Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ public function processStmtNode(
$impurePoints = array_merge($impurePoints, $finallyResult->getImpurePoints());
$finallyScope = $finallyResult->getScope();
$finalScope = $finallyResult->isAlwaysTerminating() ? $finalScope : $finalScope->processFinallyScope($finallyScope, $originalFinallyScope);
if (count($finallyResult->getExitPoints()) > 0) {
if (count($finallyResult->getExitPoints()) > 0 && $finallyResult->isAlwaysTerminating()) {
$this->callNodeCallback($nodeCallback, new FinallyExitPointsNode(
$finallyResult->toPublic()->getExitPoints(),
$finallyExitPoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function testRule(): void
]);
}

public function testBug6670(): void
{
$this->analyse([__DIR__ . '/data/bug-6670.php'], []);
}

public function testBug5627(): void
{
$this->analyse([__DIR__ . '/data/bug-5627.php'], [
Expand Down
24 changes: 24 additions & 0 deletions tests/PHPStan/Rules/Exceptions/data/bug-6670.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types = 1);

namespace Bug6670;

class HelloWorld
{
public function sayHello(): string
{
try {
return 'string';
} finally {
try {
$this->clearCache();
} catch(\Exception $e) {
return 'same string';
}
}
}

private function clearCache(): void
{
// do...
}
}
Loading