mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix issue erasing nullability of boolean
This commit is contained in:
parent
2c245b0a08
commit
d4107f9e5e
@ -229,6 +229,12 @@ class AssertionFinder
|
||||
} else {
|
||||
$if_types[$var_name] = [['falsy']];
|
||||
}
|
||||
} elseif ($var_type) {
|
||||
$notif_types = self::getAssertions($base_conditional, $this_class_name, $source);
|
||||
|
||||
if (count($notif_types) === 1) {
|
||||
$if_types = \Psalm\Type\Algebra::negateTypes($notif_types);
|
||||
}
|
||||
}
|
||||
|
||||
if ($var_type) {
|
||||
@ -258,12 +264,6 @@ class AssertionFinder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$notif_types = self::getAssertions($base_conditional, $this_class_name, $source);
|
||||
|
||||
if (count($notif_types) === 1) {
|
||||
$if_types = \Psalm\Type\Algebra::negateTypes($notif_types);
|
||||
}
|
||||
}
|
||||
|
||||
return $if_types;
|
||||
|
@ -456,6 +456,18 @@ class RedundantConditionTest extends TestCase
|
||||
if ($s !== true ) {}
|
||||
}',
|
||||
],
|
||||
'noRedundantConditionNullableBoolIsFalseOrTrue' => [
|
||||
'<?php
|
||||
function foo(?bool $s) : void {
|
||||
if ($s === false ) {} elseif ($s === true) {}
|
||||
}',
|
||||
],
|
||||
'noRedundantConditionNullableBoolIsTrueOrFalse' => [
|
||||
'<?php
|
||||
function foo(?bool $s) : void {
|
||||
if ($s === true ) {} elseif ($s === false) {}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user