mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Allow dead code detection to capture last do checks
This commit is contained in:
parent
6267fa7d1d
commit
5ed062257b
@ -158,14 +158,14 @@ class DoChecker
|
||||
$do_context->referenced_var_ids
|
||||
);
|
||||
|
||||
ExpressionChecker::analyze($statements_checker, $stmt->cond, $inner_loop_context);
|
||||
|
||||
if ($context->collect_references) {
|
||||
$context->unreferenced_vars = $do_context->unreferenced_vars;
|
||||
$context->unreferenced_vars = $inner_loop_context->unreferenced_vars;
|
||||
}
|
||||
|
||||
if ($context->collect_exceptions) {
|
||||
$context->possibly_thrown_exceptions += $do_context->possibly_thrown_exceptions;
|
||||
$context->possibly_thrown_exceptions += $inner_loop_context->possibly_thrown_exceptions;
|
||||
}
|
||||
|
||||
ExpressionChecker::analyze($statements_checker, $stmt->cond, $inner_loop_context);
|
||||
}
|
||||
}
|
||||
|
@ -847,6 +847,14 @@ class UnusedVariableTest extends TestCase
|
||||
exit;
|
||||
}',
|
||||
],
|
||||
'usedVariableInDoWhile' => [
|
||||
'<?php
|
||||
$i = 5;
|
||||
do {
|
||||
echo "hello";
|
||||
} while (--$i > 0);
|
||||
echo $i;',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user