diff --git a/src/Psalm/Checker/Statements/Expression/AssertionFinder.php b/src/Psalm/Checker/Statements/Expression/AssertionFinder.php index b537cd0f9..0ef3b1ace 100644 --- a/src/Psalm/Checker/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Checker/Statements/Expression/AssertionFinder.php @@ -184,7 +184,11 @@ class AssertionFinder ); if ($var_name) { - $if_types[$var_name] = '!falsy'; + if ($conditional instanceof PhpParser\Node\Expr\BinaryOp\Identical) { + $if_types[$var_name] = 'true'; + } else { + $if_types[$var_name] = '!falsy'; + } } else { return self::getAssertions($base_conditional, $this_class_name, $source); } diff --git a/tests/TypeReconciliationTest.php b/tests/TypeReconciliationTest.php index d52489ab9..18e1c43e1 100644 --- a/tests/TypeReconciliationTest.php +++ b/tests/TypeReconciliationTest.php @@ -856,6 +856,17 @@ class TypeReconciliationTest extends TestCase '$doc[\'s\'][\'t\']' => 'array', ], ], + 'removeTrue' => [ + '