mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix more try/catch stuff
This commit is contained in:
parent
51557c44ea
commit
b1aae0d1a5
@ -372,12 +372,6 @@ class TryAnalyzer
|
||||
);
|
||||
|
||||
if ($context->collect_references && $catch_actions[$i] !== [ScopeAnalyzer::ACTION_END]) {
|
||||
foreach ($context->unreferenced_vars as $var_id => $_) {
|
||||
if (!isset($catch_context->unreferenced_vars[$var_id])) {
|
||||
unset($context->unreferenced_vars[$var_id]);
|
||||
}
|
||||
}
|
||||
|
||||
$newly_unreferenced_vars = array_merge(
|
||||
$newly_unreferenced_vars,
|
||||
array_diff_key(
|
||||
|
@ -1223,7 +1223,7 @@ class FunctionTemplateTest extends TestCase
|
||||
return $callback();
|
||||
}
|
||||
|
||||
makeResultSet([A::class, "returnsObjectOrNull"]);',
|
||||
makeResultSet([B::class, "returnsObjectOrNull"]);',
|
||||
'error_message' => 'InvalidArgument',
|
||||
],
|
||||
'templateInvokeArg' => [
|
||||
|
@ -1232,6 +1232,25 @@ class UnusedVariableTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'usedVarInCatchAndAfter' => [
|
||||
'<?php
|
||||
function foo() : void {
|
||||
if (rand(0, 1)) {
|
||||
throw new \Exception("bad");
|
||||
}
|
||||
}
|
||||
|
||||
$a = null;
|
||||
|
||||
try {
|
||||
foo();
|
||||
$a = "hello";
|
||||
} catch (\Exception $e) {
|
||||
echo $a;
|
||||
}
|
||||
|
||||
echo $a;'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user