diff --git a/src/Rector/RemoveRayCallRector.php b/src/Rector/RemoveRayCallRector.php index 0b7d521..aeb013b 100644 --- a/src/Rector/RemoveRayCallRector.php +++ b/src/Rector/RemoveRayCallRector.php @@ -4,6 +4,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Stmt\Expression; use PhpParser\NodeTraverser; use Rector\Core\Contract\Rector\RectorInterface; @@ -34,14 +35,18 @@ public function refactor(Node $node): ?int { $expr = $node->expr; - if (! $expr instanceof FuncCall) { + if (! $expr instanceof FuncCall && !$expr instanceof MethodCall) { return null; } - if (! $this->isName($expr->name, 'ray')) { - return null; + if ($this->isName($expr->name, 'ray')) { + return NodeTraverser::REMOVE_NODE; + } + + if ($expr->var->name->parts && in_array('ray', $expr->var->name->parts)) { + return NodeTraverser::REMOVE_NODE; } - return NodeTraverser::REMOVE_NODE; + return null; } }