-
Notifications
You must be signed in to change notification settings - Fork 545
NodeScopeResolver: do not corrupt type info on invalid offset assignments #311
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
this fixes phpstan/phpstan#3782. I'm not sure if this may have any side effects, but I can't see any circumstances where it makes sense to reassign an object as an array on array dim fetch.
this resulted in a change of behaviour in one of the tests, which I think is OK because this bug fix happens to kill another bird with the same stone: repeated access to illegal offsets on strings now report **all** illegal accesses instead of just the first one.
|
The latest commit caused a change in behaviour to the result of string offset accesses, which I believe is acceptable because the old behaviour was causing some errors not to be reported, like the one missing from line 8 here: https://phpstan.org/r/801fa88f-87bb-49c3-8c6c-ea8b781fb950 |
this test is broken because of phpstan/phpstan#3803, because phpstan believes the string will never change in this scenario, which is wrong.
a non-benevolent union type key may or may not change a string, which is what we want for this test.
f54fd5f to
eca550a
Compare
|
This is fixed for the object case, but the following array coercion is still not expected (and is fixed by this PR): https://phpstan.org/r/43b7a9c7-06cf-414c-ab58-63392fa4a357 |
|
This happens because |
d45166a to
3526237
Compare
efd31ce to
0471f87
Compare
|
The linked issue got fixed. |
this fixes phpstan/phpstan#3782.
I'm not sure if this may have any side effects, but I can't see any circumstances where it makes sense to reassign an object as an array on array dim fetch.