diff --git a/src/NodeAnalyzer/MethodCallAnalyzer.php b/src/NodeAnalyzer/MethodCallAnalyzer.php index 86bce9334fb..8ba48046f80 100644 --- a/src/NodeAnalyzer/MethodCallAnalyzer.php +++ b/src/NodeAnalyzer/MethodCallAnalyzer.php @@ -4,10 +4,7 @@ namespace Rector\NodeAnalyzer; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; -//use PhpParser\Node\Expr\StaticCall; -use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; -use PhpParser\Node\Name; use Rector\BetterReflection\Reflector\SmartClassReflector; use Rector\Node\Attribute; use ReflectionMethod; @@ -57,42 +54,6 @@ final class MethodCallAnalyzer return (string) $node->name === $method; } -// /** -// * Checks "SomeClassOfSpecificType::specificMethodName()" -// */ -// public function isStaticMethodCallTypeAndMethod(Node $node, string $type, string $method): bool -// { -// if (! $this->isStaticMethodCallType($node, $type)) { -// return false; -// } -// -// /** @var StaticCall $node */ -// return (string) $node->name === $method; -// } - -// /** -// * Checks "SomeClassOfSpecificType::specificMethodName()" -// * -// * @param string[] $methodNames -// */ -// public function isStaticMethodCallTypeAndMethods(Node $node, string $type, array $methodNames): bool -// { -// if (! $this->isStaticMethodCallType($node, $type)) { -// return false; -// } -// -// /** @var StaticCall $node */ -// $currentMethodName = (string) $node->name; -// -// foreach ($methodNames as $methodName) { -// if ($currentMethodName === $methodName) { -// return true; -// } -// } -// -// return false; -// } - /** * Checks "$this->specificNameMethod()" */ @@ -157,28 +118,6 @@ final class MethodCallAnalyzer return ! in_array($nodeMethodName, $publicMethodNames, true); } -// /** -// * @param string[] $types -// */ -// public function matchStaticMethodCallTypes(Node $node, array $types): ?string -// { -// if (! $node instanceof StaticCall) { -// return null; -// } -// -// if (! $node->name instanceof Identifier) { -// return null; -// } -// -// if (! $node->class instanceof Name) { -// return null; -// } -// -// $nodeType = $node->class->toString(); -// -// return in_array($nodeType, $types, true) ? $nodeType : null; -// } - /** * @return string[] */ @@ -194,29 +133,6 @@ final class MethodCallAnalyzer return $this->publicMethodNamesForType[$type] = array_keys($publicMethods); } -// /** -// * Checks "SomeClassOfSpecificType::someMethod()" -// */ -// private function isStaticMethodCallType(Node $node, string $type): bool -// { -// if (! $node instanceof StaticCall) { -// return false; -// } -// -// $currentType = null; -// if ($node->class instanceof Name) { -// $currentType = $node->class->toString(); -// } elseif ($node->class instanceof Variable) { -// $currentType = $node->class->getAttribute(Attribute::CLASS_NAME); -// } -// -// if ($currentType !== $type) { -// return false; -// } -// -// return true; -// } - private function findVariableType(MethodCall $methodCallNode): string { $varNode = $methodCallNode->var; diff --git a/src/NodeAnalyzer/StaticMethodCallAnalyzer.php b/src/NodeAnalyzer/StaticMethodCallAnalyzer.php index ac7653bc9c3..6b823ab8e5d 100644 --- a/src/NodeAnalyzer/StaticMethodCallAnalyzer.php +++ b/src/NodeAnalyzer/StaticMethodCallAnalyzer.php @@ -11,18 +11,6 @@ use Rector\Node\Attribute; final class StaticMethodCallAnalyzer { - /** - * Checks "SpecificType::anyMethod()" - */ - private function isStaticMethodCallType(Node $node, string $type): bool - { - if (! $node instanceof StaticCall) { - return false; - } - - return $this->resolveNodeType($node) === $type; - } - /** * Checks "SpecificType::specificMethod()" */ @@ -81,6 +69,18 @@ final class StaticMethodCallAnalyzer return in_array($nodeType, $types, true) ? $nodeType : null; } + /** + * Checks "SpecificType::anyMethod()" + */ + private function isStaticMethodCallType(Node $node, string $type): bool + { + if (! $node instanceof StaticCall) { + return false; + } + + return $this->resolveNodeType($node) === $type; + } + private function resolveNodeType(StaticCall $staticCallNode): ?string { if ($staticCallNode->class instanceof Name) { diff --git a/src/Rector/Dynamic/MethodNameReplacerRector.php b/src/Rector/Dynamic/MethodNameReplacerRector.php index 6f6b9027c7d..8b31be6420b 100644 --- a/src/Rector/Dynamic/MethodNameReplacerRector.php +++ b/src/Rector/Dynamic/MethodNameReplacerRector.php @@ -38,6 +38,7 @@ final class MethodNameReplacerRector extends AbstractRector * @var MethodCallAnalyzer */ private $methodCallAnalyzer; + /** * @var StaticMethodCallAnalyzer */