mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
cleanup and cs fixes
This commit is contained in:
parent
671860c95c
commit
d30d4b01e8
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -38,6 +38,7 @@ final class MethodNameReplacerRector extends AbstractRector
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
private $methodCallAnalyzer;
|
||||
|
||||
/**
|
||||
* @var StaticMethodCallAnalyzer
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user