This commit is contained in:
Tomas Votruba 2018-08-14 13:43:32 +02:00
parent 2ed6644e62
commit 44e5cf4adf
14 changed files with 33 additions and 34 deletions

View File

@ -2,8 +2,7 @@
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\PropertyTypeResolver\Source;
class ClassThatExtendsHtml extends
Html
class ClassThatExtendsHtml extends Html
{
}

View File

@ -8,7 +8,7 @@ use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use Rector\Node\MethodCallNodeFactory;
use Rector\NodeAnalyzer\MethodCallAnalyzer;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -63,7 +63,7 @@ CODE_SAMPLE
public function isCandidate(Node $node): bool
{
// skip just added calls
if ($node->getAttribute(RectorAttribute::ORIGINAL_NODE) === null) {
if ($node->getAttribute(Attribute::ORIGINAL_NODE) === null) {
return false;
}
@ -71,7 +71,7 @@ CODE_SAMPLE
return false;
}
return $node->getAttribute(RectorAttribute::PREVIOUS_NODE) === null;
return $node->getAttribute(Attribute::PREVIOUS_NODE) === null;
}
/**

View File

@ -7,7 +7,7 @@ use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Scalar\String_;
use Rector\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -59,18 +59,18 @@ CODE_SAMPLE
return false;
}
$arrayItemParentNode = $node->getAttribute(RectorAttribute::PARENT_NODE);
$arrayItemParentNode = $node->getAttribute(Attribute::PARENT_NODE);
if (! $arrayItemParentNode instanceof ArrayItem) {
return false;
}
$arrayParentNode = $arrayItemParentNode->getAttribute(RectorAttribute::PARENT_NODE);
$arrayParentNode = $arrayItemParentNode->getAttribute(Attribute::PARENT_NODE);
/** @var MethodCall $argParentNode */
$argParentNode = $arrayParentNode->getAttribute(RectorAttribute::PARENT_NODE);
$argParentNode = $arrayParentNode->getAttribute(Attribute::PARENT_NODE);
/** @var MethodCall|Node $methodCallNode */
$methodCallNode = $argParentNode->getAttribute(RectorAttribute::PARENT_NODE);
$methodCallNode = $argParentNode->getAttribute(Attribute::PARENT_NODE);
if (! $methodCallNode instanceof MethodCall) {
return false;

View File

@ -12,7 +12,7 @@ use Rector\Builder\Class_\ClassPropertyCollector;
use Rector\Naming\PropertyNaming;
use Rector\Node\PropertyFetchNodeFactory;
use Rector\NodeAnalyzer\MethodCallAnalyzer;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
abstract class AbstractToConstructorInjectionRector extends AbstractRector
@ -73,7 +73,7 @@ abstract class AbstractToConstructorInjectionRector extends AbstractRector
$propertyName = $this->propertyNaming->fqnToVariableName($serviceType);
$this->classPropertyCollector->addPropertyForClass(
(string) $methodCallNode->getAttribute(RectorAttribute::CLASS_NAME),
(string) $methodCallNode->getAttribute(Attribute::CLASS_NAME),
[$serviceType],
$propertyName
);
@ -102,7 +102,7 @@ abstract class AbstractToConstructorInjectionRector extends AbstractRector
}
if ($argument->class instanceof Name) {
return $argument->class->getAttribute(RectorAttribute::RESOLVED_NAME)->toString();
return $argument->class->getAttribute(Attribute::RESOLVED_NAME)->toString();
}
return null;

View File

