Skip to content

Commit 7a7601e

Browse files
committed
Remove from exit points catched exceptions
1 parent d9f98dc commit 7a7601e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,13 @@ private function processStmtNode(
16381638
} else {
16391639
$catchScope = $catchScope->mergeWith($matchingThrowPoint->getScope());
16401640
}
1641+
1642+
foreach ($finallyExitPoints as $key => $finallyExitPoint) {
1643+
if ($finallyExitPoint->getStatement()->expr === $matchingThrowPoint->getNode()) {
1644+
unset($finallyExitPoints[$key]);
1645+
break;
1646+
}
1647+
}
16411648
}
16421649

16431650
$variableName = null;

tests/PHPStan/Rules/Exceptions/data/bug-11906.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function func(): void {
88
try {
99
throw new LogicException('test');
1010
} catch (LogicException) {
11-
// This catch-block should cause line 7 to not be treated as an exit point
11+
// This catch-block should cause line 9 to not be treated as an exit point
1212
} finally {
1313
if (getenv('FOO')) {
1414
return;

0 commit comments

Comments
 (0)