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:
parent
92e3d61663
commit
54d38e562f
@ -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) {
|
||||
|
@ -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) {}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user