mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Mark variables in throw arguments as used (#5166)
Fixes vimeo/psalm#5164
This commit is contained in:
parent
d740c1679c
commit
b72c5a0fa2
@ -425,7 +425,8 @@ class VariableFetchAnalyzer
|
||||
&& ($context->inside_call
|
||||
|| $context->inside_conditional
|
||||
|| $context->inside_use
|
||||
|| $context->inside_isset)
|
||||
|| $context->inside_isset
|
||||
|| $context->inside_throw)
|
||||
) {
|
||||
if (!$stmt_type->parent_nodes) {
|
||||
$assignment_node = DataFlowNode::getForAssignment(
|
||||
|
@ -2300,6 +2300,23 @@ class UnusedVariableTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'usedThrow' => [
|
||||
'<?php
|
||||
function f(Exception $e): void {
|
||||
throw $e;
|
||||
}
|
||||
',
|
||||
],
|
||||
'usedThrowInReturnedCallable' => [
|
||||
'<?php
|
||||
function createFailingFunction(RuntimeException $exception): Closure
|
||||
{
|
||||
return static function () use ($exception): void {
|
||||
throw $exception;
|
||||
};
|
||||
}
|
||||
',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user