Skip to content

Commit

Permalink
recursion is not needed, as Rector now works till there is something …
Browse files Browse the repository at this point in the history
…to change
  • Loading branch information
TomasVotruba committed Aug 2, 2021
1 parent 5145487 commit 8c4c7d0
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions rules/DeadCode/Rector/Plus/RemoveDeadZeroAndOneOperationRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,15 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$changedNode = null;
$previousNode = $node;
// $changedNode = null;
// $previousNode = $node;

if ($node instanceof AssignOp) {
$changedNode = $this->processAssignOp($node);
return $this->processAssignOp($node);
}

// -, +
if ($node instanceof BinaryOp) {
$changedNode = $this->processBinaryOp($node);
}

// recurse nested combinations
while ($changedNode !== null && ! $this->nodeComparator->areNodesEqual($previousNode, $changedNode)) {
$previousNode = $changedNode;

// nothing more to change, return last node
if (! $changedNode instanceof Node) {
return $previousNode;
}
}

return $changedNode;
return $this->processBinaryOp($node);
}

private function processAssignOp(Node $node): ?Expr
Expand Down

0 comments on commit 8c4c7d0

Please sign in to comment.