-
Notifications
You must be signed in to change notification settings - Fork 533
Fix lost type when assigning variable in method argument #4293
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
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 don't like this fix, it's very one-off. There are many things in expressions that aren't assigns, that would still be broken.
As I said, this either needs virtual nodes, or ambitious refactoring.
so you mean e.g. a |
this would mean something like a new |
The args need to be considered together. Looking at this the problem goes really deep and it might not be so easy to fix. Looking at places where FunctionCallParametersCheck is called, ParametersAcceptorSelector is called: ParametersAcceptorSelector::selectFromArgs(
$scope,
$node->getArgs(),
$constructorReflection->getVariants(),
$constructorReflection->getNamedArgumentsVariants(),
) The considered types inside are going to be wrong too because we're only passing along a single scope. And of course this method is one of the most used methods across the codebase. Changing that would have ripple effects across the ecosystem so we can't do that now. Also, The proper Argument virtual nodes objects would need to be made inside |
So my conclusion is that we can fix If people do assignment shenanigans and they have wrong generics resolved because of that, it's not so easy to fix. |
No, I meant the really ambitious refactoring that I described here #4237 (comment) and that I don't know how the code should look like after yet 😅 |
While this makes sense it sounds to be a big undertaking to support things I don't like to use at all myself (assigns in expressions). I prefer to spend my time somewhere on something more valuable |
Yeah, sure 👍 Keeping this open because the tests are valuable. |
closes phpstan/phpstan#12234
closes phpstan/phpstan#12735