Skip to content
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

Union types inside loop don’t apply to the whole loop #9753

Closed
driskell opened this issue Aug 11, 2023 · 2 comments
Closed

Union types inside loop don’t apply to the whole loop #9753

driskell opened this issue Aug 11, 2023 · 2 comments

Comments

@driskell
Copy link

driskell commented Aug 11, 2023

Bug report

It seems that the type of $items is different depending on where in the loop you are - as in it is inferred like it is a run once loop. When actually because it’s a loop the types should be the same throughout.

Definitely terrible code example but a good demonstration.

Code snippet that reproduces the problem

https://phpstan.org/r/32a3c556-8022-4599-a675-e7cc7290e107

Expected output

Clean with no errors

Did PHPStan help you today? Did it make you happy in any way?

I will forever be a happy PHPStan user!

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@c09be9e

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants