Bug report
PHPStan reports Strict comparison using === between false and true will always evaluate to false. for $initial even though it can actually be both true or false. The variable is very clearly never changed inside the function, and the function always returns. This is trivially proven by running the script in CLI and seeing that it shows both true and false in the console.
It seems that when $current is narrowed in the if-statement then $initial also gets narrowed for some reason, despite being unrelated apart from being the initial source of the value. This only happens if $initial is used to set the value of $current, so I assume there's some underlying dependency that is incorrectly retained.
This error only occurs when "Strict rules" is enabled. I'm not 100% sure, but I believe this bug was introduced "quite recently" (maybe a few months ago?) as this code didn't previously have this problem.
Code snippet that reproduces the problem
https://phpstan.org/r/8b0e6c11-886f-43f9-9cad-0876d033f330
Expected output
PHPStan should not report an error, the code is valid.
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
PHPStan reports
Strict comparison using === between false and true will always evaluate to false.for$initialeven though it can actually be bothtrueorfalse. The variable is very clearly never changed inside the function, and the function always returns. This is trivially proven by running the script in CLI and seeing that it shows bothtrueandfalsein the console.It seems that when
$currentis narrowed in the if-statement then$initialalso gets narrowed for some reason, despite being unrelated apart from being the initial source of the value. This only happens if$initialis used to set the value of$current, so I assume there's some underlying dependency that is incorrectly retained.This error only occurs when "Strict rules" is enabled. I'm not 100% sure, but I believe this bug was introduced "quite recently" (maybe a few months ago?) as this code didn't previously have this problem.
Code snippet that reproduces the problem
https://phpstan.org/r/8b0e6c11-886f-43f9-9cad-0876d033f330
Expected output
PHPStan should not report an error, the code is valid.
Did PHPStan help you today? Did it make you happy in any way?
No response