Updated Rector to commit e3ce320151

e3ce320151 [Transform] Remove specific custom Rector without generic usage (#573)
This commit is contained in:
Tomas Votruba 2021-08-02 12:03:27 +00:00
parent 6730953767
commit ebc595cbb2
15 changed files with 19 additions and 905 deletions

View File

@ -1,54 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\RemovingStatic\NodeAnalyzer;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use Rector\Core\ValueObject\MethodName;
use Rector\NodeNameResolver\NodeNameResolver;
final class SetUpClassMethodUpdater
{
/**
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
{
$this->nodeNameResolver = $nodeNameResolver;
}
public function updateSetUpMethod(\PhpParser\Node\Stmt\ClassMethod $setupClassMethod, \PhpParser\Node\Stmt\Expression $parentSetupStaticCall, \PhpParser\Node\Stmt\Expression $assign) : void
{
$parentSetUpStaticCallPosition = $this->getParentSetUpStaticCallPosition($setupClassMethod);
if ($parentSetUpStaticCallPosition === null) {
$setupClassMethod->stmts = \array_merge([$parentSetupStaticCall, $assign], (array) $setupClassMethod->stmts);
} else {
\assert($setupClassMethod->stmts !== null);
\array_splice($setupClassMethod->stmts, $parentSetUpStaticCallPosition + 1, 0, [$assign]);
}
}
private function getParentSetUpStaticCallPosition(\PhpParser\Node\Stmt\ClassMethod $setupClassMethod) : ?int
{
foreach ((array) $setupClassMethod->stmts as $position => $methodStmt) {
if ($methodStmt instanceof \PhpParser\Node\Stmt\Expression) {
$methodStmt = $methodStmt->expr;
}
if (!$methodStmt instanceof \PhpParser\Node\Expr\StaticCall) {
continue;
}
if (!$methodStmt->class instanceof \PhpParser\Node\Name) {
continue;
}
if (!$this->nodeNameResolver->isName($methodStmt->class, 'parent')) {
continue;
}
if (!$this->nodeNameResolver->isName($methodStmt->name, \Rector\Core\ValueObject\MethodName::SET_UP)) {
continue;
}
return $position;
}
return null;
}
}

View File

@ -1,36 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\RemovingStatic\NodeFactory;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Name;
use PHPStan\Type\ObjectType;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
use Rector\StaticTypeMapper\StaticTypeMapper;
final class SelfContainerFactory
{
/**
* @var \Rector\StaticTypeMapper\StaticTypeMapper
*/
private $staticTypeMapper;
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper)
{
$this->staticTypeMapper = $staticTypeMapper;
}
public function createGetTypeMethodCall(\PHPStan\Type\ObjectType $objectType) : \PhpParser\Node\Expr\MethodCall
{
$staticPropertyFetch = new \PhpParser\Node\Expr\StaticPropertyFetch(new \PhpParser\Node\Name('self'), 'container');
$getMethodCall = new \PhpParser\Node\Expr\MethodCall($staticPropertyFetch, 'get');
$className = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($objectType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
if (!$className instanceof \PhpParser\Node\Name) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
}
$getMethodCall->args[] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\ClassConstFetch($className, 'class'));
return $getMethodCall;
}
}

View File

