NodeScopeResolver: do not corrupt type info on invalid offset assignments#311
Closed
dktapps wants to merge 7 commits intophpstan:masterfrom
pmmp:array-dim-fetch-var-type-corruption
Closed
NodeScopeResolver: do not corrupt type info on invalid offset assignments#311dktapps wants to merge 7 commits intophpstan:masterfrom pmmp:array-dim-fetch-var-type-corruption
dktapps wants to merge 7 commits intophpstan:masterfrom
pmmp:array-dim-fetch-var-type-corruption
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.
Contributor
Author
|
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 |
dktapps
commented
Aug 31, 2020
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
Contributor
Author
|
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 |
Member
|
This happens because |
d45166a to
3526237
Compare
efd31ce to
0471f87
Compare
Member
|
The linked issue got fixed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.