-
Notifications
You must be signed in to change notification settings - Fork 529
implemented call_user_func
& call_user_func_array
dynamic return type extensions
#756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
the syntax errors seem unrelated as these also happen on the master branch. this is good to go - I think. |
@ondrejmirtes should be ready to merge |
rebased against master. all green now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few thoughts, wondering if we could expand some of the testing and concerns of FuncCall
when it's a StaticCall
.
call_user_func
& call_user_func_array
dynamic return type extensions
function proxy() { | ||
$params = [ | ||
'CallUserFuncArray\generic', | ||
[123] | ||
]; | ||
|
||
assertType('int', call_user_func_array(...$params)); | ||
|
||
$params = [ | ||
'CallUserFuncArray\generic', | ||
123, | ||
456 | ||
]; | ||
|
||
// cufa expect max 2 args | ||
assertType('*NEVER*', call_user_func_array(...$params)); | ||
assertType('int', call_user_func(...$params)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea yet on how to implement this cases, where only a unpack-array is passed, as I don't know how to split/what to pass into the FuncCall
- which expects the name and args separated.
all other cases seem to pass right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that in this variadic case I will let the extension just return the $defaultReturn
@ondrejmirtes any feedback on this PR? |
@staabm My top priority right now is PHP 8.1 support (https://phpstan.org/blog/plan-to-support-php-8-1). The main action is now happening in https://github.com/ondrejmirtes/BetterReflection/tree/ng and https://github.com/phpstan/phpstan-src/tree/ng-better-reflection. Once this is finished and released, the operations will return to normal eventually. I now have 187 emails in my inbox worthy of my attention (all related to PHPStan), so please stay tuned. |
@ondrejmirtes I see, thx for the update. if you see small issues I can fix to support you on the php 8.1 tasks, feel free to ping me |
$callbackType = $scope->getType($args[0]->value); | ||
$callbackArgsType = $scope->getType($args[1]->value); | ||
|
||
if ($callbackType->isCallable()->yes() && $callbackArgsType->isArray()->yes()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this entire codeblock about? Why are there instanceof specific AST nodes like Array_ and Variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this block is about unwrapping the passed in array-arg so that each array-item can be re-wrapped into Arg
objects and passed thru to the FuncCall
call_user_func_array('CallUserFuncArray\fun3', [1 ,2 ,3])
-> CallUserFuncArray\fun3(1, 2, 3);
ddd20b4
to
95d480b
Compare
Hi, I'm cleaning up old and stale PRs. Please send a new PR if you're still interested, thanks. This has been a draft for about a year. |
closes phpstan/phpstan#5942