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

"Variable $i might not be defined." in for loop using comma operator (binary search) #3858

Closed
gnutix opened this issue Sep 11, 2020 · 2 comments

Comments

@gnutix
Copy link

gnutix commented Sep 11, 2020

Bug report

While implementing a binary search, we used a comma operator within a for loop and use the $i variable outside the loop too, and it is in practice always defined.

Code snippet that reproduces the problem

https://phpstan.org/r/85c66c6f-a6d4-4084-8815-07d3f46b099d
https://3v4l.org/LVt1P

Expected output

No errors

@phpstan-bot
Copy link
Contributor

@gnutix After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-18: Variable $i might not be defined.
+No errors

@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 Feb 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants