Skip to content

Commit

Permalink
[NodeManipulator] Improve IfManipulator::collectNestedIfsWithNonBreak…
Browse files Browse the repository at this point in the history
…ing() performance (#3720)
  • Loading branch information
samsonasik committed May 1, 2023
1 parent 0204a23 commit 3c7f2e8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/NodeManipulator/IfManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,14 @@ public function collectNestedIfsWithNonBreaking(Foreach_ $foreach): array
return [];
}

$betterNodeFinderFindInstanceOf = $this->betterNodeFinder->findInstanceOf($currentIf->stmts, Return_::class);
$return = $this->betterNodeFinder->findFirstInstanceOf($currentIf->stmts, Return_::class);

if ($betterNodeFinderFindInstanceOf !== []) {
if ($return instanceof Return_) {
return [];
}

/** @var Exit_[] $exits */
$exits = $this->betterNodeFinder->findInstanceOf($currentIf->stmts, Exit_::class);
if ($exits !== []) {
$exit = $this->betterNodeFinder->findFirstInstanceOf($currentIf->stmts, Exit_::class);
if ($exit instanceof Exit_) {
return [];
}

Expand Down

0 comments on commit 3c7f2e8

Please sign in to comment.