Skip to content

Commit

Permalink
[EarlyReturn] Clean up ChangeOrIfReturnToEarlyReturnRector skip check (
Browse files Browse the repository at this point in the history
…#800)

* [EarlyReturn] Clean up ChangeOrIfReturnToEarlyReturnRector skip check

* more cleaning up
  • Loading branch information
samsonasik committed Aug 31, 2021
1 parent 2e18cab commit 25d3555
Showing 1 changed file with 0 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,8 @@ public function refactor(Node $node): ?Node
return null;
}

$nextNode = $node->getAttribute(AttributeKey::NEXT_NODE);
if ($this->shouldSkip($nextNode)) {
return null;
}

/** @var Return_ $return */
$return = $node->stmts[0];

// avoid repetitive ifs combined with other rules
if ($nextNode instanceof Return_ && $this->nodeComparator->areNodesEqual($nextNode->expr, $return->expr)) {
return null;
}

$ifs = $this->createMultipleIfs($node->cond, $return, []);

foreach ($ifs as $key => $if) {
Expand All @@ -118,15 +107,6 @@ public function refactor(Node $node): ?Node
return $node;
}

private function shouldSkip(?Node $nextNode): bool
{
if ($nextNode === null) {
return false;
}

return $nextNode instanceof Return_ && $nextNode->expr === null;
}

/**
* @param If_[] $ifs
* @return If_[]
Expand Down

0 comments on commit 25d3555

Please sign in to comment.