cleanup and cs fixes

This commit is contained in:
TomasVotruba 2017-10-20 18:25:47 +02:00
parent 671860c95c
commit d30d4b01e8
3 changed files with 13 additions and 96 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -38,6 +38,7 @@ final class MethodNameReplacerRector extends AbstractRector
* @var MethodCallAnalyzer
*/
private $methodCallAnalyzer;
/**
* @var StaticMethodCallAnalyzer
*/