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
Dynamic array key access does not work if key is optional even after isset() #7000
Comments
Confirmed that it was broken by this change
I think it means this commit caused a regression but place to fix is somewhere related to truthy scope of isset. |
|
https://phpstan.org/r/9496a732-ceff-43ce-ad47-b30af5a9baa4 related to |
I think the type in isset truthy scope can be improved as I’m not sure why it is only working when there is a following foreach |
@rajyan This type isn't a solution. You're losing the array shape and the error should not be reported only for |
@ondrejmirtes https://phpstan.org/r/441c0694-0e3b-404f-a25e-f85522e1780f By the way, there seems to be a bug with |
Maybe a duplicate of #6508 |
* add regression tests for phpstan/phpstan#7000 * specify expression even it doesn't change types * skip UnionType offset because it's hard to solve in some cases * skip specified expressions in NonexistentOffsetInArrayDimFetchRule * fix tests * add regression tests * fix useless call in foreach * fix issue-7190 too * Avoided duplicate namespace Co-authored-by: Ondřej Mirtes <ondrej@mirtes.cz>
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
This shows it best.
https://phpstan.org/r/5bd531ea-0a41-4be8-bbf9-3ca42e8d0bbe
It seems to be a "regression" of the 1.5.4 release which is unsurprising given it fixed a lot of issues related to arrays. But I do believe the behavior is incorrect and hope it can be fixed.
Expected output
No error
The text was updated successfully, but these errors were encountered: