diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 36ef08ccae1..28dd4c658bc 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '5b054eaa33bcd3cede29c544603cd31dd2959631'; + public const PACKAGE_VERSION = '0d86656f904c940d8573f4966e753ffb76e010c2'; /** * @api * @var string */ - public const RELEASE_DATE = '2025-02-19 11:12:02'; + public const RELEASE_DATE = '2025-02-19 17:57:56'; /** * @var int */ diff --git a/src/NodeManipulator/IfManipulator.php b/src/NodeManipulator/IfManipulator.php index 4e8eee08bc4..e6bf571f7cc 100644 --- a/src/NodeManipulator/IfManipulator.php +++ b/src/NodeManipulator/IfManipulator.php @@ -135,12 +135,7 @@ final class IfManipulator if (!$this->isIfWithoutElseAndElseIfs($currentIf)) { return []; } - $return = $this->betterNodeFinder->findFirstInstanceOf($currentIf->stmts, Return_::class); - if ($return instanceof Return_) { - return []; - } - $exit = $this->betterNodeFinder->findFirstInstanceOf($currentIf->stmts, Exit_::class); - if ($exit instanceof Exit_) { + if ($this->betterNodeFinder->hasInstancesOf($currentIf->stmts, [Return_::class, Exit_::class])) { return []; } // last if is with the expression diff --git a/src/PhpParser/Node/BetterNodeFinder.php b/src/PhpParser/Node/BetterNodeFinder.php index abe0e3bb569..83a87c5f8fa 100644 --- a/src/PhpParser/Node/BetterNodeFinder.php +++ b/src/PhpParser/Node/BetterNodeFinder.php @@ -117,14 +117,14 @@ final class BetterNodeFinder public function hasInstancesOf($nodes, array $types) : bool { Assert::allIsAOf($types, Node::class); - foreach ($types as $type) { - $foundNode = $this->nodeFinder->findFirstInstanceOf($nodes, $type); - if (!$foundNode instanceof Node) { - continue; + return (bool) $this->nodeFinder->findFirst($nodes, static function (Node $node) use($types) : bool { + foreach ($types as $type) { + if ($node instanceof $type) { + return \true; + } } - return \true; - } - return \false; + return \false; + }); } /** * @param Node|Node[] $nodes