diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index d5f62a9b8a7..d0f9ae4cb74 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -3879,6 +3879,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto $throwPoints = array_merge($throwPoints, $result->getThrowPoints()); $impurePoints = array_merge($impurePoints, $result->getImpurePoints()); $isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating(); + $throwPoints[] = InternalThrowPoint::createImplicit($scope, $expr); } else { $this->callNodeCallback($nodeCallback, $expr->name, $scope, $storage); } diff --git a/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php b/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php index 8f1dc90722e..ba108b19c02 100644 --- a/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php +++ b/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php @@ -681,4 +681,9 @@ public function testBug9146NonStrict(): void ]); } + public function testBug13569(): void + { + $this->analyse([__DIR__ . '/data/bug-13569.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Exceptions/data/bug-13569.php b/tests/PHPStan/Rules/Exceptions/data/bug-13569.php new file mode 100644 index 00000000000..8913a75964a --- /dev/null +++ b/tests/PHPStan/Rules/Exceptions/data/bug-13569.php @@ -0,0 +1,19 @@ += 8.1 + +declare(strict_types = 1); + +namespace Bug13569; + +enum ReactionType: string +{ + case EMOJI_HEART = '❤️'; + + public static function tryFromName(string $name): ?self + { + try { + return ReactionType::{$name}; + } catch (\Error) { + return null; + } + } +}