-
-
Notifications
You must be signed in to change notification settings - Fork 864
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional types regressions #8467
Labels
Comments
Thank you for investigating! |
rajyan
added a commit
to rajyan/phpstan-src
that referenced
this issue
Dec 6, 2022
rajyan
added a commit
to rajyan/phpstan-src
that referenced
this issue
Dec 6, 2022
rajyan
added a commit
to rajyan/phpstan-src
that referenced
this issue
Dec 7, 2022
rajyan
added a commit
to rajyan/phpstan-src
that referenced
this issue
Dec 7, 2022
@ondrejmirtes After the latest push in 1.9.x, PHPStan now reports different result with your code snippet: @@ @@
-17: Foreach overwrites $v with its value variable.
+No errors |
馃憤 |
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.
Bug report
Hi @rajyan, there's some more work to do 馃槄
I updated the Composer integration test and there are some new errors. The build is green on 1.9.2:
In ShowCommand it should know the type is narrowed because the getter has an array shape type alias. So it should know it's already
list<string>
.SuggestedPackagesReporter might be a bit tricky. This isn't new behaviour but it's reported in more cases because the conditonal types are now more "smart". The problem is in
polluteScopeWithAlwaysIterableForeach: false
(the configuration in phpstan-strict-rules which also adds the rule "foreach overwrites existing variable"). Here it is: https://phpstan.org/r/a58b7580-7018-418b-bbe6-157c5ee91758The problem is that PHPStan with
polluteScopeWithAlwaysIterableForeach: false
SHOULD NOT know that a variable always exists if some array is non-empty. But here it is aware that if $k is non-empty then$v
always exists. But withpolluteScopeWithAlwaysIterableForeach: false
we don't want this behaviour. It might be a bit tricky to fix...And the Mercurial and Git problems are the same - the value is already checked and cannot be
null
at that point.Thank you very much for looking into this, I'd be really gratefuly if you were able to fix at least some of those.
The text was updated successfully, but these errors were encountered: