-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#4881Labels
Milestone
Description
Bug report
Given two booleans $b and $c, the following ought to work:
function a(bool $b, bool $c): int {
return match(true) {
$b && $c => 1,
!$b && !$c => 2,
!$b && $c => 3,
$b && !$c => 4,
};
}but, I'm getting a "Match expression does not handle remaining value: true"
The original problem:
https://phpstan.org/r/142cf3a3-37d4-4cce-bd44-d703936d8283
Then I tried giving each arm a value:
https://phpstan.org/r/4b78755c-5f87-454a-ba0c-a9eb17baeb4f
And then I tried using strict comparison on true and false
https://phpstan.org/r/5dd7c48b-df06-4a57-9cc1-07de2466cffd
All three are giving the same error, even though at least one of them will always be true
Code snippet that reproduces the problem
https://phpstan.org/r/142cf3a3-37d4-4cce-bd44-d703936d8283
Expected output
I expected no errors.
Did PHPStan help you today? Did it make you happy in any way?
As always, great product - and of course, I'm sponsoring ;)
Reactions are currently unavailable