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:
parent
f0141cab4e
commit
e5c25eae97
@ -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,
|
||||
|
@ -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' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user