@ -1,268 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\RemovingStatic\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\ObjectType;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\NodeManipulator\ClassInsertManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\MethodName;
use Rector\Naming\Naming\PropertyNaming;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PHPUnit\NodeFactory\SetUpClassMethodFactory;
use Rector\PostRector\Collector\PropertyToAddCollector;
use Rector\PostRector\ValueObject\PropertyMetadata;
use Rector\RemovingStatic\NodeAnalyzer\SetUpClassMethodUpdater;
use Rector\RemovingStatic\NodeFactory\SelfContainerFactory;
use Rector\RemovingStatic\NodeFactory\SetUpFactory;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector\PHPUnitStaticToKernelTestCaseGetRectorTest
*/
final class PHPUnitStaticToKernelTestCaseGetRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
{
/**
* @api
* @var string
*/
public const STATIC_CLASS_TYPES = 'static_class_types';
/**
* @var ObjectType[]
*/
private $staticObjectTypes = [];
/**
* @var ObjectType[]
*/
private $newPropertyObjectTypes = [];
/**
* @var \Rector\Naming\Naming\PropertyNaming
*/
private $propertyNaming;
/**
* @var \Rector\Core\NodeManipulator\ClassInsertManipulator
*/
private $classInsertManipulator;
/**
* @var \Rector\PHPUnit\NodeFactory\SetUpClassMethodFactory
*/
private $setUpClassMethodFactory;
/**
* @var \Rector\RemovingStatic\NodeFactory\SetUpFactory
*/
private $setUpFactory;
/**
* @var \Rector\RemovingStatic\NodeFactory\SelfContainerFactory
*/
private $selfContainerFactory;
/**
* @var \Rector\RemovingStatic\NodeAnalyzer\SetUpClassMethodUpdater
*/
private $setUpClassMethodUpdater;
/**
* @var \Rector\PostRector\Collector\PropertyToAddCollector
*/
private $propertyToAddCollector;
public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\PHPUnit\NodeFactory\SetUpClassMethodFactory $setUpClassMethodFactory, \Rector\RemovingStatic\NodeFactory\SetUpFactory $setUpFactory, \Rector\RemovingStatic\NodeFactory\SelfContainerFactory $selfContainerFactory, \Rector\RemovingStatic\NodeAnalyzer\SetUpClassMethodUpdater $setUpClassMethodUpdater, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector)
{
$this->propertyNaming = $propertyNaming;
$this->classInsertManipulator = $classInsertManipulator;
$this->setUpClassMethodFactory = $setUpClassMethodFactory;
$this->setUpFactory = $setUpFactory;
$this->selfContainerFactory = $selfContainerFactory;
$this->setUpClassMethodUpdater = $setUpClassMethodUpdater;
$this->propertyToAddCollector = $propertyToAddCollector;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert static calls in PHPUnit test cases, to get() from the container of KernelTestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
use PHPUnit\Framework\TestCase;
final class SomeTestCase extends TestCase
{
public function test()
{
$product = EntityFactory::create('product');
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
final class SomeTestCase extends KernelTestCase
{
/**
* @var EntityFactory
*/
private $entityFactory;
protected function setUp(): void
{
parent::setUp();
$this->entityFactory = $this->getService(EntityFactory::class);
}
public function test()
{
$product = $this->entityFactory->create('product');
}
}
CODE_SAMPLE
, [self::STATIC_CLASS_TYPES => ['EntityFactory']])]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Stmt\Class_::class];
}
/**
* @param StaticCall|Class_ $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
// skip yourself
$this->newPropertyObjectTypes = [];
if ($node instanceof \PhpParser\Node\Stmt\Class_) {
if ($this->nodeTypeResolver->isObjectTypes($node, $this->staticObjectTypes)) {
return null;
}
return $this->processClass($node);
}
return $this->processStaticCall($node);
}
/**
* @param array<string, mixed> $configuration
*/
public function configure(array $configuration) : void
{
$staticClassTypes = $configuration[self::STATIC_CLASS_TYPES] ?? [];
foreach ($staticClassTypes as $staticClassType) {
$this->staticObjectTypes[] = new \PHPStan\Type\ObjectType($staticClassType);
}
}
private function processClass(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\Class_
{
if ($this->isObjectType($class, new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\TestCase'))) {
return $this->processPHPUnitClass($class);
}
// add property with the object
$newPropertyObjectTypes = $this->collectNewPropertyObjectTypes($class);
if ($newPropertyObjectTypes === []) {
return null;
}
// add via constructor
foreach ($newPropertyObjectTypes as $newPropertyObjectType) {
$newPropertyName = $this->propertyNaming->fqnToVariableName($newPropertyObjectType);
$propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($newPropertyName, $newPropertyObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE);
$this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata);
}
return $class;
}
private function processStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\MethodCall
{
$classLike = $staticCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE);
if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) {
return null;
}
foreach ($this->staticObjectTypes as $staticObjectType) {
if (!$this->isObjectType($staticCall->class, $staticObjectType)) {
continue;
}
return $this->convertStaticCallToPropertyMethodCall($staticCall, $staticObjectType);
}
return null;
}
private function processPHPUnitClass(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\Class_
{
// add property with the object
$newPropertyTypes = $this->collectNewPropertyObjectTypes($class);
if ($newPropertyTypes === []) {
return null;
}
// add all properties to class
$class = $this->addNewPropertiesToClass($class, $newPropertyTypes);
$parentSetUpStaticCallExpression = $this->setUpFactory->createParentStaticCall();
foreach ($newPropertyTypes as $newPropertyType) {
// container fetch assign
$assign = $this->createContainerGetTypeToPropertyAssign($newPropertyType);
$setupClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::SET_UP);
// get setup or create a setup add add it there
if ($setupClassMethod !== null) {
$this->setUpClassMethodUpdater->updateSetUpMethod($setupClassMethod, $parentSetUpStaticCallExpression, $assign);
} else {
$setUpMethod = $this->setUpClassMethodFactory->createSetUpMethod([$assign]);
$this->classInsertManipulator->addAsFirstMethod($class, $setUpMethod);
}
}
// update parent clsas if not already
if (!$this->isObjectType($class, new \PHPStan\Type\ObjectType('Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase'))) {
$class->extends = new \PhpParser\Node\Name\FullyQualified('Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase');
}
return $class;
}
/**
* @return ObjectType[]
*/
private function collectNewPropertyObjectTypes(\PhpParser\Node\Stmt\Class_ $class) : array
{
$this->newPropertyObjectTypes = [];
$this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) : void {
if (!$node instanceof \PhpParser\Node\Expr\StaticCall) {
return;
}
foreach ($this->staticObjectTypes as $staticObjectType) {
if (!$this->isObjectType($node->class, $staticObjectType)) {
continue;
}
$this->newPropertyObjectTypes[] = $staticObjectType;
}
});
$this->newPropertyObjectTypes = \array_unique($this->newPropertyObjectTypes);
return $this->newPropertyObjectTypes;
}
private function convertStaticCallToPropertyMethodCall(\PhpParser\Node\Expr\StaticCall $staticCall, \PHPStan\Type\ObjectType $objectType) : \PhpParser\Node\Expr\MethodCall
{
// create "$this->someService" instead
$propertyName = $this->propertyNaming->fqnToVariableName($objectType);
$propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName);
// turn static call to method on property call
$methodCall = new \PhpParser\Node\Expr\MethodCall($propertyFetch, $staticCall->name);
$methodCall->args = $staticCall->args;
return $methodCall;
}
/**
* @param ObjectType[] $propertyTypes
*/
private function addNewPropertiesToClass(\PhpParser\Node\Stmt\Class_ $class, array $propertyTypes) : \PhpParser\Node\Stmt\Class_
{
$properties = [];
foreach ($propertyTypes as $propertyType) {
$propertyName = $this->propertyNaming->fqnToVariableName($propertyType);
$properties[] = $this->nodeFactory->createPrivatePropertyFromNameAndType($propertyName, $propertyType);
}
// add property to the start of the class
$class->stmts = \array_merge($properties, $class->stmts);
return $class;
}
private function createContainerGetTypeToPropertyAssign(\PHPStan\Type\ObjectType $objectType) : \PhpParser\Node\Stmt\Expression
{
$getMethodCall = $this->selfContainerFactory->createGetTypeMethodCall($objectType);
$propertyName = $this->propertyNaming->fqnToVariableName($objectType);
$propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName);
$assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $getMethodCall);
return new \PhpParser\Node\Stmt\Expression($assign);
}
}