@ -6,7 +6,7 @@ use PhpParser\Node;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Scalar\String_;
use Rector\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -51,7 +51,7 @@ final class ConstraintUrlOptionRector extends AbstractRector
return false;
}
$prevNode = $node->getAttribute(RectorAttribute::PREVIOUS_NODE);
$prevNode = $node->getAttribute(Attribute::PREVIOUS_NODE);
if (! $prevNode instanceof String_) {
return false;

View File

@ -6,7 +6,7 @@ use PhpParser\ConstExprEvaluator;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Identifier;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
final class ConstExprEvaluatorFactory
{
@ -23,7 +23,7 @@ final class ConstExprEvaluatorFactory
private function resolveClassConstFetch(ClassConstFetch $classConstFetchNode): string
{
$class = $classConstFetchNode->class->getAttribute(RectorAttribute::RESOLVED_NAME)->toString();
$class = $classConstFetchNode->class->getAttribute(Attribute::RESOLVED_NAME)->toString();
/** @var Identifier $identifierNode */
$identifierNode = $classConstFetchNode->name;

View File

@ -5,7 +5,7 @@ namespace Rector\Rector\Annotation;
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockAnalyzer;
use Rector\Rector\AbstractPHPUnitRector;
@ -96,7 +96,7 @@ CODE_SAMPLE
}
/** @var Node $parentNode */
$parentNode = $node->getAttribute(RectorAttribute::PARENT_NODE);
$parentNode = $node->getAttribute(Attribute::PARENT_NODE);
$parentNodeTypes = $this->nodeTypeResolver->resolve($parentNode);
foreach ($this->classToAnnotationMap as $type => $annotationMap) {
@ -133,7 +133,7 @@ CODE_SAMPLE
}
/** @var Node|null $parentNode */
$parentNode = $node->getAttribute(RectorAttribute::PARENT_NODE);
$parentNode = $node->getAttribute(Attribute::PARENT_NODE);
if (! $parentNode) {
return true;
}

View File

@ -10,7 +10,7 @@ use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Configuration\Rector\ArgumentRemoverRecipe;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
use SomeClass;
@ -138,7 +138,7 @@ CODE_SAMPLE
$valueNode = $argOrParamNode->value;
if ($valueNode instanceof ClassConstFetch) {
$valueNodeAsString = $valueNode->class->getAttribute(RectorAttribute::RESOLVED_NAME)->toString()
$valueNodeAsString = $valueNode->class->getAttribute(Attribute::RESOLVED_NAME)->toString()
. '::'
. (string) $valueNode->name;

View File

@ -6,7 +6,7 @@ use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Use_;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -86,7 +86,7 @@ final class ClassReplacerRector extends AbstractRector
// @todo use NodeTypeResolver?
if ($node instanceof Name) {
// resolved name has priority, as it is FQN
$resolvedName = $node->getAttribute(RectorAttribute::RESOLVED_NAME);
$resolvedName = $node->getAttribute(Attribute::RESOLVED_NAME);
if ($resolvedName instanceof FullyQualified) {
return $resolvedName;
}

View File

@ -7,7 +7,7 @@ use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use Rector\Builder\StatementGlue;
use Rector\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -113,7 +113,7 @@ CODE_SAMPLE
private function getClassNodeParentClassName(Class_ $classNode): string
{
/** @var FullyQualified $fullyQualifiedName */
$fullyQualifiedName = $classNode->extends->getAttribute(RectorAttribute::RESOLVED_NAME);
$fullyQualifiedName = $classNode->extends->getAttribute(Attribute::RESOLVED_NAME);
return $fullyQualifiedName->toString();
}

View File

@ -7,7 +7,7 @@ use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Name\FullyQualified;
use Rector\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -84,7 +84,7 @@ final class RenameClassConstantsUseToStringsRector extends AbstractRector
private function getClassNameFromClassConstFetch(ClassConstFetch $classConstFetchNode): string
{
/** @var FullyQualified|null $fqnName */
$fqnName = $classConstFetchNode->class->getAttribute(RectorAttribute::RESOLVED_NAME);
$fqnName = $classConstFetchNode->class->getAttribute(Attribute::RESOLVED_NAME);
if ($fqnName === null && $classConstFetchNode->class instanceof Variable) {
return (string) $classConstFetchNode->class->name;

View File

@ -8,7 +8,7 @@ use PhpParser\Node\Name;
use PhpParser\Node\NullableType;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Property;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -67,7 +67,7 @@ final class ValueObjectRemoverRector extends AbstractValueObjectRemoverRector
}
if ($node instanceof Name) {
$parentNode = $node->getAttribute(RectorAttribute::PARENT_NODE);
$parentNode = $node->getAttribute(Attribute::PARENT_NODE);
if ($parentNode instanceof Param) {
return true;
}

View File

@ -10,7 +10,7 @@ use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
use Rector\Builder\StatementGlue;
use Rector\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
@ -100,7 +100,7 @@ final class PseudoNamespaceToNamespaceRector extends AbstractRector
$oldName = $this->resolveNameFromNode($nameOrIdentifierNode);
$newNameParts = explode('_', $oldName);
$parentNode = $nameOrIdentifierNode->getAttribute(RectorAttribute::PARENT_NODE);
$parentNode = $nameOrIdentifierNode->getAttribute(Attribute::PARENT_NODE);
$lastNewNamePart = $newNameParts[count($newNameParts) - 1];
if ($nameOrIdentifierNode instanceof Name) {

View File

@ -6,7 +6,7 @@ use PhpParser\BuilderFactory;
use PhpParser\ConstExprEvaluator;
use PhpParser\Node\Name;
use PHPUnit\Framework\TestCase;
use Rector\NodeTypeResolver\Node\Attribute as RectorAttribute;
use Rector\NodeTypeResolver\Node\Attribute;
use Rector\NodeValueResolver\ConstExprEvaluatorFactory;
final class ConstExprEvaluatorFactoryTest extends TestCase
@ -24,7 +24,7 @@ final class ConstExprEvaluatorFactoryTest extends TestCase
public function test(): void
{
$classConstFetchNode = (new BuilderFactory())->classConstFetch('SomeClass', 'SOME_CONSTANT');
$classConstFetchNode->class->setAttribute(RectorAttribute::RESOLVED_NAME, new Name('SomeClassResolveName'));
$classConstFetchNode->class->setAttribute(Attribute::RESOLVED_NAME, new Name('SomeClassResolveName'));
$this->assertSame(
'SomeClassResolveName::SOME_CONSTANT',