I have a function which expects a Callable
parameter. I want to determine that this callable returns a string and if it doesn't an exception should be thrown.
I tried searching for this, but no luck. Does the PHP reflection API provide functionality like this? I don't want to run the method and see if it actually returns a string.
Help would be appreciated.
Example of what I need:
class MyClass
{
protected static $overrider = null;
public static function setOverrider(Callable $callback)
{
// Pseudo code start
if (!$callback returns string) {
throw new \Exception('Wasnt a string!');
}
// Pseudo code end
self::$overrider = $callback;
}
}
Aucun commentaire:
Enregistrer un commentaire