View File

@ -1,40 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\Naming;
use PhpParser\Node;
use PhpParser\Node\Stmt\Namespace_;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\NodeNameResolver\NodeNameResolver;
final class FullyQualifiedNameResolver
{
/**
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
/**
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
{
$this->betterNodeFinder = $betterNodeFinder;
$this->nodeNameResolver = $nodeNameResolver;
}
/**
* @param Node[] $nodes
*/
public function resolveFullyQualifiedName(array $nodes, string $shortClassName) : string
{
$namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Namespace_::class);
if (!$namespace instanceof \PhpParser\Node\Stmt\Namespace_) {
return $shortClassName;
}
$namespaceName = $this->nodeNameResolver->getName($namespace);
if ($namespaceName === null) {
return $shortClassName;
}
return $namespaceName . '\\' . $shortClassName;
}
}

View File

@ -1,44 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\NodeFactory;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use Rector\CodingStyle\Naming\ClassNaming;
use RectorPrefix20210802\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder;
final class StaticMethodClassFactory
{
/**
* @var \Rector\Transform\NodeFactory\ClassMethodFactory
*/
private $classMethodFactory;
/**
* @var \Rector\CodingStyle\Naming\ClassNaming
*/
private $classNaming;
public function __construct(\Rector\Transform\NodeFactory\ClassMethodFactory $classMethodFactory, \Rector\CodingStyle\Naming\ClassNaming $classNaming)
{
$this->classMethodFactory = $classMethodFactory;
$this->classNaming = $classNaming;
}
/**
* @param Function_[] $functions
*/
public function createStaticMethodClass(string $shortClassName, array $functions) : \PhpParser\Node\Stmt\Class_
{
$classBuilder = new \RectorPrefix20210802\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder($shortClassName);
$classBuilder->makeFinal();
foreach ($functions as $function) {
$staticClassMethod = $this->createStaticMethod($function);
$classBuilder->addStmt($staticClassMethod);
}
return $classBuilder->getNode();
}
private function createStaticMethod(\PhpParser\Node\Stmt\Function_ $function) : \PhpParser\Node\Stmt\ClassMethod
{
$methodName = $this->classNaming->createMethodNameFromFunction($function);
return $this->classMethodFactory->createClassMethodFromFunction($methodName, $function);
}
}

View File

@ -1,107 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\Rector\Expression;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Return_;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Transform\ValueObject\MethodCallToReturn;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix20210802\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Transform\Rector\Expression\MethodCallToReturnRector\MethodCallToReturnRectorTest
*/
final class MethodCallToReturnRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
{
/**
* @var string
*/
public const METHOD_CALL_WRAPS = 'method_call_wraps';
/**
* @var MethodCallToReturn[]
*/
private $methodCallWraps = [];
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Wrap method call to return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$this->deny();
}
public function deny()
{
return 1;
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
return $this->deny();
}
public function deny()
{
return 1;
}
}
CODE_SAMPLE
, [self::METHOD_CALL_WRAPS => [new \Rector\Transform\ValueObject\MethodCallToReturn('SomeClass', 'deny')]])]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\Expression::class];
}
/**
* @param Expression $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if (!$node->expr instanceof \PhpParser\Node\Expr\MethodCall) {
return null;
}
$methodCall = $node->expr;
return $this->refactorMethodCall($methodCall);
}
/**
* @param array<string, MethodCallToReturn[]> $configuration
*/
public function configure(array $configuration) : void
{
$methodCallWraps = $configuration[self::METHOD_CALL_WRAPS] ?? [];
\RectorPrefix20210802\Webmozart\Assert\Assert::allIsInstanceOf($methodCallWraps, \Rector\Transform\ValueObject\MethodCallToReturn::class);
$this->methodCallWraps = $methodCallWraps;
}
private function refactorMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node
{
$parent = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
foreach ($this->methodCallWraps as $methodCallWrap) {
if (!$this->isObjectType($methodCall->var, $methodCallWrap->getObjectType())) {
continue;
}
if (!$this->isName($methodCall->name, $methodCallWrap->getMethod())) {
continue;
}
// already wrapped
if ($parent instanceof \PhpParser\Node\Stmt\Return_) {
continue;
}
return new \PhpParser\Node\Stmt\Return_($methodCall);
}
return null;
}
}

