Skip to content

Commit c0ab1b9

Browse files
committed
Callback::invoke() and invokeArgs() are deprecated in favor of native invocation
1 parent fd87fe8 commit c0ab1b9

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Utils/Callback.php

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static function closure($callable, string $method = null): \Closure
4141
*/
4242
public static function invoke($callable, ...$args)
4343
{
44+
trigger_error(__METHOD__ . '() is deprecated, une native invoking.', E_USER_DEPRECATED);
4445
self::check($callable);
4546
return $callable(...$args);
4647
}
@@ -53,6 +54,7 @@ public static function invoke($callable, ...$args)
5354
*/
5455
public static function invokeArgs($callable, array $args = [])
5556
{
57+
trigger_error(__METHOD__ . '() is deprecated, une native invoking.', E_USER_DEPRECATED);
5658
self::check($callable);
5759
return $callable(...$args);
5860
}

tests/Utils/Callback.invoke.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ class Test
3030

3131

3232
$cb = [new Test, 'fun'];
33-
Assert::same('Test::fun*', Callback::invoke($cb, '*'));
34-
Assert::same('Test::fun*', Callback::invokeArgs($cb, ['*']));
33+
Assert::same('Test::fun*', @Callback::invoke($cb, '*')); // is deprecated
34+
Assert::same('Test::fun*', @Callback::invokeArgs($cb, ['*'])); // is deprecated
3535

3636

3737
$cb = [new Test, 'ref'];
38-
Assert::same('Test::ref', Callback::invokeArgs($cb, [&$ref]));
38+
Assert::same('Test::ref', @Callback::invokeArgs($cb, [&$ref])); // is deprecated
3939
Assert::same('Test::ref', $ref);
4040

4141

4242
Assert::exception(function () {
43-
Callback::invoke('undefined');
43+
@Callback::invoke('undefined'); // is deprecated
4444
}, Nette\InvalidArgumentException::class, "Callback 'undefined' is not callable.");
4545

4646

4747
Assert::exception(function () {
48-
Callback::invokeArgs('undefined');
48+
@Callback::invokeArgs('undefined'); // is deprecated
4949
}, Nette\InvalidArgumentException::class, "Callback 'undefined' is not callable.");

0 commit comments

Comments
 (0)