Skip to content

Commit

Permalink
Remove array function from RemoveEmptyMethodCallRector as too narrow (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 22, 2023
1 parent 112e490 commit 88f17e9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 69 deletions.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions rules/DeadCode/Rector/MethodCall/RemoveEmptyMethodCallRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassLike;
Expand Down Expand Up @@ -115,10 +113,6 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
return $this->nodeFactory->createFalse();
}

if ($parentNode instanceof ArrowFunction && $this->nodeComparator->areNodesEqual($parentNode->expr, $node)) {
return $this->processArrowFunction($parentNode, $node);
}

if (! $parentNode instanceof Expression) {
return null;
}
Expand Down Expand Up @@ -191,15 +185,4 @@ private function shouldSkipClassMethod(

return ! $classMethod->isPrivate();
}

private function processArrowFunction(ArrowFunction $arrowFunction, MethodCall $methodCall): MethodCall | ConstFetch
{
$parentParentNode = $arrowFunction->getAttribute(AttributeKey::PARENT_NODE);
if ($parentParentNode instanceof Expression) {
$this->removeNode($arrowFunction);
return $methodCall;
}

return $this->nodeFactory->createFalse();
}
}

0 comments on commit 88f17e9

Please sign in to comment.