1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Limit removal of vars further

This commit is contained in:
Matt Brown 2021-02-09 00:53:09 -05:00
parent ad0b575080
commit ecfc4726d7
2 changed files with 2 additions and 0 deletions

View File

@ -249,6 +249,7 @@ class ElseIfAnalyzer
foreach ($elseif_context->vars_in_scope as $var_id => $_) {
if (preg_match('/' . preg_quote($changed_var_id, '/') . '[\]\[\-]/', $var_id)
&& !\array_key_exists($var_id, $newly_reconciled_var_ids)
&& !\array_key_exists($var_id, $cond_referenced_var_ids)
) {
unset($elseif_context->vars_in_scope[$var_id]);
}

View File

@ -294,6 +294,7 @@ class IfElseAnalyzer
foreach ($if_context->vars_in_scope as $var_id => $_) {
if (preg_match('/' . preg_quote($changed_var_id, '/') . '[\]\[\-]/', $var_id)
&& !\array_key_exists($var_id, $changed_var_ids)
&& !\array_key_exists($var_id, $cond_referenced_var_ids)
) {
unset($if_context->vars_in_scope[$var_id]);
}