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
If array keys are known, they should be used to infer lookup types #6108
Comments
A workaround is to introduce a temp var before the inner foreach, it works like expected |
This was recently fixed and works in PHPStan 1.4.4. |
ondrejmirtes
added a commit
to phpstan/phpstan-src
that referenced
this issue
Feb 28, 2022
Closes phpstan/phpstan#5893 Closes phpstan/phpstan#6070 Closes phpstan/phpstan#5869 Closes phpstan/phpstan#6212 Closes phpstan/phpstan#6262 Closes phpstan/phpstan#6266 Closes phpstan/phpstan#6023 Closes phpstan/phpstan#6108 Closes phpstan/phpstan#6020 Closes phpstan/phpstan#1746 Closes phpstan/phpstan#1516 Closes phpstan/phpstan#6174 Closes phpstan/phpstan#6112 Closes phpstan/phpstan#5749 Closes phpstan/phpstan#5969 Closes phpstan/phpstan#5295 Closes phpstan/phpstan#5675 Closes phpstan/phpstan#5369 Closes phpstan/phpstan#6699 Closes phpstan/phpstan#6505
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Feature request
If I have two arrays, each of which have a defined shape, PHPStan should be able to figure out the value of array lookups. For example:
This results in an error on the
foreach
line: "Argument of an invalid type array|bool supplied for foreach, only iterables are supported." (playground link). However, PHPStan should "know" that$key
has type'a'|'b'
, both of which would be keys on$x
that contain values that are valid to iterate over.The text was updated successfully, but these errors were encountered: