Support getting reflection of an anonymous function#100
Support getting reflection of an anonymous function#100Lctrs wants to merge 1 commit intophpstan:masterfrom Lctrs:closure-reflection
Conversation
|
Hi, I don't understand what you're trying to achieve. Can you first post something on phpstan.org that fails? |
|
Hi @ondrejmirtes, Well, nothing fails. In rectorphp/rector#2658, I worked on a class that could resolve any calls ( I had one problem when I don't know if I did the right thing though. Here is where I implemented it, maybe you can understand me better with this. |
From https://www.php.net/manual/en/class.closure.php : > Besides the methods listed here, this class also has an __invoke method.
|
For |
|
It works with this too for example: $func = 'date';
$func();So |
|
Something like this ? $type = $scope->getType($funcCall->name);
$parametersAcceptors = $type->getCallableParametersAcceptors($scope);
return new NativeFunctionReflection(
'{closure}', //TODO: get real name
$parametersAcceptors,
null,
TrinaryLogic::createMaybe()
);Is this the PHPStan way of doing the following ? $f = function() {};
$r = new \ReflectionFunction($f);
$f = 'date';
$r = new \ReflectionFunction($f); |
|
Not sure what you need FunctionReflection, but yeah, something like that. |
From https://www.php.net/manual/en/class.closure.php :