-
-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if (with assignment to existing variable and type checking) is always false #2499
Comments
Hi, you got operators priority wrong. PHPStan is right. Compare: https://3v4l.org/tL3B1 with https://3v4l.org/eXP58. |
Sorry, looks like it should not be reported: https://3v4l.org/DbMmp |
@yura3d After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-5: If condition is always false.
+5: If condition is always false.
+5: Result of && is always false. Full report
|
@yura3d After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-5: If condition is always false.
+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. |
Bug report
If I declare a variable and set a value of some type to it (let it be
int
, like in code snippet), change its value (mixed
in snippet) in if statement and check the variable to be another type (string
in snippet) in the same if statement, I get "If condition is always false".Code snippet that reproduces the problem
https://phpstan.org/r/884e2c78-c95c-46f8-8a01-0d990cddee0a
Expected output
No errors, like it works when the variable is not declared before if statement
The text was updated successfully, but these errors were encountered: