1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #561 - add all the do-defined vars before checking loop

This commit is contained in:
Matt Brown 2018-03-08 11:17:27 -05:00
parent 67312be2a9
commit 4873228e52
2 changed files with 14 additions and 0 deletions

View File

@ -59,6 +59,12 @@ class DoChecker
}
}
foreach ($do_context->vars_in_scope as $var_id => $type) {
if (!isset($context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = clone $type;
}
}
$mixed_var_ids = [];
foreach ($do_context->vars_in_scope as $var_id => $type) {

View File

@ -975,6 +975,14 @@ class LoopScopeTest extends TestCase
}
}',
],
'doWhileDefinedVar' => [
'<?php
$value = null;
do {
$count = rand(0, 1);
$value = 6;
} while ($count);',
],
];
}