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
False negative with nested if in for loop #4666
Comments
I see the "easy fixes" label, if you point me out which part of code should be updated, I can make a PR |
I actually don't know what's going on and why is this reported, probably the left part of the && expression influences something about the right part which shouldn't be happening. "Easy fix" just means that it will not be hard to fix, but it needs to be debugged what's going on in Scope with this situation. |
My tip is actually that the TypeSpecifier does something weird with this part: |
@nikophil After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-13: Result of && is always false.
+ 9: Method HelloWorld::test() is unused.
+13: Result of && is always false.
+22: Property MyObject::$type is never written, only read. Full report
|
@nikophil After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-13: Result of && is always false.
+13: Result of && is always false.
+ 9: Method HelloWorld::test() is unused.
+22: Property MyObject::$type is never written, only read. Full report
|
@nikophil After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-13: Result of && is always false.
+ 9: Method HelloWorld::test() is unused.
+22: Property MyObject::$type is never written, only read. Full report
|
Fixed: phpstan/phpstan-src@4321374 |
Closes phpstan/phpstan#5759 Closes phpstan/phpstan#5668 Closes phpstan/phpstan#5496 Closes phpstan/phpstan#4666 Closes phpstan/phpstan#3892 Closes phpstan/phpstan#3314 Closes phpstan/phpstan#2870 Closes phpstan/phpstan#5354
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. |
Hello there,
Bug report
Here is an example of the problem.
https://phpstan.org/r/c499e9ad-92a3-47ec-91ba-42d0920dbc06
I got a false negative on this code. I know the code is far from ideal but it actually works, and moreover on the first iteration, the
&&
result is definitely not false...What's weird is that when you change the if in order to use
CONST_2
in both part of the&&
, phpstan returns 0 errors, although both parts of the&&
are unrelated. Or maybe i'm missing something OoIf i split the
&&
in order to use two nestedif
, I got no errors as well...Expected output
no error should be reported.
The text was updated successfully, but these errors were encountered: