diff --git a/.github/workflows/test_with_doctrine.yaml b/.github/workflows/test_with_doctrine.yaml index 134107d6509..b512584a173 100644 --- a/.github/workflows/test_with_doctrine.yaml +++ b/.github/workflows/test_with_doctrine.yaml @@ -32,4 +32,4 @@ jobs: # do not intall doctrine/orm phpstan, it conflicts with Retor's one composer install -d orm --no-dev - - run: bin/rector process orm/lib --config ci/config/rector-doctrine.yaml --autoload-file orm/vendor/autoload.php + - run: bin/rector process orm/lib --config ci/config/rector-doctrine.yaml --autoload-file orm/vendor/autoload.php --debug diff --git a/packages/node-collector/src/NodeCollector/ParsedFunctionLikeNodeCollector.php b/packages/node-collector/src/NodeCollector/ParsedFunctionLikeNodeCollector.php index 1ffa57678c4..9438eceb3e2 100644 --- a/packages/node-collector/src/NodeCollector/ParsedFunctionLikeNodeCollector.php +++ b/packages/node-collector/src/NodeCollector/ParsedFunctionLikeNodeCollector.php @@ -205,7 +205,7 @@ final class ParsedFunctionLikeNodeCollector // one node can be of multiple-class types $classType = $this->resolveClassType($node); - $methodName = $this->nodeNameResolver->getName($node); + $methodName = $this->nodeNameResolver->getName($node->name); if ($classType instanceof MixedType) { // anonymous return; } diff --git a/packages/node-name-resolver/src/NodeNameResolver.php b/packages/node-name-resolver/src/NodeNameResolver.php index e45da0fc412..a8b4abf9cb2 100644 --- a/packages/node-name-resolver/src/NodeNameResolver.php +++ b/packages/node-name-resolver/src/NodeNameResolver.php @@ -8,9 +8,11 @@ use Nette\Utils\Strings; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Interface_; use PhpParser\Node\Stmt\Trait_; +use Rector\Core\Exception\ShouldNotHappenException; use Rector\NodeNameResolver\Contract\NodeNameResolverInterface; use Rector\NodeNameResolver\Regex\RegexPatternDetector; @@ -85,6 +87,14 @@ final class NodeNameResolver public function getName(Node $node): ?string { + if ($node instanceof MethodCall || $node instanceof StaticCall) { + if ($node->name instanceof MethodCall || $node->name instanceof StaticCall) { + return null; + } + + throw new ShouldNotHappenException(sprintf('Pick more specific node than "%s"', get_class($node))); + } + foreach ($this->nodeNameResolvers as $nodeNameResolver) { if (! is_a($node, $nodeNameResolver->getNode(), true)) { continue; diff --git a/rules/cakephp/src/Rector/MethodCall/ModalToGetSetRector.php b/rules/cakephp/src/Rector/MethodCall/ModalToGetSetRector.php index 6e4da9ddc7f..21acb7d105f 100644 --- a/rules/cakephp/src/Rector/MethodCall/ModalToGetSetRector.php +++ b/rules/cakephp/src/Rector/MethodCall/ModalToGetSetRector.php @@ -103,7 +103,7 @@ PHP continue; } - $currentMethodName = $this->getName($methodCall); + $currentMethodName = $this->getName($methodCall->name); if ($currentMethodName === null) { continue; } diff --git a/rules/cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php b/rules/cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php index 88a6a8032a2..7cdf38666c9 100644 --- a/rules/cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php +++ b/rules/cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php @@ -106,7 +106,7 @@ PHP continue; } - $currentMethodName = $this->getName($methodCall); + $currentMethodName = $this->getName($methodCall->name); if ($currentMethodName === null) { continue; } diff --git a/rules/code-quality/src/Rector/For_/ForRepeatedCountToOwnVariableRector.php b/rules/code-quality/src/Rector/For_/ForRepeatedCountToOwnVariableRector.php index 590002f7eac..a92f5ac574f 100644 --- a/rules/code-quality/src/Rector/For_/ForRepeatedCountToOwnVariableRector.php +++ b/rules/code-quality/src/Rector/For_/ForRepeatedCountToOwnVariableRector.php @@ -7,6 +7,8 @@ namespace Rector\CodeQuality\Rector\For_; use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt\For_; use PHPStan\Analyser\Scope; @@ -89,7 +91,8 @@ PHP } $countInCond = $node; - $valueName = $this->getName($node->args[0]->value); + + $valueName = $this->resolveValueName($node); $countedValueName = $this->createCountedValueName($valueName, $for->getAttribute(AttributeKey::SCOPE)); return new Variable($countedValueName); @@ -111,4 +114,14 @@ PHP return parent::createCountedValueName($countedValueName, $scope); } + + private function resolveValueName(FuncCall $funcCall): ?string + { + $argumentValue = $funcCall->args[0]->value; + if ($argumentValue instanceof MethodCall || $argumentValue instanceof StaticCall) { + return $this->getName($argumentValue->name); + } + + return $this->getName($argumentValue); + } } diff --git a/rules/dead-code/src/Rector/ClassMethod/RemoveDelegatingParentCallRector.php b/rules/dead-code/src/Rector/ClassMethod/RemoveDelegatingParentCallRector.php index 81a664bfda9..d016de8f725 100644 --- a/rules/dead-code/src/Rector/ClassMethod/RemoveDelegatingParentCallRector.php +++ b/rules/dead-code/src/Rector/ClassMethod/RemoveDelegatingParentCallRector.php @@ -160,7 +160,7 @@ PHP return false; } - if (! $this->areNamesEqual($staticCall, $classMethod)) { + if (! $this->areNamesEqual($staticCall->name, $classMethod->name)) { return false; } @@ -222,7 +222,8 @@ PHP } /** @var string $methodName */ - $methodName = $this->getName($staticCall); + $methodName = $this->getName($staticCall->name); + $parentClassMethod = $this->functionLikeParsedNodesFinder->findMethod($methodName, $parentClassName); if ($parentClassMethod !== null && $parentClassMethod->isProtected() && $classMethod->isPublic()) { return true; diff --git a/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php b/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php index e50e837ce25..f6f14a4a499 100644 --- a/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php +++ b/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php @@ -133,7 +133,7 @@ PHP private function resolveDefaultValuesFromCall(Node $node): array { /** @var string|null $nodeName */ - $nodeName = $this->getName($node); + $nodeName = $this->getName($node->name); if ($nodeName === null) { return []; } diff --git a/rules/dead-code/src/Rector/Stmt/RemoveUnreachableStatementRector.php b/rules/dead-code/src/Rector/Stmt/RemoveUnreachableStatementRector.php index 4f261ce9b00..2383ad19569 100644 --- a/rules/dead-code/src/Rector/Stmt/RemoveUnreachableStatementRector.php +++ b/rules/dead-code/src/Rector/Stmt/RemoveUnreachableStatementRector.php @@ -6,6 +6,7 @@ namespace Rector\DeadCode\Rector\Stmt; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassMethod; @@ -134,6 +135,14 @@ PHP return false; } + if ($node->name instanceof MethodCall) { + return false; + } + + if ($node->name instanceof StaticCall) { + return false; + } + return $this->isName($node->name, 'markTestSkipped'); }); } diff --git a/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php b/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php index b9407e0713a..2bc2b2ee8b2 100644 --- a/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php +++ b/rules/doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php @@ -147,7 +147,7 @@ PHP return null; } - $name = $this->getName($node); + $name = $this->getName($node->name); if ($name === null) { return null; } diff --git a/rules/nette-tester-to-phpunit/src/AssertManipulator.php b/rules/nette-tester-to-phpunit/src/AssertManipulator.php index 405c48afa8a..76651513d0d 100644 --- a/rules/nette-tester-to-phpunit/src/AssertManipulator.php +++ b/rules/nette-tester-to-phpunit/src/AssertManipulator.php @@ -117,17 +117,17 @@ final class AssertManipulator */ public function processStaticCall(StaticCall $staticCall): Node { - if ($this->nodeNameResolver->isNames($staticCall, ['truthy', 'falsey'])) { + if ($this->nodeNameResolver->isNames($staticCall->name, ['truthy', 'falsey'])) { return $this->processTruthyOrFalseyCall($staticCall); } - if ($this->nodeNameResolver->isNames($staticCall, ['contains', 'notContains'])) { + if ($this->nodeNameResolver->isNames($staticCall->name, ['contains', 'notContains'])) { $this->processContainsCall($staticCall); - } elseif ($this->nodeNameResolver->isNames($staticCall, ['exception', 'throws'])) { + } elseif ($this->nodeNameResolver->isNames($staticCall->name, ['exception', 'throws'])) { $this->processExceptionCall($staticCall); - } elseif ($this->nodeNameResolver->isName($staticCall, 'type')) { + } elseif ($this->nodeNameResolver->isName($staticCall->name, 'type')) { $this->processTypeCall($staticCall); - } elseif ($this->nodeNameResolver->isName($staticCall, 'noError')) { + } elseif ($this->nodeNameResolver->isName($staticCall->name, 'noError')) { $this->processNoErrorCall($staticCall); } else { $this->renameAssertMethod($staticCall); @@ -153,11 +153,14 @@ final class AssertManipulator { if ($this->stringTypeAnalyzer->isStringOrUnionStringOnlyType($staticCall->args[1]->value)) { $name = $this->nodeNameResolver->isName( - $staticCall, + $staticCall->name, 'contains' ) ? 'assertStringContainsString' : 'assertStringNotContainsString'; } else { - $name = $this->nodeNameResolver->isName($staticCall, 'contains') ? 'assertContains' : 'assertNotContains'; + $name = $this->nodeNameResolver->isName( + $staticCall->name, + 'contains' + ) ? 'assertContains' : 'assertNotContains'; } $staticCall->name = new Identifier($name); @@ -240,7 +243,7 @@ final class AssertManipulator */ private function processTruthyOrFalseyCall(StaticCall $staticCall): Expr { - $method = $this->nodeNameResolver->isName($staticCall, 'truthy') ? 'assertTrue' : 'assertFalse'; + $method = $this->nodeNameResolver->isName($staticCall->name, 'truthy') ? 'assertTrue' : 'assertFalse'; if (! $this->sholdBeStaticCall($staticCall)) { $call = new MethodCall(new Variable('this'), $method); @@ -296,7 +299,7 @@ final class AssertManipulator private function renameAssertMethod(StaticCall $staticCall): void { foreach (self::ASSERT_METHODS_REMAP as $oldMethod => $newMethod) { - if (! $this->nodeNameResolver->isName($staticCall, $oldMethod)) { + if (! $this->nodeNameResolver->isName($staticCall->name, $oldMethod)) { continue; } diff --git a/rules/nette-to-symfony/src/Route/RouteInfoFactory.php b/rules/nette-to-symfony/src/Route/RouteInfoFactory.php index a5bf52dd5ae..7cd83783bff 100644 --- a/rules/nette-to-symfony/src/Route/RouteInfoFactory.php +++ b/rules/nette-to-symfony/src/Route/RouteInfoFactory.php @@ -58,12 +58,12 @@ final class RouteInfoFactory return null; } - if (! $this->nodeNameResolver->isNames($node, ['get', 'head', 'post', 'put', 'patch', 'delete'])) { + if (! $this->nodeNameResolver->isNames($node->name, ['get', 'head', 'post', 'put', 'patch', 'delete'])) { return null; } /** @var string $methodName */ - $methodName = $this->nodeNameResolver->getName($node); + $methodName = $this->nodeNameResolver->getName($node->name); $uppercasedMethodName = strtoupper($methodName); $methods = []; diff --git a/rules/php-70/src/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php b/rules/php-70/src/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php index 7c5e8d9e328..1ee9ee8d922 100644 --- a/rules/php-70/src/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php +++ b/rules/php-70/src/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php @@ -170,6 +170,8 @@ final class NonVariableToVariableOnFunctionCallRector extends AbstractRector { if ($expr instanceof New_ && $expr->class instanceof Name) { $name = $this->getShortName($expr->class); + } elseif ($expr instanceof MethodCall || $expr instanceof StaticCall) { + $name = $this->getName($expr->name); } else { $name = $this->getName($expr); } diff --git a/rules/php-70/src/Rector/FunctionLike/Php4ConstructorRector.php b/rules/php-70/src/Rector/FunctionLike/Php4ConstructorRector.php index 20fe285f11c..1ca03ba4b20 100644 --- a/rules/php-70/src/Rector/FunctionLike/Php4ConstructorRector.php +++ b/rules/php-70/src/Rector/FunctionLike/Php4ConstructorRector.php @@ -196,7 +196,7 @@ PHP } // it's not a parent PHP 4 constructor call - if (! $this->isName($node, $parentClassName)) { + if (! $this->isName($node->name, $parentClassName)) { return; } diff --git a/rules/php-70/src/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php b/rules/php-70/src/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php index d63a4dfa04a..eb13def17de 100644 --- a/rules/php-70/src/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php +++ b/rules/php-70/src/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php @@ -90,7 +90,7 @@ PHP */ public function refactor(Node $node): ?Node { - $methodName = $this->getName($node); + $methodName = $this->getName($node->name); $className = $this->resolveStaticCallClassName($node); if ($methodName === null || $className === null) { diff --git a/rules/php-74/src/Rector/StaticCall/ExportToReflectionFunctionRector.php b/rules/php-74/src/Rector/StaticCall/ExportToReflectionFunctionRector.php index f7954c59e5a..dce06516eb5 100644 --- a/rules/php-74/src/Rector/StaticCall/ExportToReflectionFunctionRector.php +++ b/rules/php-74/src/Rector/StaticCall/ExportToReflectionFunctionRector.php @@ -59,7 +59,7 @@ PHP return null; } - if (! $this->isName($node, 'export')) { + if (! $this->isName($node->name, 'export')) { return null; } diff --git a/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php b/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php index f5999fb8257..9c4c77f64a5 100644 --- a/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php +++ b/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php @@ -107,7 +107,7 @@ final class PhpSpecMocksToPHPUnitMocksRector extends AbstractPhpSpecToPHPUnitRec throw new ShouldNotHappenException(); } - $mockMethodName = $this->getName($methodCall->var); + $mockMethodName = $this->getName($methodCall->var->name); if ($mockMethodName === null) { throw new ShouldNotHappenException(); } diff --git a/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php b/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php index 50c96a57520..5feee1c5417 100644 --- a/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php +++ b/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php @@ -178,7 +178,7 @@ final class PhpSpecPromisesToPHPUnitAssertRector extends AbstractPhpSpecToPHPUni return new Clone_($this->testedObjectPropertyFetch); } - $methodName = $this->getName($node); + $methodName = $this->getName($node->name); if ($methodName === null) { return null; } diff --git a/rules/phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php b/rules/phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php index 9f1a5d8fbcc..80b8566031c 100644 --- a/rules/phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php +++ b/rules/phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php @@ -86,7 +86,9 @@ PHP return null; } - $node->name = new Identifier(self::OLD_METHODS_NAMES_TO_NEW_NAMES['string'][$this->getName($node)]); + $methodName = $this->getName($node->name); + + $node->name = new Identifier(self::OLD_METHODS_NAMES_TO_NEW_NAMES['string'][$methodName]); return $node; } diff --git a/rules/phpunit/src/Rector/SpecificMethod/AssertCompareToSpecificMethodRector.php b/rules/phpunit/src/Rector/SpecificMethod/AssertCompareToSpecificMethodRector.php index ecf1b08ccfa..fd437315807 100644 --- a/rules/phpunit/src/Rector/SpecificMethod/AssertCompareToSpecificMethodRector.php +++ b/rules/phpunit/src/Rector/SpecificMethod/AssertCompareToSpecificMethodRector.php @@ -109,7 +109,7 @@ final class AssertCompareToSpecificMethodRector extends AbstractPHPUnitRector private function renameMethod(Node $node, string $funcName): void { /** @var string $oldMethodName */ - $oldMethodName = $this->getName($node); + $oldMethodName = $this->getName($node->name); [$trueMethodName, $falseMethodName] = self::DEFAULT_OLD_TO_NEW_METHODS[$funcName]; diff --git a/rules/phpunit/src/Rector/SpecificMethod/AssertRegExpRector.php b/rules/phpunit/src/Rector/SpecificMethod/AssertRegExpRector.php index 29a5ae4e47e..fee161d6ea2 100644 --- a/rules/phpunit/src/Rector/SpecificMethod/AssertRegExpRector.php +++ b/rules/phpunit/src/Rector/SpecificMethod/AssertRegExpRector.php @@ -62,7 +62,7 @@ final class AssertRegExpRector extends AbstractPHPUnitRector return null; } - $oldMethodName = $this->getName($node); + $oldMethodName = $this->getName($node->name); if ($oldMethodName === null) { return null; } diff --git a/rules/renaming/src/Rector/MethodCall/RenameStaticMethodRector.php b/rules/renaming/src/Rector/MethodCall/RenameStaticMethodRector.php index 2a94ccdc254..185a2dd1d9f 100644 --- a/rules/renaming/src/Rector/MethodCall/RenameStaticMethodRector.php +++ b/rules/renaming/src/Rector/MethodCall/RenameStaticMethodRector.php @@ -75,7 +75,7 @@ final class RenameStaticMethodRector extends AbstractRector } foreach ($oldToNewMethods as $oldMethod => $newMethod) { - if (! $this->isName($node, $oldMethod)) { + if (! $this->isName($node->name, $oldMethod)) { continue; } diff --git a/rules/shopware/src/Rector/MethodCall/ReplaceEnlightResponseWithSymfonyResponseRector.php b/rules/shopware/src/Rector/MethodCall/ReplaceEnlightResponseWithSymfonyResponseRector.php index e73933ab621..46217ad944c 100644 --- a/rules/shopware/src/Rector/MethodCall/ReplaceEnlightResponseWithSymfonyResponseRector.php +++ b/rules/shopware/src/Rector/MethodCall/ReplaceEnlightResponseWithSymfonyResponseRector.php @@ -67,7 +67,8 @@ PHP return null; } - $name = $this->getName($node); + $name = $this->getName($node->name); + switch ($name) { case 'setHeader': return $this->modifySetHeader($node); diff --git a/rules/symfony/src/Rector/Class_/MakeCommandLazyRector.php b/rules/symfony/src/Rector/Class_/MakeCommandLazyRector.php index f5d1fdd8699..b0984925129 100644 --- a/rules/symfony/src/Rector/Class_/MakeCommandLazyRector.php +++ b/rules/symfony/src/Rector/Class_/MakeCommandLazyRector.php @@ -105,7 +105,7 @@ PHP return null; } - if (! $this->isName($expr, '__construct')) { + if (! $this->isName($expr->name, '__construct')) { return null; } diff --git a/rules/symfony/src/Rector/Yaml/ParseFileRector.php b/rules/symfony/src/Rector/Yaml/ParseFileRector.php index 02e5c5905f1..a462e953070 100644 --- a/rules/symfony/src/Rector/Yaml/ParseFileRector.php +++ b/rules/symfony/src/Rector/Yaml/ParseFileRector.php @@ -42,7 +42,7 @@ final class ParseFileRector extends AbstractRector */ public function refactor(Node $node): ?Node { - if (! $this->isName($node, 'parse')) { + if (! $this->isName($node->name, 'parse')) { return null; } diff --git a/src/Php/Regex/RegexPatternArgumentManipulator.php b/src/Php/Regex/RegexPatternArgumentManipulator.php index 4b64ed78d16..1b910338801 100644 --- a/src/Php/Regex/RegexPatternArgumentManipulator.php +++ b/src/Php/Regex/RegexPatternArgumentManipulator.php @@ -133,7 +133,7 @@ final class RegexPatternArgumentManipulator } foreach ($methodNamesToArgumentPosition as $methodName => $argumentPosition) { - if (! $this->nodeNameResolver->isName($staticCall, $methodName)) { + if (! $this->nodeNameResolver->isName($staticCall->name, $methodName)) { continue; } diff --git a/src/PhpParser/Node/Manipulator/ChainMethodCallManipulator.php b/src/PhpParser/Node/Manipulator/ChainMethodCallManipulator.php index f19470c4176..4a9631ff1d8 100644 --- a/src/PhpParser/Node/Manipulator/ChainMethodCallManipulator.php +++ b/src/PhpParser/Node/Manipulator/ChainMethodCallManipulator.php @@ -48,7 +48,7 @@ final class ChainMethodCallManipulator $methods = array_reverse($methods); foreach ($methods as $method) { - $activeMethodName = $this->nodeNameResolver->getName($node); + $activeMethodName = $this->nodeNameResolver->getName($node->name); if ($activeMethodName !== $method) { return false; } diff --git a/src/PhpParser/Node/Manipulator/IdentifierManipulator.php b/src/PhpParser/Node/Manipulator/IdentifierManipulator.php index 350a80655b6..b2a55719eef 100644 --- a/src/PhpParser/Node/Manipulator/IdentifierManipulator.php +++ b/src/PhpParser/Node/Manipulator/IdentifierManipulator.php @@ -48,7 +48,7 @@ final class IdentifierManipulator { $this->ensureNodeHasIdentifier($node); - $oldNodeMethodName = $this->nodeNameResolver->getName($node); + $oldNodeMethodName = $this->resolveOldMethodName($node); if ($oldNodeMethodName === null) { return; } @@ -85,4 +85,14 @@ final class IdentifierManipulator implode('", "', self::NODE_CLASSES_WITH_IDENTIFIER) )); } + + private function resolveOldMethodName(Node $node) + { + if ($node instanceof StaticCall || $node instanceof MethodCall) { + $oldNodeMethodName = $this->nodeNameResolver->getName($node->name); + } else { + $oldNodeMethodName = $this->nodeNameResolver->getName($node); + } + return $oldNodeMethodName; + } } diff --git a/src/PhpParser/Node/Manipulator/MethodCallManipulator.php b/src/PhpParser/Node/Manipulator/MethodCallManipulator.php index 4b3693e44da..24b9f09da6e 100644 --- a/src/PhpParser/Node/Manipulator/MethodCallManipulator.php +++ b/src/PhpParser/Node/Manipulator/MethodCallManipulator.php @@ -51,7 +51,7 @@ final class MethodCallManipulator $methodCallNamesOnVariable = []; foreach ($methodCallsOnVariable as $methodCallOnVariable) { - $methodName = $this->nodeNameResolver->getName($methodCallOnVariable); + $methodName = $this->nodeNameResolver->getName($methodCallOnVariable->name); if ($methodName === null) { continue; } diff --git a/src/Rector/Argument/ArgumentRemoverRector.php b/src/Rector/Argument/ArgumentRemoverRector.php index eb0e5b2ae82..06c237c831c 100644 --- a/src/Rector/Argument/ArgumentRemoverRector.php +++ b/src/Rector/Argument/ArgumentRemoverRector.php @@ -80,7 +80,7 @@ PHP } foreach ($positionByMethodName as $methodName => $positions) { - if (! $this->isName($node, $methodName)) { + if (! $this->isName($node->name, $methodName)) { continue; } diff --git a/src/Rector/ClassMethod/AddMethodParentCallRector.php b/src/Rector/ClassMethod/AddMethodParentCallRector.php index 97ac63af329..acea7a77339 100644 --- a/src/Rector/ClassMethod/AddMethodParentCallRector.php +++ b/src/Rector/ClassMethod/AddMethodParentCallRector.php @@ -146,7 +146,7 @@ PHP return false; } - return $this->isName($node, $method); + return $this->isName($node->name, $method); }); } } diff --git a/src/Rector/StaticCall/StaticCallToFunctionRector.php b/src/Rector/StaticCall/StaticCallToFunctionRector.php index c7de97cb11e..1db2c369f62 100644 --- a/src/Rector/StaticCall/StaticCallToFunctionRector.php +++ b/src/Rector/StaticCall/StaticCallToFunctionRector.php @@ -66,7 +66,7 @@ final class StaticCallToFunctionRector extends AbstractRector } foreach ($methodNamesToFunctions as $methodName => $function) { - if (! $this->isName($node, $methodName)) { + if (! $this->isName($node->name, $methodName)) { continue; }