1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #2970 - use correct unreferenced vars when analysing do

This commit is contained in:
Matthew Brown 2020-03-13 11:41:17 -04:00
parent 92e3d61663
commit 54d38e562f
2 changed files with 16 additions and 1 deletions

View File

@ -228,7 +228,7 @@ class DoAnalyzer
);
if ($context->collect_references) {
$context->unreferenced_vars = $inner_loop_context->unreferenced_vars;
$context->unreferenced_vars = $loop_scope->loop_context->unreferenced_vars;
}
if ($context->collect_exceptions) {

View File

@ -1424,6 +1424,21 @@ class UnusedVariableTest extends TestCase
echo implode(",", $p);
}'
],
'doWhileWithBreak' => [
'<?php
function foo(): void {
$f = false;
do {
if (rand(0,1)) {
$f = true;
break;
}
} while (rand(0,1));
if ($f) {}
}'
],
];
}