Bug report
PHPStan reports the following error on the second if condition in the linked snippet:
Right side of && is always false.
I believe this is a false positive.
After the first condition, PHPStan can infer that !($a && $b && $c) is true, meaning at least one of $a, $b, or $c is false. However, that does not imply that $b must be false when $c is true.
For example, this input reaches the second branch:
$a = false;
$b = true;
$c = true;
In that case, the first condition is false, but the second condition is true.
Also, the issue appears to depend on operand order. The warning is reported for:
but not for:
These expressions are logically equivalent in this case, so I would not expect PHPStan to report an error for only one of them.
Code snippet that reproduces the problem
https://phpstan.org/r/bbf2c2c1-fb4b-4c5d-857d-47d4eb1e3873
Expected output
No error should be reported
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
PHPStan reports the following error on the second
ifcondition in the linked snippet:I believe this is a false positive.
After the first condition, PHPStan can infer that
!($a && $b && $c)is true, meaning at least one of$a,$b, or$cis false. However, that does not imply that$bmust be false when$cis true.For example, this input reaches the second branch:
In that case, the first condition is false, but the second condition is true.
Also, the issue appears to depend on operand order. The warning is reported for:
but not for:
These expressions are logically equivalent in this case, so I would not expect PHPStan to report an error for only one of them.
Code snippet that reproduces the problem
https://phpstan.org/r/bbf2c2c1-fb4b-4c5d-857d-47d4eb1e3873
Expected output
No error should be reported
Did PHPStan help you today? Did it make you happy in any way?
No response