1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix strict reconciliation of bools

This commit is contained in:
Matt Brown 2018-05-07 18:09:40 -04:00
parent 3c9e42f884
commit 0eda76b742
2 changed files with 15 additions and 1 deletions

View File

@ -863,7 +863,9 @@ class Reconciler
$did_remove_type = false;
foreach ($existing_var_atomic_types as $type) {
if (!$type instanceof TBool) {
if (!$type instanceof TBool
|| ($is_strict_equality && get_class($type) === TBool::class)
) {
$non_bool_types[] = $type;
} else {
$did_remove_type = true;

View File

@ -819,6 +819,18 @@ class TypeAlgebraTest extends TestCase
$a = (($s === "a" && rand(0, 1)) || ($s === "b" && rand(0, 1))) ? 1 : 0;',
],
'boolComparison' => [
'<?php
$a = (bool) rand(0, 1);
if (rand(0, 1)) {
$a = null;
}
if ($a !== (bool) rand(0, 1)) {
echo $a === false ? "a" : "b";
}',
],
];
}