1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Check context var exists

This commit is contained in:
Matt Brown 2021-02-09 14:13:18 -05:00
parent 88fe805c27
commit 2dc86651a4

View File

@ -197,7 +197,12 @@ class SwitchAnalyzer
$stmt->allMatched = true;
} elseif ($switch_scope->possibly_redefined_vars) {
foreach ($switch_scope->possibly_redefined_vars as $var_id => $type) {
$context->vars_in_scope[$var_id] = Type::combineUnionTypes($type, $context->vars_in_scope[$var_id]);
if (isset($context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = Type::combineUnionTypes(
$type,
$context->vars_in_scope[$var_id]
);
}
}
}