class MyClass
{
private function myPrivateMethod() {}
public getCallable(): callable
{
return \Closure::fromCallable[$this, 'myPrivateMethod']
}
}
Callback::unwrap((new MyClass())->getCallable()); // This will raise a TypeError
I think the return typehint for the unwrap function to be 'array|callable' instead of simply 'callable'.
And by the way i have see in the toString funtion a case for "lambda" when does this "if" is used ?
Hi,
Nice piece of code. There is a bug in the Callback::unwrap function (https://github.com/nette/utils/blob/master/src/Utils/Callback.php#L127), the return value could be an array and not a callable in case you have a closure using a private method. for exemple :
I think the return typehint for the unwrap function to be 'array|callable' instead of simply 'callable'.
And by the way i have see in the toString funtion a case for "lambda" when does this "if" is used ?
Have a good day.