Permalink
Browse files

fixed callback::check() [Closes nette/utils#179]

  • Loading branch information...
dg committed Nov 20, 2018
1 parent 9a5a06f commit 631aea8099f4ff3fcfcd953c4289472a705e0ddc
Showing with 14 additions and 14 deletions.
  1. +7 −7 cs/callback.texy
  2. +7 −7 en/callback.texy
@@ -12,17 +12,17 @@ use Nette\Utils\Callback;
\--


check($callable, bool $syntax = false): bool .[method]
------------------------------------------------------
check($callable, bool $syntax = false): callable .[method]
----------------------------------------------------------

Zkontroluje, zda proměnná `$callable` může být volána jako funkce. Jinak vyhodí `Nette\InvalidArgumentException`. Pokud je `$syntax` nastavena na hodnotu true, funkce jen ověří, že `$callable` má strukturu callbacku, ale neověřuje, zda daná třída nebo metoda skutečně existuje.

/--php
echo Callback::check('trim'); // true
echo Callback::check(['NonExistentClass', 'method']); // false
echo Callback::check(['NonExistentClass', 'method'], true); // true
echo Callback::check(function () {}); // true
echo Callback::check(null); // false
Callback::check('trim'); // nevyhodí výjimku
Callback::check(['NonExistentClass', 'method']); // vyhodí Nette\InvalidArgumentException
Callback::check(['NonExistentClass', 'method'], true); // nevyhodí výjimku
Callback::check(function () {}); // nevyhodí výjimku
Callback::check(null); // vyhodí Nette\InvalidArgumentException
\--


@@ -11,17 +11,17 @@ use Nette\Utils\Callback;
\--


check($callable, bool $syntax = false): bool .[method]
------------------------------------------------------
check($callable, bool $syntax = false): callable .[method]
----------------------------------------------------------

Checks that `$callable` can be called as a function. Otherwise throws `Nette\InvalidArgumentException`. If the `$syntax` is set to true, the function only verifies that `$callable` has a valid structure to be used as a callback, but does not verify if the class or method actually exists.

/--php
echo Callback::check('trim'); // true
echo Callback::check(['NonExistentClass', 'method']); // false
echo Callback::check(['NonExistentClass', 'method'], true); // true
echo Callback::check(function () {}); // true
echo Callback::check(null); // false
Callback::check('trim'); // no exception
Callback::check(['NonExistentClass', 'method']); // throws Nette\InvalidArgumentException
Callback::check(['NonExistentClass', 'method'], true); // no exception
Callback::check(function () {}); // no exception
Callback::check(null); // throws Nette\InvalidArgumentException
\--


0 comments on commit 631aea8

Please sign in to comment.