Skip to content
Permalink
Browse files

Fix #2464 - null coalesce shouldn’t allow undefined vars

  • Loading branch information
muglug committed Dec 13, 2019
1 parent 6ff312f commit ca5f8fabdc07bf1b5a0f54dc7b5c1c3f1bab663d
@@ -586,7 +586,11 @@ function (\Psalm\Internal\Clause $c) use ($mixed_var_ids) {
new CodeLocation($statements_analyzer->getSource(), $stmt->left)
);

$t_if_context->vars_in_scope = $t_if_vars_in_scope_reconciled;
foreach ($context->vars_in_scope as $var_id => $_) {
if (isset($t_if_vars_in_scope_reconciled[$var_id])) {
$t_if_context->vars_in_scope[$var_id] = $t_if_vars_in_scope_reconciled[$var_id];
}
}
}

if (!self::hasArrayDimFetch($stmt->left)) {
@@ -744,6 +744,16 @@ function foo(string $s) : string {
}',
'error_message' => 'NullableReturnStatement',
],
'undefinedVarInNullCoalesce' => [
'<?php
function bar(): void {
$do_baz = $config["do_it"] ?? false;
if ($do_baz) {
baz();
}
}',
'UndefinedVariable'
],
];
}
}

0 comments on commit ca5f8fa

Please sign in to comment.
You can’t perform that action at this time.