From 7df819e585dad029813cf1035811c5844d0f7efc Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Mon, 6 Sep 2021 21:26:43 -0400 Subject: [PATCH] Unrelated: Use strict_equality instead of loose_equality for `===` checks (`=` is strict equality, `~` is loose equality) --- .../Statements/Expression/AssertionFinder.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index 4a2631bfe..c9a30914a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -465,7 +465,7 @@ class AssertionFinder if ($var_name_left && (!$var_type->isSingle() || $var_type->getAssertionString() !== $assertion)) { - $if_types[$var_name_left] = [['~'.$assertion]]; + $if_types[$var_name_left] = [['='.$assertion]]; } $var_name_right = ExpressionIdentifier::getArrayVarId( @@ -476,7 +476,7 @@ class AssertionFinder if ($var_name_right && (!$other_type->isSingle() || $other_type->getAssertionString() !== $assertion)) { - $if_types[$var_name_right] = [['~'.$assertion]]; + $if_types[$var_name_right] = [['='.$assertion]]; } return $if_types ? [$if_types] : []; @@ -3456,14 +3456,13 @@ class AssertionFinder } } else { foreach ($value_type->getAtomicTypes() as $atomic_value_type) { - if ($atomic_value_type instanceof Type\Atomic\TLiteralInt - || $atomic_value_type instanceof Type\Atomic\TLiteralString - || $atomic_value_type instanceof Type\Atomic\TLiteralFloat - || $atomic_value_type instanceof Type\Atomic\TEnumCase + if ($atomic_value_type instanceof Type\Atomic\TFalse + || $atomic_value_type instanceof Type\Atomic\TTrue + || $atomic_value_type instanceof Type\Atomic\TNull ) { - $assertions[] = '=' . $atomic_value_type->getAssertionString(); - } else { $assertions[] = $atomic_value_type->getAssertionString(); + } else { + $assertions[] = '=' . $atomic_value_type->getAssertionString(); } } }