diff --git a/src/Psalm/Internal/Algebra.php b/src/Psalm/Internal/Algebra.php index 2c632906e..3574841ea 100644 --- a/src/Psalm/Internal/Algebra.php +++ b/src/Psalm/Internal/Algebra.php @@ -325,6 +325,7 @@ class Algebra /** * Look for clauses with only one possible value * + * doesn't infer the "unset" correctly * @psalm-suppress MoreSpecificReturnType * @param list $clauses * @param array $cond_referenced_var_ids diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index 6a6417f73..fdfa804bc 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -2336,6 +2336,8 @@ class AssertionFinder $if_types = $if_types ? [$if_types] : []; if ($if_types === [] && count($notif_types) === 2) { + $check_var_assertion = null; + $check_var = null; foreach ($notif_types as $notif_type) { foreach ($notif_type as $var => $assertions) { if (count($assertions) !== 1 || count($assertions[0]) !== 1) { @@ -3066,6 +3068,8 @@ class AssertionFinder // @todo optionally extend this to arbitrary number of assert-if cases of multiple variables in the function // same code above too if ($if_types === [] && count($notif_types) === 2) { + $check_var_assertion = null; + $check_var = null; foreach ($notif_types as $notif_type) { foreach ($notif_type as $var => $assertions) { if (count($assertions) !== 1 || count($assertions[0]) !== 1) {