1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #172 - make sure new coalesce vars escape brackets

This commit is contained in:
Matt Brown 2017-06-20 15:38:32 -04:00
parent f0141cab4e
commit e5c25eae97
2 changed files with 11 additions and 3 deletions

View File

@ -968,6 +968,14 @@ class ExpressionChecker
return false;
}
foreach ($t_if_context->vars_in_scope as $var_id => $type) {
if (isset($context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = Type::combineUnionTypes($context->vars_in_scope[$var_id], $type);
} else {
$context->vars_in_scope[$var_id] = $type;
}
}
if ($context->collect_references) {
$context->referenced_vars = array_merge(
$context->referenced_vars,

View File

@ -60,10 +60,10 @@ class Php70Test extends TestCase
],
'nullCoalesceWithReference' => [
'<?php
$arr = ["hello", "goodbye"];
$a =& $arr[rand(0, 10)] ?? null;',
$var = 0;
($a =& $var) ?? "hello";',
'assertions' => [
['string|null' => '$a'],
['int' => '$a'],
],
],
'spaceship' => [