From c0ab1b974bdda34257eb82d86f0affa13859950c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 16 Feb 2018 16:13:16 +0100 Subject: [PATCH] Callback::invoke() and invokeArgs() are deprecated in favor of native invocation --- src/Utils/Callback.php | 2 ++ tests/Utils/Callback.invoke.phpt | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Utils/Callback.php b/src/Utils/Callback.php index 421ac420c..7840bbb99 100644 --- a/src/Utils/Callback.php +++ b/src/Utils/Callback.php @@ -41,6 +41,7 @@ public static function closure($callable, string $method = null): \Closure */ public static function invoke($callable, ...$args) { + trigger_error(__METHOD__ . '() is deprecated, une native invoking.', E_USER_DEPRECATED); self::check($callable); return $callable(...$args); } @@ -53,6 +54,7 @@ public static function invoke($callable, ...$args) */ public static function invokeArgs($callable, array $args = []) { + trigger_error(__METHOD__ . '() is deprecated, une native invoking.', E_USER_DEPRECATED); self::check($callable); return $callable(...$args); } diff --git a/tests/Utils/Callback.invoke.phpt b/tests/Utils/Callback.invoke.phpt index ae685b412..9d072f29f 100644 --- a/tests/Utils/Callback.invoke.phpt +++ b/tests/Utils/Callback.invoke.phpt @@ -30,20 +30,20 @@ class Test $cb = [new Test, 'fun']; -Assert::same('Test::fun*', Callback::invoke($cb, '*')); -Assert::same('Test::fun*', Callback::invokeArgs($cb, ['*'])); +Assert::same('Test::fun*', @Callback::invoke($cb, '*')); // is deprecated +Assert::same('Test::fun*', @Callback::invokeArgs($cb, ['*'])); // is deprecated $cb = [new Test, 'ref']; -Assert::same('Test::ref', Callback::invokeArgs($cb, [&$ref])); +Assert::same('Test::ref', @Callback::invokeArgs($cb, [&$ref])); // is deprecated Assert::same('Test::ref', $ref); Assert::exception(function () { - Callback::invoke('undefined'); + @Callback::invoke('undefined'); // is deprecated }, Nette\InvalidArgumentException::class, "Callback 'undefined' is not callable."); Assert::exception(function () { - Callback::invokeArgs('undefined'); + @Callback::invokeArgs('undefined'); // is deprecated }, Nette\InvalidArgumentException::class, "Callback 'undefined' is not callable.");