You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subsequent nullsafe method calls on nullable variable results in false positive #6922
I have tried to narrow down the problem and I found that PHPStan correctly assumes the type if the (possible null) bool value is compared to TRUE but throws an error if compared to FALSE. Since both comparisons are strict I believe this to be a bug.
Here is the issue demonstrated using the PHPStan playground:
Activity
janchaloupka commentedon Sep 20, 2022
Hello I have also encountered this issue.
I have tried to narrow down the problem and I found that PHPStan correctly assumes the type if the (possible null) bool value is compared to
TRUEbut throws an error if compared toFALSE. Since both comparisons are strict I believe this to be a bug.Here is the issue demonstrated using the PHPStan playground:
Strict comparison with
FALSEvalue (incorrect type assumed).https://phpstan.org/r/1f061693-59d3-4205-b910-1e2822f9d499
Strict comparison with
TRUEvalue (everything works as expected).https://phpstan.org/r/cc552cae-25f0-4a5e-8c01-80ef681a4278
phpstan-bot commentedon Oct 30, 2023
@egonolieux After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:
phpstan-bot commentedon Oct 30, 2023
@janchaloupka After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.1 – 8.2
No errors
PHP 7.1 – 8.0 (1 error)
Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 6Regression tests
github-actions commentedon Dec 4, 2023
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.