mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
[NoreRepository] merge ClassLikeParsedNodesFinder to NodeRepository (#4185)
Co-authored-by: rector-bot <tomas@getrector.org>
This commit is contained in:
parent
7cab529bf8
commit
f5f7ba76af
@ -10,7 +10,7 @@ use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
@ -21,11 +21,6 @@ final class PropertyUsageAnalyzer
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
|
||||
/**
|
||||
* @var ClassLikeParsedNodesFinder
|
||||
*/
|
||||
private $classLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @var BetterNodeFinder
|
||||
*/
|
||||
@ -36,16 +31,21 @@ final class PropertyUsageAnalyzer
|
||||
*/
|
||||
private $familyRelationsAnalyzer;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
BetterNodeFinder $betterNodeFinder,
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
FamilyRelationsAnalyzer $familyRelationsAnalyzer,
|
||||
NodeNameResolver $nodeNameResolver
|
||||
NodeNameResolver $nodeNameResolver,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->familyRelationsAnalyzer = $familyRelationsAnalyzer;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function isPropertyFetchedInChildClass(Property $property): bool
|
||||
@ -67,7 +67,7 @@ final class PropertyUsageAnalyzer
|
||||
|
||||
$childrenClassNames = $this->familyRelationsAnalyzer->getChildrenOfClass($className);
|
||||
foreach ($childrenClassNames as $childClassName) {
|
||||
$childClass = $this->classLikeParsedNodesFinder->findClass($childClassName);
|
||||
$childClass = $this->nodeRepository->findClass($childClassName);
|
||||
if ($childClass === null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Rector\NodeCollector\NodeCollector;
|
||||
|
||||
use Nette\Utils\Arrays;
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
@ -12,9 +13,13 @@ use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
@ -89,16 +94,23 @@ final class NodeRepository
|
||||
*/
|
||||
private $parsedClassConstFetchNodeCollector;
|
||||
|
||||
/**
|
||||
* @var ParsedNodeCollector
|
||||
*/
|
||||
private $parsedNodeCollector;
|
||||
|
||||
public function __construct(
|
||||
ArrayCallableMethodReferenceAnalyzer $arrayCallableMethodReferenceAnalyzer,
|
||||
ParsedPropertyFetchNodeCollector $parsedPropertyFetchNodeCollector,
|
||||
NodeNameResolver $nodeNameResolver,
|
||||
ParsedClassConstFetchNodeCollector $parsedClassConstFetchNodeCollector
|
||||
ParsedClassConstFetchNodeCollector $parsedClassConstFetchNodeCollector,
|
||||
ParsedNodeCollector $parsedNodeCollector
|
||||
) {
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->arrayCallableMethodReferenceAnalyzer = $arrayCallableMethodReferenceAnalyzer;
|
||||
$this->parsedPropertyFetchNodeCollector = $parsedPropertyFetchNodeCollector;
|
||||
$this->parsedClassConstFetchNodeCollector = $parsedClassConstFetchNodeCollector;
|
||||
$this->parsedNodeCollector = $parsedNodeCollector;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,6 +339,108 @@ final class NodeRepository
|
||||
return [];
|
||||
}
|
||||
|
||||
public function hasClassChildren(Class_ $desiredClass): bool
|
||||
{
|
||||
$desiredClassName = $desiredClass->getAttribute(AttributeKey::CLASS_NAME);
|
||||
if ($desiredClassName === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->parsedNodeCollector->getClasses() as $classNode) {
|
||||
$currentClassName = $classNode->getAttribute(AttributeKey::CLASS_NAME);
|
||||
if ($currentClassName === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $this->isChildOrEqualClassLike($desiredClassName, $currentClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class_[]
|
||||
*/
|
||||
public function findClassesBySuffix(string $suffix): array
|
||||
{
|
||||
$classNodes = [];
|
||||
|
||||
foreach ($this->parsedNodeCollector->getClasses() as $className => $classNode) {
|
||||
if (! Strings::endsWith($className, $suffix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classNodes[] = $classNode;
|
||||
}
|
||||
|
||||
return $classNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Trait_[]
|
||||
*/
|
||||
public function findUsedTraitsInClass(ClassLike $classLike): array
|
||||
{
|
||||
$traits = [];
|
||||
|
||||
foreach ($classLike->getTraitUses() as $traitUse) {
|
||||
foreach ($traitUse->traits as $trait) {
|
||||
$traitName = $this->nodeNameResolver->getName($trait);
|
||||
if ($traitName === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundTrait = $this->parsedNodeCollector->findTrait($traitName);
|
||||
if ($foundTrait !== null) {
|
||||
$traits[] = $foundTrait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class_[]|Interface_[]
|
||||
*/
|
||||
public function findClassesAndInterfacesByType(string $type): array
|
||||
{
|
||||
return array_merge($this->findChildrenOfClass($type), $this->findImplementersOfInterface($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class_[]
|
||||
*/
|
||||
public function findChildrenOfClass(string $class): array
|
||||
{
|
||||
$childrenClasses = [];
|
||||
|
||||
foreach ($this->parsedNodeCollector->getClasses() as $classNode) {
|
||||
$currentClassName = $classNode->getAttribute(AttributeKey::CLASS_NAME);
|
||||
if (! $this->isChildOrEqualClassLike($class, $currentClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$childrenClasses[] = $classNode;
|
||||
}
|
||||
|
||||
return $childrenClasses;
|
||||
}
|
||||
|
||||
public function findInterface(string $class): ?Interface_
|
||||
{
|
||||
return $this->parsedNodeCollector->findInterface($class);
|
||||
}
|
||||
|
||||
public function findClass(string $name): ?Class_
|
||||
{
|
||||
return $this->parsedNodeCollector->findClass($name);
|
||||
}
|
||||
|
||||
private function addMethod(ClassMethod $classMethod): void
|
||||
{
|
||||
$className = $classMethod->getAttribute(AttributeKey::CLASS_NAME);
|
||||
@ -373,6 +487,39 @@ final class NodeRepository
|
||||
return $this->callsByTypeAndMethod[$className][$methodName] ?? $this->arrayCallablesByTypeAndMethod[$className][$methodName] ?? [];
|
||||
}
|
||||
|
||||
private function isChildOrEqualClassLike(string $desiredClass, ?string $currentClassName): bool
|
||||
{
|
||||
if ($currentClassName === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! is_a($currentClassName, $desiredClass, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $currentClassName !== $desiredClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Interface_[]
|
||||
*/
|
||||
private function findImplementersOfInterface(string $interface): array
|
||||
{
|
||||
$implementerInterfaces = [];
|
||||
|
||||
foreach ($this->parsedNodeCollector->getInterfaces() as $interfaceNode) {
|
||||
$className = $interfaceNode->getAttribute(AttributeKey::CLASS_NAME);
|
||||
|
||||
if (! $this->isChildOrEqualClassLike($interface, $className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$implementerInterfaces[] = $interfaceNode;
|
||||
}
|
||||
|
||||
return $implementerInterfaces;
|
||||
}
|
||||
|
||||
private function resolveNodeClassTypes(Node $node): Type
|
||||
{
|
||||
if ($node instanceof MethodCall && $node->var instanceof Variable && $node->var->name === 'this') {
|
||||
|
@ -1,150 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\NodeCollector\NodeFinder;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use Rector\NodeCollector\NodeCollector\ParsedNodeCollector;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
final class ClassLikeParsedNodesFinder
|
||||
{
|
||||
/**
|
||||
* @var ParsedNodeCollector
|
||||
*/
|
||||
private $parsedNodeCollector;
|
||||
|
||||
/**
|
||||
* @var NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, ParsedNodeCollector $parsedNodeCollector)
|
||||
{
|
||||
$this->parsedNodeCollector = $parsedNodeCollector;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class_[]
|
||||
*/
|
||||
public function findChildrenOfClass(string $class): array
|
||||
{
|
||||
$childrenClasses = [];
|
||||
|
||||
foreach ($this->parsedNodeCollector->getClasses() as $classNode) {
|
||||
$currentClassName = $classNode->getAttribute(AttributeKey::CLASS_NAME);
|
||||
if (! $this->isChildOrEqualClassLike($class, $currentClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$childrenClasses[] = $classNode;
|
||||
}
|
||||
|
||||
return $childrenClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class_[]
|
||||
*/
|
||||
public function findClassesBySuffix(string $suffix): array
|
||||
{
|
||||
$classNodes = [];
|
||||
|
||||
foreach ($this->parsedNodeCollector->getClasses() as $className => $classNode) {
|
||||
if (! Strings::endsWith($className, $suffix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classNodes[] = $classNode;
|
||||
}
|
||||
|
||||
return $classNodes;
|
||||
}
|
||||
|
||||
public function hasClassChildren(string $class): bool
|
||||
{
|
||||
return $this->findChildrenOfClass($class) !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Trait_[]
|
||||
*/
|
||||
public function findUsedTraitsInClass(ClassLike $classLike): array
|
||||
{
|
||||
$traits = [];
|
||||
|
||||
foreach ($classLike->getTraitUses() as $traitUse) {
|
||||
foreach ($traitUse->traits as $trait) {
|
||||
$traitName = $this->nodeNameResolver->getName($trait);
|
||||
if ($traitName === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundTrait = $this->parsedNodeCollector->findTrait($traitName);
|
||||
if ($foundTrait !== null) {
|
||||
$traits[] = $foundTrait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class_[]|Interface_[]
|
||||
*/
|
||||
public function findClassesAndInterfacesByType(string $type): array
|
||||
{
|
||||
return array_merge($this->findChildrenOfClass($type), $this->findImplementersOfInterface($type));
|
||||
}
|
||||
|
||||
public function findInterface(string $class): ?Interface_
|
||||
{
|
||||
return $this->parsedNodeCollector->findInterface($class);
|
||||
}
|
||||
|
||||
public function findClass(string $name): ?Class_
|
||||
{
|
||||
return $this->parsedNodeCollector->findClass($name);
|
||||
}
|
||||
|
||||
private function isChildOrEqualClassLike(string $desiredClass, ?string $currentClassName): bool
|
||||
{
|
||||
if ($currentClassName === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! is_a($currentClassName, $desiredClass, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $currentClassName !== $desiredClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Interface_[]
|
||||
*/
|
||||
private function findImplementersOfInterface(string $interface): array
|
||||
{
|
||||
$implementerInterfaces = [];
|
||||
|
||||
foreach ($this->parsedNodeCollector->getInterfaces() as $interfaceNode) {
|
||||
$className = $interfaceNode->getAttribute(AttributeKey::CLASS_NAME);
|
||||
|
||||
if (! $this->isChildOrEqualClassLike($interface, $className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$implementerInterfaces[] = $interfaceNode;
|
||||
}
|
||||
|
||||
return $implementerInterfaces;
|
||||
}
|
||||
}
|
@ -436,3 +436,6 @@ parameters:
|
||||
|
||||
# the smallest descriptive method
|
||||
- '#Variable "\$inverseJoinColumnsOpeningAndClosingSpace" is too long with \d+ chars\. Narrow it under 40 chars#'
|
||||
|
||||
# complex - single repository for all nodes
|
||||
- '#Class cognitive complexity for "NodeRepository" is \d+, keep it under 50#'
|
||||
|
@ -26,6 +26,7 @@ use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\RectorDefinition\CodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
@ -37,6 +38,16 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
*/
|
||||
final class CallableThisArrayToAnonymousFunctionRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(NodeRepository $nodeRepository)
|
||||
{
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Convert [$this, "method"] to proper anonymous function', [
|
||||
@ -150,7 +161,7 @@ PHP
|
||||
$objectType = $this->popFirstObjectType($objectType);
|
||||
|
||||
if ($objectType instanceof ObjectType) {
|
||||
$class = $this->classLikeParsedNodesFinder->findClass($objectType->getClassName());
|
||||
$class = $this->nodeRepository->findClass($objectType->getClassName());
|
||||
|
||||
if ($class === null) {
|
||||
return null;
|
||||
|
@ -80,7 +80,7 @@ PHP
|
||||
}
|
||||
|
||||
// 0. constants declared in interfaces have to be public
|
||||
if ($this->classLikeParsedNodesFinder->findInterface($class) !== null) {
|
||||
if ($this->nodeRepository->findInterface($class) !== null) {
|
||||
$this->makePublic($node);
|
||||
return $node;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\DeadCode\NodeManipulator\MagicMethodDetector;
|
||||
use Rector\DeadCode\NodeManipulator\VariadicFunctionLikeDetector;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
@ -47,16 +48,23 @@ final class RemoveUnusedParameterRector extends AbstractRector implements ZeroCa
|
||||
*/
|
||||
private $variadicFunctionLikeDetector;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
ClassManipulator $classManipulator,
|
||||
ClassMethodManipulator $classMethodManipulator,
|
||||
MagicMethodDetector $magicMethodDetector,
|
||||
VariadicFunctionLikeDetector $variadicFunctionLikeDetector
|
||||
VariadicFunctionLikeDetector $variadicFunctionLikeDetector,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->classManipulator = $classManipulator;
|
||||
$this->classMethodManipulator = $classMethodManipulator;
|
||||
$this->magicMethodDetector = $magicMethodDetector;
|
||||
$this->variadicFunctionLikeDetector = $variadicFunctionLikeDetector;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
@ -114,7 +122,7 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
$childrenOfClass = $this->classLikeParsedNodesFinder->findChildrenOfClass($className);
|
||||
$childrenOfClass = $this->nodeRepository->findChildrenOfClass($className);
|
||||
$unusedParameters = $this->getUnusedParameters($node, $methodName, $childrenOfClass);
|
||||
if ($unusedParameters === []) {
|
||||
return null;
|
||||
|
@ -19,6 +19,7 @@ use Rector\Core\RectorDefinition\CodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\DeadCode\Doctrine\DoctrineEntityManipulator;
|
||||
use Rector\DeadCode\UnusedNodeResolver\ClassUnusedPrivateClassMethodResolver;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
@ -47,14 +48,21 @@ final class RemoveUnusedDoctrineEntityMethodAndPropertyRector extends AbstractRe
|
||||
*/
|
||||
private $doctrineEntityManipulator;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
ClassManipulator $classManipulator,
|
||||
ClassUnusedPrivateClassMethodResolver $classUnusedPrivateClassMethodResolver,
|
||||
DoctrineEntityManipulator $doctrineEntityManipulator
|
||||
DoctrineEntityManipulator $doctrineEntityManipulator,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->classUnusedPrivateClassMethodResolver = $classUnusedPrivateClassMethodResolver;
|
||||
$this->classManipulator = $classManipulator;
|
||||
$this->doctrineEntityManipulator = $doctrineEntityManipulator;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
@ -263,7 +271,7 @@ PHP
|
||||
}
|
||||
|
||||
// get the class property and remove "mappedBy/inversedBy" from annotation
|
||||
$relatedEntityClass = $this->classLikeParsedNodesFinder->findClass($targetEntity);
|
||||
$relatedEntityClass = $this->nodeRepository->findClass($targetEntity);
|
||||
if (! $relatedEntityClass instanceof Class_) {
|
||||
return null;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ use Rector\DoctrineCodeQuality\NodeAnalyzer\ColumnDatetimePropertyAnalyzer;
|
||||
use Rector\DoctrineCodeQuality\NodeFactory\ValueAssignFactory;
|
||||
use Rector\DoctrineCodeQuality\NodeManipulator\ColumnDatetimePropertyManipulator;
|
||||
use Rector\DoctrineCodeQuality\NodeManipulator\ConstructorManipulator;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @sponsor Thanks https://www.luzanky.cz/ for sponsoring this rule
|
||||
@ -47,13 +46,11 @@ final class MoveCurrentDateTimeDefaultInEntityToConstructorRector extends Abstra
|
||||
private $columnDatetimePropertyManipulator;
|
||||
|
||||
public function __construct(
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
ColumnDatetimePropertyAnalyzer $columnDatetimePropertyAnalyzer,
|
||||
ConstructorManipulator $constructorManipulator,
|
||||
ValueAssignFactory $valueAssignFactory,
|
||||
ColumnDatetimePropertyManipulator $columnDatetimePropertyManipulator
|
||||
) {
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->columnDatetimePropertyAnalyzer = $columnDatetimePropertyAnalyzer;
|
||||
$this->constructorManipulator = $constructorManipulator;
|
||||
$this->valueAssignFactory = $valueAssignFactory;
|
||||
|
@ -21,6 +21,7 @@ use Rector\Core\Util\StaticRectorStrings;
|
||||
use Rector\NetteToSymfony\Route\RouteInfoFactory;
|
||||
use Rector\NetteToSymfony\Routing\ExplicitRouteAnnotationDecorator;
|
||||
use Rector\NetteToSymfony\ValueObject\RouteInfo;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
|
||||
use ReflectionMethod;
|
||||
@ -48,14 +49,21 @@ final class RouterListToControllerAnnotationsRector extends AbstractRector
|
||||
*/
|
||||
private $explicitRouteAnnotationDecorator;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
ExplicitRouteAnnotationDecorator $explicitRouteAnnotationDecorator,
|
||||
NodeRepository $nodeRepository,
|
||||
ReturnTypeInferer $returnTypeInferer,
|
||||
RouteInfoFactory $routeInfoFactory
|
||||
) {
|
||||
$this->routeInfoFactory = $routeInfoFactory;
|
||||
$this->returnTypeInferer = $returnTypeInferer;
|
||||
$this->explicitRouteAnnotationDecorator = $explicitRouteAnnotationDecorator;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
@ -224,7 +232,7 @@ PHP
|
||||
|
||||
private function resolveControllerClassMethod(RouteInfo $routeInfo): ?ClassMethod
|
||||
{
|
||||
$classNode = $this->classLikeParsedNodesFinder->findClass($routeInfo->getClass());
|
||||
$classNode = $this->nodeRepository->findClass($routeInfo->getClass());
|
||||
if ($classNode === null) {
|
||||
return null;
|
||||
}
|
||||
@ -242,7 +250,7 @@ PHP
|
||||
|
||||
private function completeImplicitRoutes(): void
|
||||
{
|
||||
$presenterClasses = $this->classLikeParsedNodesFinder->findClassesBySuffix('Presenter');
|
||||
$presenterClasses = $this->nodeRepository->findClassesBySuffix('Presenter');
|
||||
|
||||
foreach ($presenterClasses as $presenterClass) {
|
||||
foreach ($presenterClass->getMethods() as $classMethod) {
|
||||
|
@ -108,7 +108,7 @@ PHP
|
||||
$node->setAttribute(self::HAS_NEW_ACCESS_LEVEL, true);
|
||||
|
||||
// 0. constants declared in interfaces have to be public
|
||||
if ($this->classLikeParsedNodesFinder->findInterface($class) !== null) {
|
||||
if ($this->nodeRepository->findInterface($class) !== null) {
|
||||
$this->makePublic($node);
|
||||
return $node;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\RectorDefinition\CodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\Core\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\PSR4\Collector\RenamedClassesCollector;
|
||||
use ReflectionClass;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
@ -36,14 +36,19 @@ final class RemoveUselessJustForSakeInterfaceRector extends AbstractRector
|
||||
*/
|
||||
private $renamedClassesCollector;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
RenamedClassesCollector $renamedClassesCollector,
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
NodeRepository $nodeRepository,
|
||||
string $interfacePattern = '#(.*?)#'
|
||||
) {
|
||||
$this->interfacePattern = $interfacePattern;
|
||||
$this->renamedClassesCollector = $renamedClassesCollector;
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +178,7 @@ CODE_SAMPLE
|
||||
private function removeInterfaceFile(string $interfaceName, string $classFileLocation): void
|
||||
{
|
||||
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
|
||||
$interface = $this->classLikeParsedNodesFinder->findInterface($interfaceName);
|
||||
$interface = $this->nodeRepository->findInterface($interfaceName);
|
||||
if ($interface instanceof Interface_) {
|
||||
$this->removeNode($interface);
|
||||
}
|
||||
|
@ -9,12 +9,23 @@ use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\RectorDefinition\CodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
|
||||
/**
|
||||
* @see \Rector\SOLID\Tests\Rector\Class_\FinalizeClassesWithoutChildrenRector\FinalizeClassesWithoutChildrenRectorTest
|
||||
*/
|
||||
final class FinalizeClassesWithoutChildrenRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(NodeRepository $nodeRepository)
|
||||
{
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Finalize every class that has no children', [
|
||||
@ -71,9 +82,7 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var string $class */
|
||||
$class = $this->getName($node);
|
||||
if ($this->classLikeParsedNodesFinder->hasClassChildren($class)) {
|
||||
if ($this->nodeRepository->hasClassChildren($node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,23 @@ use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\RectorDefinition\CodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
|
||||
/**
|
||||
* @see \Rector\SOLID\Tests\Rector\Class_\MakeUnusedClassesWithChildrenAbstractRector\MakeUnusedClassesWithChildrenAbstractRectorTest
|
||||
*/
|
||||
final class MakeUnusedClassesWithChildrenAbstractRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(NodeRepository $nodeRepository)
|
||||
{
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Classes that have no children nor are used, should have abstract', [
|
||||
@ -61,7 +72,7 @@ PHP
|
||||
}
|
||||
|
||||
// 1. is in static call?
|
||||
if ($this->functionLikeParsedNodesFinder->findMethodCallsOnClass($className) !== []) {
|
||||
if ($this->nodeRepository->findMethodCallsOnClass($className) !== []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -71,7 +82,7 @@ PHP
|
||||
}
|
||||
|
||||
// 3. does it have any children
|
||||
if ($this->classLikeParsedNodesFinder->findChildrenOfClass($className) === []) {
|
||||
if ($this->nodeRepository->findChildrenOfClass($className) === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\SOLID\NodeFactory\InjectMethodFactory;
|
||||
use Rector\SOLID\NodeRemover\ClassMethodNodeRemover;
|
||||
@ -72,18 +72,23 @@ final class MultiParentingToAbstractDependencyRector extends AbstractRector impl
|
||||
*/
|
||||
private $classInsertManipulator;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
ClassMethodNodeRemover $classMethodNodeRemover,
|
||||
InjectMethodFactory $injectMethodFactory,
|
||||
PhpDocInfoFactory $phpDocInfoFactory,
|
||||
ClassInsertManipulator $classInsertManipulator
|
||||
ClassInsertManipulator $classInsertManipulator,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->injectMethodFactory = $injectMethodFactory;
|
||||
$this->classMethodNodeRemover = $classMethodNodeRemover;
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->classInsertManipulator = $classInsertManipulator;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
@ -170,7 +175,7 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
$childrenClasses = $this->classLikeParsedNodesFinder->findChildrenOfClass($className);
|
||||
$childrenClasses = $this->nodeRepository->findChildrenOfClass($className);
|
||||
if (count($childrenClasses) < 2) {
|
||||
return null;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Core\RectorDefinition\CodeSample;
|
||||
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\Symfony\NodeFactory\BuilderFormNodeFactory;
|
||||
use Rector\Symfony\NodeFactory\ConfigureOptionsNodeFactory;
|
||||
use ReflectionClass;
|
||||
@ -52,12 +53,19 @@ final class FormTypeInstanceToClassConstRector extends AbstractFormAddRector
|
||||
*/
|
||||
private $configureOptionsNodeFactory;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
BuilderFormNodeFactory $builderFormNodeFactory,
|
||||
ConfigureOptionsNodeFactory $configureOptionsNodeFactory
|
||||
ConfigureOptionsNodeFactory $configureOptionsNodeFactory,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->builderFormNodeFactory = $builderFormNodeFactory;
|
||||
$this->configureOptionsNodeFactory = $configureOptionsNodeFactory;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
@ -215,7 +223,7 @@ PHP
|
||||
$methodCall->args[$optionsPosition] = new Arg($array);
|
||||
}
|
||||
|
||||
$formTypeClass = $this->classLikeParsedNodesFinder->findClass($className);
|
||||
$formTypeClass = $this->nodeRepository->findClass($className);
|
||||
if ($formTypeClass === null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\StaticType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\ChangesReporting\Collector\RectorChangeCollector;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStan\Type\SelfObjectType;
|
||||
@ -27,11 +27,6 @@ use Rector\TypeDeclaration\ValueObject\NewType;
|
||||
|
||||
final class ChildParamPopulator
|
||||
{
|
||||
/**
|
||||
* @var ClassLikeParsedNodesFinder
|
||||
*/
|
||||
private $classLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
@ -47,16 +42,21 @@ final class ChildParamPopulator
|
||||
*/
|
||||
private $rectorChangeCollector;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
NodeNameResolver $nodeNameResolver,
|
||||
RectorChangeCollector $rectorChangeCollector,
|
||||
StaticTypeMapper $staticTypeMapper
|
||||
StaticTypeMapper $staticTypeMapper,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,12 +76,12 @@ final class ChildParamPopulator
|
||||
return;
|
||||
}
|
||||
|
||||
$childrenClassLikes = $this->classLikeParsedNodesFinder->findClassesAndInterfacesByType($className);
|
||||
$childrenClassLikes = $this->nodeRepository->findClassesAndInterfacesByType($className);
|
||||
|
||||
// update their methods as well
|
||||
foreach ($childrenClassLikes as $childClassLike) {
|
||||
if ($childClassLike instanceof Class_) {
|
||||
$usedTraits = $this->classLikeParsedNodesFinder->findUsedTraitsInClass($childClassLike);
|
||||
$usedTraits = $this->nodeRepository->findUsedTraitsInClass($childClassLike);
|
||||
|
||||
foreach ($usedTraits as $trait) {
|
||||
$this->addParamTypeToMethod($trait, $position, $functionLike, $paramType);
|
||||
|
@ -15,7 +15,7 @@ use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\StaticType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStan\Type\SelfObjectType;
|
||||
@ -28,24 +28,24 @@ final class ChildReturnPopulator
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
|
||||
/**
|
||||
* @var ClassLikeParsedNodesFinder
|
||||
*/
|
||||
private $classLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
NodeNameResolver $nodeNameResolver,
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
StaticTypeMapper $staticTypeMapper
|
||||
StaticTypeMapper $staticTypeMapper,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,14 +63,14 @@ final class ChildReturnPopulator
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
|
||||
$childrenClassLikes = $this->classLikeParsedNodesFinder->findChildrenOfClass($className);
|
||||
$childrenClassLikes = $this->nodeRepository->findChildrenOfClass($className);
|
||||
if ($childrenClassLikes === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
// update their methods as well
|
||||
foreach ($childrenClassLikes as $childClassLike) {
|
||||
$usedTraits = $this->classLikeParsedNodesFinder->findUsedTraitsInClass($childClassLike);
|
||||
$usedTraits = $this->nodeRepository->findUsedTraitsInClass($childClassLike);
|
||||
foreach ($usedTraits as $trait) {
|
||||
$this->addReturnTypeToChildMethod($trait, $classMethod, $returnType);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeCollector\NodeCollector\ParsedNodeCollector;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
@ -26,26 +26,26 @@ final class ChildAndParentClassManipulator
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
|
||||
/**
|
||||
* @var ClassLikeParsedNodesFinder
|
||||
*/
|
||||
private $classLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @var ParsedNodeCollector
|
||||
*/
|
||||
private $parsedNodeCollector;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
NodeFactory $nodeFactory,
|
||||
NodeNameResolver $nodeNameResolver,
|
||||
ParsedNodeCollector $parsedNodeCollector
|
||||
ParsedNodeCollector $parsedNodeCollector,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->parsedNodeCollector = $parsedNodeCollector;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +80,7 @@ final class ChildAndParentClassManipulator
|
||||
return;
|
||||
}
|
||||
|
||||
$childClassNodes = $this->classLikeParsedNodesFinder->findChildrenOfClass($className);
|
||||
$childClassNodes = $this->nodeRepository->findChildrenOfClass($className);
|
||||
|
||||
foreach ($childClassNodes as $childClassNode) {
|
||||
$childConstructorClassMethod = $childClassNode->getMethod(MethodName::CONSTRUCT);
|
||||
|
@ -21,7 +21,7 @@ use Rector\BetterPhpDocParser\PhpDocNode\JMS\SerializerTypeTagValueNode;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\Doctrine\AbstractRector\DoctrineTrait;
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\SOLID\Guard\VariableToConstantGuard;
|
||||
@ -53,30 +53,30 @@ final class PropertyManipulator
|
||||
*/
|
||||
private $assignManipulator;
|
||||
|
||||
/**
|
||||
* @var ClassLikeParsedNodesFinder
|
||||
*/
|
||||
private $classLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @var VariableToConstantGuard
|
||||
*/
|
||||
private $variableToConstantGuard;
|
||||
|
||||
/**
|
||||
* @var NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
public function __construct(
|
||||
AssignManipulator $assignManipulator,
|
||||
BetterNodeFinder $betterNodeFinder,
|
||||
BetterStandardPrinter $betterStandardPrinter,
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
NodeNameResolver $nodeNameResolver,
|
||||
VariableToConstantGuard $variableToConstantGuard
|
||||
VariableToConstantGuard $variableToConstantGuard,
|
||||
NodeRepository $nodeRepository
|
||||
) {
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->assignManipulator = $assignManipulator;
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
$this->variableToConstantGuard = $variableToConstantGuard;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@ final class PropertyManipulator
|
||||
return [];
|
||||
}
|
||||
|
||||
$nodesToSearch = $this->classLikeParsedNodesFinder->findUsedTraitsInClass($classLike);
|
||||
$nodesToSearch = $this->nodeRepository->findUsedTraitsInClass($classLike);
|
||||
$nodesToSearch[] = $classLike;
|
||||
|
||||
$singleProperty = $property->props[0];
|
||||
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\Core\Rector\AbstractRector;
|
||||
|
||||
use Rector\NodeCollector\NodeFinder\ClassLikeParsedNodesFinder;
|
||||
use Rector\NodeCollector\NodeFinder\FunctionLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
@ -13,11 +12,6 @@ use Rector\NodeCollector\NodeFinder\FunctionLikeParsedNodesFinder;
|
||||
*/
|
||||
trait NodeCollectorTrait
|
||||
{
|
||||
/**
|
||||
* @var ClassLikeParsedNodesFinder
|
||||
*/
|
||||
protected $classLikeParsedNodesFinder;
|
||||
|
||||
/**
|
||||
* @var FunctionLikeParsedNodesFinder
|
||||
*/
|
||||
@ -26,11 +20,8 @@ trait NodeCollectorTrait
|
||||
/**
|
||||
* @required
|
||||
*/
|
||||
public function autowireNodeCollectorTrait(
|
||||
ClassLikeParsedNodesFinder $classLikeParsedNodesFinder,
|
||||
FunctionLikeParsedNodesFinder $functionLikeParsedNodesFinder
|
||||
): void {
|
||||
$this->classLikeParsedNodesFinder = $classLikeParsedNodesFinder;
|
||||
public function autowireNodeCollectorTrait(FunctionLikeParsedNodesFinder $functionLikeParsedNodesFinder): void
|
||||
{
|
||||
$this->functionLikeParsedNodesFinder = $functionLikeParsedNodesFinder;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user