View File

@ -1,157 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\Rector\FileWithoutNamespace;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Namespace_;
use Rector\CodingStyle\Naming\ClassNaming;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\Rector\AbstractRector;
use Rector\FileSystemRector\ValueObject\AddedFileWithNodes;
use Rector\Transform\Naming\FullyQualifiedNameResolver;
use Rector\Transform\NodeFactory\StaticMethodClassFactory;
use Rector\Transform\ValueObject\FunctionToStaticCall;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use Symplify\SmartFileSystem\SmartFileInfo;
/**
* @see \Rector\Tests\Transform\Rector\FileWithoutNamespace\FunctionToStaticMethodRector\FunctionToStaticMethodRectorTest
*/
final class FunctionToStaticMethodRector extends \Rector\Core\Rector\AbstractRector
{
/**
* @var \Rector\CodingStyle\Naming\ClassNaming
*/
private $classNaming;
/**
* @var \Rector\Transform\NodeFactory\StaticMethodClassFactory
*/
private $staticMethodClassFactory;
/**
* @var \Rector\Transform\Naming\FullyQualifiedNameResolver
*/
private $fullyQualifiedNameResolver;
public function __construct(\Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\Transform\NodeFactory\StaticMethodClassFactory $staticMethodClassFactory, \Rector\Transform\Naming\FullyQualifiedNameResolver $fullyQualifiedNameResolver)
{
$this->classNaming = $classNaming;
$this->staticMethodClassFactory = $staticMethodClassFactory;
$this->fullyQualifiedNameResolver = $fullyQualifiedNameResolver;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change functions to static calls, so composer can autoload them', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
function some_function()
{
}
some_function('lol');
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeUtilsClass
{
public static function someFunction()
{
}
}
SomeUtilsClass::someFunction('lol');
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class, \PhpParser\Node\Stmt\Namespace_::class];
}
/**
* @param FileWithoutNamespace|Namespace_ $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
/** @var Function_[] $functions */
$functions = $this->betterNodeFinder->findInstanceOf($node, \PhpParser\Node\Stmt\Function_::class);
if ($functions === []) {
return null;
}
$smartFileInfo = $this->file->getSmartFileInfo();
$shortClassName = $this->classNaming->getNameFromFileInfo($smartFileInfo);
$class = $this->staticMethodClassFactory->createStaticMethodClass($shortClassName, $functions);
$stmts = $node->stmts;
$this->removeNodes($functions);
// replace function calls with class static call
$functionsToStaticCalls = $this->resolveFunctionsToStaticCalls($stmts, $shortClassName, $functions);
$node->stmts = $this->replaceFuncCallsWithStaticCalls($stmts, $functionsToStaticCalls);
$this->printStaticMethodClass($smartFileInfo, $shortClassName, $node, $class);
return $node;
}
/**
* @param Node[] $stmts
* @param Function_[] $functions
* @return FunctionToStaticCall[]
*/
private function resolveFunctionsToStaticCalls(array $stmts, string $shortClassName, array $functions) : array
{
$functionsToStaticCalls = [];
$className = $this->fullyQualifiedNameResolver->resolveFullyQualifiedName($stmts, $shortClassName);
foreach ($functions as $function) {
$functionName = $this->getName($function);
if ($functionName === null) {
continue;
}
$methodName = $this->classNaming->createMethodNameFromFunction($function);
$functionsToStaticCalls[] = new \Rector\Transform\ValueObject\FunctionToStaticCall($functionName, $className, $methodName);
}
return $functionsToStaticCalls;
}
/**
* @param Node[] $stmts
* @param FunctionToStaticCall[] $functionsToStaticCalls
* @return Node[]
*/
private function replaceFuncCallsWithStaticCalls(array $stmts, array $functionsToStaticCalls) : array
{
$this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($functionsToStaticCalls) : ?StaticCall {
if (!$node instanceof \PhpParser\Node\Expr\FuncCall) {
return null;
}
foreach ($functionsToStaticCalls as $functionToStaticCall) {
if (!$this->isName($node, $functionToStaticCall->getFunction())) {
continue;
}
$staticCall = $this->nodeFactory->createStaticCall($functionToStaticCall->getClass(), $functionToStaticCall->getMethod());
$staticCall->args = $node->args;
return $staticCall;
}
return null;
});
return $stmts;
}
/**
* @param \PhpParser\Node\Stmt\Namespace_|\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $node
*/
private function printStaticMethodClass(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, string $shortClassName, $node, \PhpParser\Node\Stmt\Class_ $class) : void
{
$classFileDestination = $smartFileInfo->getPath() . \DIRECTORY_SEPARATOR . $shortClassName . '.php';
$nodesToPrint = [$this->resolveNodeToPrint($node, $class)];
$addedFileWithNodes = new \Rector\FileSystemRector\ValueObject\AddedFileWithNodes($classFileDestination, $nodesToPrint);
$this->removedAndAddedFilesCollector->addAddedFile($addedFileWithNodes);
}
/**
* @param \PhpParser\Node\Stmt\Namespace_|\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $node
* @return \PhpParser\Node\Stmt\Namespace_|\PhpParser\Node\Stmt\Class_
*/
private function resolveNodeToPrint($node, \PhpParser\Node\Stmt\Class_ $class)
{
if ($node instanceof \PhpParser\Node\Stmt\Namespace_) {
return new \PhpParser\Node\Stmt\Namespace_($node->name, [$class]);
}
return $class;
}
}

