From bbdbe4f884236f86f98066988fecbd8753ad8d9e Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 21 Sep 2026 09:26:01 +0200 Subject: [PATCH] Fix nette build --- src/Rule/Nette/RethrowExceptionRule.php | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Rule/Nette/RethrowExceptionRule.php b/src/Rule/Nette/RethrowExceptionRule.php index 88c7d9d..d00b668 100644 --- a/src/Rule/Nette/RethrowExceptionRule.php +++ b/src/Rule/Nette/RethrowExceptionRule.php @@ -45,17 +45,7 @@ public function getNodeType(): string public function processNode(Node $node, Scope $scope): array { - $hasGeneralCatch = false; - foreach ($node->catches as $catch) { - foreach ($catch->types as $type) { - $typeClass = (string) $type; - if ($typeClass === 'Exception' || $typeClass === Throwable::class) { - $hasGeneralCatch = true; - break 2; - } - } - } - if (!$hasGeneralCatch) { + if (!$this->hasGeneralCatch($node)) { return []; } @@ -92,6 +82,20 @@ public function processNode(Node $node, Scope $scope): array return $messages; } + private function hasGeneralCatch(TryCatch $node): bool + { + foreach ($node->catches as $catch) { + foreach ($catch->types as $type) { + $typeClass = (string) $type; + if ($typeClass === 'Exception' || $typeClass === Throwable::class) { + return true; + } + } + } + + return false; + } + /** * @param Node|Node[]|scalar $node * @return string[]