From 5fb31cd1ad17c9a8c02c0b7eb3fe9bd6fc346b3b Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 8 Nov 2019 14:45:50 +0100 Subject: [PATCH] fix name resolving on variable --- .../ThisCallOnStaticMethodToStaticCallRector.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php b/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php index e46302a28f57..d11f82dbe6d3 100644 --- a/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php +++ b/packages/Php70/src/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php @@ -6,6 +6,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\Variable; use Rector\NodeContainer\ParsedNodesByType; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Rector\AbstractRector; @@ -76,6 +77,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + if (! $node->var instanceof Variable) { + return null; + } + if (! $this->isName($node->var, 'this')) { return null; } @@ -85,7 +90,7 @@ public function refactor(Node $node): ?Node return null; } - $methodName = $this->getName($node); + $methodName = $this->getName($node->name); if ($methodName === null) { return null; } @@ -95,11 +100,6 @@ public function refactor(Node $node): ?Node return null; } - $methodName = $this->getName($node); - if ($methodName === null) { - return null; - } - return $this->createStaticCall('self', $methodName, $node->args); } }