-
Notifications
You must be signed in to change notification settings - Fork 546
Fix "list type lost in for loop" #4403
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
Conversation
|
we could make this work for more involved loops, but I think this will work as a first step -- other examples
|
|
This pull request has been marked as ready for review. |
| && $stmt->init[0] instanceof Assign | ||
| && $stmt->init[0]->var instanceof Variable | ||
| && $stmt->init[0]->expr instanceof Node\Scalar\Int_ | ||
| && $stmt->init[0]->expr->value === 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could do >=0
|
Thank you! |
|
any opinions on the other given examples? do you think this can work and should be implemented? |
|
Instead of writing many many conditions, I'd like if this could be expressed more by the type system. That would cover all situations. But I'm not sure yet how it could look. |
|
ok thanks. no priority on it. |
if the for loop is in the shape of
for($i = 0; $i < count($items); $i++) {we can set$items[$i]as existing expression type.closes phpstan/phpstan#12807