View File

@ -1,132 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Type\ObjectType;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Naming\Naming\PropertyNaming;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PostRector\Collector\PropertyToAddCollector;
use Rector\PostRector\ValueObject\PropertyMetadata;
use Rector\Transform\ValueObject\VariableMethodCallToServiceCall;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector\VariableMethodCallToServiceCallRectorTest
*/
final class VariableMethodCallToServiceCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
{
/**
* @var string
*/
public const VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS = 'variable_method_calls_to_service_calls';
/**
* @var VariableMethodCallToServiceCall[]
*/
private $variableMethodCallsToServiceCalls = [];
/**
* @var \Rector\Naming\Naming\PropertyNaming
*/
private $propertyNaming;
/**
* @var \Rector\PostRector\Collector\PropertyToAddCollector
*/
private $propertyToAddCollector;
public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector)
{
$this->propertyNaming = $propertyNaming;
$this->propertyToAddCollector = $propertyToAddCollector;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace variable method call to a service one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
use PhpParser\Node;
class SomeClass
{
public function run(Node $node)
{
$phpDocInfo = $node->getAttribute('php_doc_info');
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use PhpParser\Node;
class SomeClass
{
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
}
public function run(Node $node)
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
}
}
CODE_SAMPLE
, [self::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS => [new \Rector\Transform\ValueObject\VariableMethodCallToServiceCall('PhpParser\\Node', 'getAttribute', 'php_doc_info', 'Rector\\BetterPhpDocParser\\PhpDocInfo\\PhpDocInfoFactory', 'createFromNodeOrEmpty')]])]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\MethodCall::class];
}
/**
* @param MethodCall $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
foreach ($this->variableMethodCallsToServiceCalls as $variableMethodCallToServiceCall) {
if (!$node->var instanceof \PhpParser\Node\Expr\Variable) {
continue;
}
if (!$this->isObjectType($node->var, $variableMethodCallToServiceCall->getVariableObjectType())) {
continue;
}
if (!$this->isName($node->name, $variableMethodCallToServiceCall->getMethodName())) {
continue;
}
$firstArgValue = $node->args[0]->value;
if (!$this->valueResolver->isValue($firstArgValue, $variableMethodCallToServiceCall->getArgumentValue())) {
continue;
}
$classLike = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE);
if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) {
continue;
}
$serviceObjectType = new \PHPStan\Type\ObjectType($variableMethodCallToServiceCall->getServiceType());
$propertyName = $this->propertyNaming->fqnToVariableName($serviceObjectType);
$propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $serviceObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE);
$this->propertyToAddCollector->addPropertyToClass($classLike, $propertyMetadata);
return $this->createServiceMethodCall($serviceObjectType, $variableMethodCallToServiceCall->getServiceMethodName(), $node);
}
return null;
}
/**
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
$this->variableMethodCallsToServiceCalls = $configuration[self::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS] ?? [];
}
private function createServiceMethodCall(\PHPStan\Type\ObjectType $objectType, string $methodName, \PhpParser\Node\Expr\MethodCall $node) : \PhpParser\Node\Expr\MethodCall
{
$propertyName = $this->propertyNaming->fqnToVariableName($objectType);
$propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName);
$methodCall = new \PhpParser\Node\Expr\MethodCall($propertyFetch, $methodName);
$methodCall->args[] = new \PhpParser\Node\Arg($node->var);
return $methodCall;
}
}

View File

@ -1,30 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
final class MethodCallToReturn
{
/**
* @var string
*/
private $class;
/**
* @var string
*/
private $method;
public function __construct(string $class, string $method)
{
$this->class = $class;
$this->method = $method;
}
public function getObjectType() : \PHPStan\Type\ObjectType
{
return new \PHPStan\Type\ObjectType($this->class);
}
public function getMethod() : string
{
return $this->method;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '4d816080ee22e8414d7252938c4e758fcca84355';
public const PACKAGE_VERSION = 'e3ce3201512eb23ba2b195265dc63c671893c43a';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-02 11:33:54';
public const RELEASE_DATE = '2021-08-02 11:51:51';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210802\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf::getLoader();
return ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e::getLoader();

View File

@ -2835,15 +2835,12 @@ return array(
'Rector\\RectorInstaller\\LocalFilesystem' => $vendorDir . '/rector/extension-installer/src/LocalFilesystem.php',
'Rector\\RectorInstaller\\Plugin' => $vendorDir . '/rector/extension-installer/src/Plugin.php',
'Rector\\RectorInstaller\\PluginInstaller' => $vendorDir . '/rector/extension-installer/src/PluginInstaller.php',
'Rector\\RemovingStatic\\NodeAnalyzer\\SetUpClassMethodUpdater' => $baseDir . '/rules/RemovingStatic/NodeAnalyzer/SetUpClassMethodUpdater.php',
'Rector\\RemovingStatic\\NodeAnalyzer\\StaticCallPresenceAnalyzer' => $baseDir . '/rules/RemovingStatic/NodeAnalyzer/StaticCallPresenceAnalyzer.php',
'Rector\\RemovingStatic\\NodeFactory\\SelfContainerFactory' => $baseDir . '/rules/RemovingStatic/NodeFactory/SelfContainerFactory.php',
'Rector\\RemovingStatic\\NodeFactory\\SetUpFactory' => $baseDir . '/rules/RemovingStatic/NodeFactory/SetUpFactory.php',
'Rector\\RemovingStatic\\Printer\\FactoryClassPrinter' => $baseDir . '/rules/RemovingStatic/Printer/FactoryClassPrinter.php',
'Rector\\RemovingStatic\\Rector\\ClassMethod\\LocallyCalledStaticMethodToNonStaticRector' => $baseDir . '/rules/RemovingStatic/Rector/ClassMethod/LocallyCalledStaticMethodToNonStaticRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\DesiredClassTypeToDynamicRector' => $baseDir . '/rules/RemovingStatic/Rector/Class_/DesiredClassTypeToDynamicRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\NewUniqueObjectToEntityFactoryRector' => $baseDir . '/rules/RemovingStatic/Rector/Class_/NewUniqueObjectToEntityFactoryRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\PHPUnitStaticToKernelTestCaseGetRector' => $baseDir . '/rules/RemovingStatic/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\PassFactoryToUniqueObjectRector' => $baseDir . '/rules/RemovingStatic/Rector/Class_/PassFactoryToUniqueObjectRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\StaticTypeToSetterInjectionRector' => $baseDir . '/rules/RemovingStatic/Rector/Class_/StaticTypeToSetterInjectionRector.php',
'Rector\\RemovingStatic\\Rector\\Property\\DesiredPropertyClassMethodTypeToDynamicRector' => $baseDir . '/rules/RemovingStatic/Rector/Property/DesiredPropertyClassMethodTypeToDynamicRector.php',
@ -3028,13 +3025,11 @@ return array(
'Rector\\Testing\\PHPUnit\\StaticPHPUnitEnvironment' => $baseDir . '/packages/Testing/PHPUnit/StaticPHPUnitEnvironment.php',
'Rector\\Testing\\TestingParser\\TestingParser' => $baseDir . '/packages/Testing/TestingParser/TestingParser.php',
'Rector\\Testing\\ValueObject\\InputFilePathWithExpectedFile' => $baseDir . '/packages/Testing/ValueObject/InputFilePathWithExpectedFile.php',
'Rector\\Transform\\Naming\\FullyQualifiedNameResolver' => $baseDir . '/rules/Transform/Naming/FullyQualifiedNameResolver.php',
'Rector\\Transform\\NodeAnalyzer\\FuncCallStaticCallToMethodCallAnalyzer' => $baseDir . '/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php',
'Rector\\Transform\\NodeAnalyzer\\SingletonClassMethodAnalyzer' => $baseDir . '/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php',
'Rector\\Transform\\NodeFactory\\ClassMethodFactory' => $baseDir . '/rules/Transform/NodeFactory/ClassMethodFactory.php',
'Rector\\Transform\\NodeFactory\\PropertyFetchFactory' => $baseDir . '/rules/Transform/NodeFactory/PropertyFetchFactory.php',
'Rector\\Transform\\NodeFactory\\ProvideConfigFilePathClassMethodFactory' => $baseDir . '/rules/Transform/NodeFactory/ProvideConfigFilePathClassMethodFactory.php',
'Rector\\Transform\\NodeFactory\\StaticMethodClassFactory' => $baseDir . '/rules/Transform/NodeFactory/StaticMethodClassFactory.php',
'Rector\\Transform\\NodeFactory\\UnwrapClosureFactory' => $baseDir . '/rules/Transform/NodeFactory/UnwrapClosureFactory.php',
'Rector\\Transform\\NodeTypeAnalyzer\\TypeProvidingExprFromClassResolver' => $baseDir . '/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php',
'Rector\\Transform\\Rector\\Assign\\DimFetchAssignToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php',
@ -3049,8 +3044,6 @@ return array(
'Rector\\Transform\\Rector\\Class_\\ChangeSingletonToServiceRector' => $baseDir . '/rules/Transform/Rector/Class_/ChangeSingletonToServiceRector.php',
'Rector\\Transform\\Rector\\Class_\\MergeInterfacesRector' => $baseDir . '/rules/Transform/Rector/Class_/MergeInterfacesRector.php',
'Rector\\Transform\\Rector\\Class_\\ParentClassToTraitsRector' => $baseDir . '/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php',
'Rector\\Transform\\Rector\\Expression\\MethodCallToReturnRector' => $baseDir . '/rules/Transform/Rector/Expression/MethodCallToReturnRector.php',
'Rector\\Transform\\Rector\\FileWithoutNamespace\\FunctionToStaticMethodRector' => $baseDir . '/rules/Transform/Rector/FileWithoutNamespace/FunctionToStaticMethodRector.php',
'Rector\\Transform\\Rector\\FuncCall\\ArgumentFuncCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php',
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToConstFetchRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php',
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php',
@ -3064,7 +3057,6 @@ return array(
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToStaticCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php',
'Rector\\Transform\\Rector\\MethodCall\\ReplaceParentCallByPropertyCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php',
'Rector\\Transform\\Rector\\MethodCall\\ServiceGetterToConstructorInjectionRector' => $baseDir . '/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php',
'Rector\\Transform\\Rector\\MethodCall\\VariableMethodCallToServiceCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/VariableMethodCallToServiceCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewArgToMethodCallRector' => $baseDir . '/rules/Transform/Rector/New_/NewArgToMethodCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewToConstructorInjectionRector' => $baseDir . '/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php',
'Rector\\Transform\\Rector\\New_\\NewToMethodCallRector' => $baseDir . '/rules/Transform/Rector/New_/NewToMethodCallRector.php',
@ -3085,7 +3077,6 @@ return array(
'Rector\\Transform\\ValueObject\\GetAndSetToMethodCall' => $baseDir . '/rules/Transform/ValueObject/GetAndSetToMethodCall.php',
'Rector\\Transform\\ValueObject\\MethodCallToAnotherMethodCallWithArguments' => $baseDir . '/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php',
'Rector\\Transform\\ValueObject\\MethodCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToMethodCall.php',
'Rector\\Transform\\ValueObject\\MethodCallToReturn' => $baseDir . '/rules/Transform/ValueObject/MethodCallToReturn.php',
'Rector\\Transform\\ValueObject\\MethodCallToStaticCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToStaticCall.php',
'Rector\\Transform\\ValueObject\\NewArgToMethodCall' => $baseDir . '/rules/Transform/ValueObject/NewArgToMethodCall.php',
'Rector\\Transform\\ValueObject\\NewToMethodCall' => $baseDir . '/rules/Transform/ValueObject/NewToMethodCall.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf
class ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit7a605ef554a9e3e46d85e12cdfbd1d3e::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit7a605ef554a9e3e46d85e12cdfbd1d3e::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiree884cc48de6e7e624cac6e13afe63ddf($fileIdentifier, $file);
composerRequire7a605ef554a9e3e46d85e12cdfbd1d3e($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequiree884cc48de6e7e624cac6e13afe63ddf($fileIdentifier, $file)
function composerRequire7a605ef554a9e3e46d85e12cdfbd1d3e($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
class ComposerStaticInit7a605ef554a9e3e46d85e12cdfbd1d3e
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3190,15 +3190,12 @@ class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
'Rector\\RectorInstaller\\LocalFilesystem' => __DIR__ . '/..' . '/rector/extension-installer/src/LocalFilesystem.php',
'Rector\\RectorInstaller\\Plugin' => __DIR__ . '/..' . '/rector/extension-installer/src/Plugin.php',
'Rector\\RectorInstaller\\PluginInstaller' => __DIR__ . '/..' . '/rector/extension-installer/src/PluginInstaller.php',
'Rector\\RemovingStatic\\NodeAnalyzer\\SetUpClassMethodUpdater' => __DIR__ . '/../..' . '/rules/RemovingStatic/NodeAnalyzer/SetUpClassMethodUpdater.php',
'Rector\\RemovingStatic\\NodeAnalyzer\\StaticCallPresenceAnalyzer' => __DIR__ . '/../..' . '/rules/RemovingStatic/NodeAnalyzer/StaticCallPresenceAnalyzer.php',
'Rector\\RemovingStatic\\NodeFactory\\SelfContainerFactory' => __DIR__ . '/../..' . '/rules/RemovingStatic/NodeFactory/SelfContainerFactory.php',
'Rector\\RemovingStatic\\NodeFactory\\SetUpFactory' => __DIR__ . '/../..' . '/rules/RemovingStatic/NodeFactory/SetUpFactory.php',
'Rector\\RemovingStatic\\Printer\\FactoryClassPrinter' => __DIR__ . '/../..' . '/rules/RemovingStatic/Printer/FactoryClassPrinter.php',
'Rector\\RemovingStatic\\Rector\\ClassMethod\\LocallyCalledStaticMethodToNonStaticRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/ClassMethod/LocallyCalledStaticMethodToNonStaticRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\DesiredClassTypeToDynamicRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/Class_/DesiredClassTypeToDynamicRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\NewUniqueObjectToEntityFactoryRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/Class_/NewUniqueObjectToEntityFactoryRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\PHPUnitStaticToKernelTestCaseGetRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\PassFactoryToUniqueObjectRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/Class_/PassFactoryToUniqueObjectRector.php',
'Rector\\RemovingStatic\\Rector\\Class_\\StaticTypeToSetterInjectionRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/Class_/StaticTypeToSetterInjectionRector.php',
'Rector\\RemovingStatic\\Rector\\Property\\DesiredPropertyClassMethodTypeToDynamicRector' => __DIR__ . '/../..' . '/rules/RemovingStatic/Rector/Property/DesiredPropertyClassMethodTypeToDynamicRector.php',
@ -3383,13 +3380,11 @@ class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
'Rector\\Testing\\PHPUnit\\StaticPHPUnitEnvironment' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/StaticPHPUnitEnvironment.php',
'Rector\\Testing\\TestingParser\\TestingParser' => __DIR__ . '/../..' . '/packages/Testing/TestingParser/TestingParser.php',
'Rector\\Testing\\ValueObject\\InputFilePathWithExpectedFile' => __DIR__ . '/../..' . '/packages/Testing/ValueObject/InputFilePathWithExpectedFile.php',
'Rector\\Transform\\Naming\\FullyQualifiedNameResolver' => __DIR__ . '/../..' . '/rules/Transform/Naming/FullyQualifiedNameResolver.php',
'Rector\\Transform\\NodeAnalyzer\\FuncCallStaticCallToMethodCallAnalyzer' => __DIR__ . '/../..' . '/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php',
'Rector\\Transform\\NodeAnalyzer\\SingletonClassMethodAnalyzer' => __DIR__ . '/../..' . '/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php',
'Rector\\Transform\\NodeFactory\\ClassMethodFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/ClassMethodFactory.php',
'Rector\\Transform\\NodeFactory\\PropertyFetchFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/PropertyFetchFactory.php',
'Rector\\Transform\\NodeFactory\\ProvideConfigFilePathClassMethodFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/ProvideConfigFilePathClassMethodFactory.php',
'Rector\\Transform\\NodeFactory\\StaticMethodClassFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/StaticMethodClassFactory.php',
'Rector\\Transform\\NodeFactory\\UnwrapClosureFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/UnwrapClosureFactory.php',
'Rector\\Transform\\NodeTypeAnalyzer\\TypeProvidingExprFromClassResolver' => __DIR__ . '/../..' . '/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php',
'Rector\\Transform\\Rector\\Assign\\DimFetchAssignToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php',
@ -3404,8 +3399,6 @@ class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
'Rector\\Transform\\Rector\\Class_\\ChangeSingletonToServiceRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Class_/ChangeSingletonToServiceRector.php',
'Rector\\Transform\\Rector\\Class_\\MergeInterfacesRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Class_/MergeInterfacesRector.php',
'Rector\\Transform\\Rector\\Class_\\ParentClassToTraitsRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php',
'Rector\\Transform\\Rector\\Expression\\MethodCallToReturnRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Expression/MethodCallToReturnRector.php',
'Rector\\Transform\\Rector\\FileWithoutNamespace\\FunctionToStaticMethodRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FileWithoutNamespace/FunctionToStaticMethodRector.php',
'Rector\\Transform\\Rector\\FuncCall\\ArgumentFuncCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php',
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToConstFetchRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php',
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php',
@ -3419,7 +3412,6 @@ class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php',
'Rector\\Transform\\Rector\\MethodCall\\ReplaceParentCallByPropertyCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php',
'Rector\\Transform\\Rector\\MethodCall\\ServiceGetterToConstructorInjectionRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php',
'Rector\\Transform\\Rector\\MethodCall\\VariableMethodCallToServiceCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/VariableMethodCallToServiceCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewArgToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/New_/NewArgToMethodCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewToConstructorInjectionRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php',
'Rector\\Transform\\Rector\\New_\\NewToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/New_/NewToMethodCallRector.php',
@ -3440,7 +3432,6 @@ class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
'Rector\\Transform\\ValueObject\\GetAndSetToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/GetAndSetToMethodCall.php',
'Rector\\Transform\\ValueObject\\MethodCallToAnotherMethodCallWithArguments' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php',
'Rector\\Transform\\ValueObject\\MethodCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToMethodCall.php',
'Rector\\Transform\\ValueObject\\MethodCallToReturn' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToReturn.php',
'Rector\\Transform\\ValueObject\\MethodCallToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToStaticCall.php',
'Rector\\Transform\\ValueObject\\NewArgToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/NewArgToMethodCall.php',
'Rector\\Transform\\ValueObject\\NewToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/NewToMethodCall.php',
@ -3850,9 +3841,9 @@ class ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInite884cc48de6e7e624cac6e13afe63ddf::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit7a605ef554a9e3e46d85e12cdfbd1d3e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7a605ef554a9e3e46d85e12cdfbd1d3e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7a605ef554a9e3e46d85e12cdfbd1d3e::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20210802\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf', false) && !interface_exists('ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf', false) && !trait_exists('ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf', false)) {
spl_autoload_call('RectorPrefix20210802\ComposerAutoloaderInite884cc48de6e7e624cac6e13afe63ddf');
if (!class_exists('ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e', false) && !interface_exists('ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e', false) && !trait_exists('ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e', false)) {
spl_autoload_call('RectorPrefix20210802\ComposerAutoloaderInit7a605ef554a9e3e46d85e12cdfbd1d3e');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210802\Doctrine\Inflector\Inflector');
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210802\print_node(...func_get_args());
}
}
if (!function_exists('composerRequiree884cc48de6e7e624cac6e13afe63ddf')) {
function composerRequiree884cc48de6e7e624cac6e13afe63ddf() {
return \RectorPrefix20210802\composerRequiree884cc48de6e7e624cac6e13afe63ddf(...func_get_args());
if (!function_exists('composerRequire7a605ef554a9e3e46d85e12cdfbd1d3e')) {
function composerRequire7a605ef554a9e3e46d85e12cdfbd1d3e() {
return \RectorPrefix20210802\composerRequire7a605ef554a9e3e46d85e12cdfbd1d3e(...func_get_args());
}
}
if (!function_exists('parseArgs')) {