Permalink
Browse files
Fix #2197 - prevent false positive from try in while
- Loading branch information
|
@@ -414,6 +414,20 @@ function ($fq_catch_class) use ($codebase) { |
|
|
$statements_analyzer->registerVariableUses($locations); |
|
|
} |
|
|
} |
|
|
|
|
|
$newly_unreferenced_vars = array_merge( |
|
|
$newly_unreferenced_vars, |
|
|
array_diff_key( |
|
|
$try_context->unreferenced_vars, |
|
|
$old_unreferenced_vars |
|
|
) |
|
|
); |
|
|
|
|
|
foreach ($newly_unreferenced_vars as $var_id => $locations) { |
|
|
if (!isset($context->unreferenced_vars[$var_id])) { |
|
|
$context->unreferenced_vars[$var_id] = $locations; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if ($stmt->finally) { |
|
|
|
@@ -1171,6 +1171,29 @@ function b(): void { |
|
|
echo $b; |
|
|
}' |
|
|
], |
|
|
'tryWithWhile' => [ |
|
|
'<?php |
|
|
function foo(): void { |
|
|
$done = false; |
|
|
|
|
|
while (!$done) { |
|
|
try { |
|
|
$done = true; |
|
|
} catch (\Exception $e) { |
|
|
} |
|
|
} |
|
|
}', |
|
|
], |
|
|
'tryWithWhileWithoutTry' => [ |
|
|
'<?php |
|
|
function foo(): void { |
|
|
$done = false; |
|
|
|
|
|
while (!$done) { |
|
|
$done = true; |
|
|
} |
|
|
}', |
|
|
], |
|
|
]; |
|
|
} |
|
|
|
|
|
0 comments on commit
62a3598