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
"Instanceof static" is treated erroneously as "instanceof self" #2231
Labels
Comments
I fixed by treating this comparison identically to |
@kiler129 After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-6: Result of && is always false.
+No errors |
Fixed: phpstan/phpstan-src@4acbc6c |
ondrejmirtes
added a commit
to phpstan/phpstan-src
that referenced
this issue
Mar 15, 2021
Closes phpstan/phpstan#2231 Closes phpstan/phpstan#3558 Closes phpstan/phpstan#4671 Closes phpstan/phpstan#3351 Closes phpstan/phpstan#4648 Closes phpstan/phpstan#4213 Closes phpstan/phpstan#3523 Closes phpstan/phpstan#3120 Closes phpstan/phpstan#1652 Closes phpstan/phpstan#1843
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
A statement
$foo instanceof static
is treated like thestatic
is always the same class as the class where statement is placed. This is obviously wrong, and the easiest example will be to imagine an abstract class which does such check.Code snippet that reproduces the problem
Running example: https://3v4l.org/O87Qc
Analysis: https://phpstan.org/r/d6cb91f9-e428-4652-a8b0-16ee03ff6759
Currently the analysis reports
Result of && is always false.
for$x !== null && !($x instanceof static)
where?foo $x
Expected output
No error is expected. Psalm recently fixed the same problem: https://psalm.dev/r/4223401cd8
The text was updated successfully, but these errors were encountered: