-
-
Notifications
You must be signed in to change notification settings - Fork 938
Closed
Labels
Milestone
Description
Bug report
I have a variable $a with type 1|2|3|4, and a variable $test with type int
After comparing the two variables the value of $test is narrowed down to exclude all the values in the union type, i.e int<min,0>|int<5,max>.
Then an error is detected if I compare $b ( 1|2|3|4) to $test
if($a === $test){
return true;
}
// next line raises "it always evaluates to false" error
return $b === $test;
The same doesn't apply if $a and $b are of type int<1,4>
Code snippet that reproduces the problem
https://phpstan.org/r/550fcad9-e421-40dc-8987-a59ff9082ac5
Expected output
I would expect no error since the second comparison is legitimate
Did PHPStan help you today? Did it make you happy in any way?
It helps every day. Xmas included
Reactions are currently unavailable