mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 23:41:57 +02:00
Updated Rector to commit 059783fb07cbe5bd2259d4634d32f563ce862de0
059783fb07
Remove MethodCallToMethodCallRector as unused (#4128)
This commit is contained in:
parent
b9a035cc96
commit
08a4332d59
@ -1,4 +1,4 @@
|
||||
# 373 Rules Overview
|
||||
# 372 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
- [Strict](#strict) (5)
|
||||
|
||||
- [Transform](#transform) (24)
|
||||
- [Transform](#transform) (23)
|
||||
|
||||
- [TypeDeclaration](#typedeclaration) (40)
|
||||
|
||||
@ -7117,51 +7117,6 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
|
||||
<br>
|
||||
|
||||
### MethodCallToMethodCallRector
|
||||
|
||||
Change method one method from one service to a method call to in another service
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Transform\Rector\MethodCall\MethodCallToMethodCallRector`](../rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Transform\Rector\MethodCall\MethodCallToMethodCallRector;
|
||||
use Rector\Transform\ValueObject\MethodCallToMethodCall;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(MethodCallToMethodCallRector::class, [
|
||||
new MethodCallToMethodCall('FirstDependency', 'go', 'SecondDependency', 'away'),
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function __construct(
|
||||
- private FirstDependency $firstDependency
|
||||
+ private SecondDependency $secondDependency
|
||||
) {
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
- $this->firstDependency->go();
|
||||
+ $this->secondDependency->away();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### MethodCallToPropertyFetchRector
|
||||
|
||||
Turns method call `"$this->something()"` to property fetch "$this->something"
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodeQuality;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Stmt\Case_;
|
||||
use PhpParser\Node\Stmt\Catch_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Do_;
|
||||
use PhpParser\Node\Stmt\Else_;
|
||||
use PhpParser\Node\Stmt\ElseIf_;
|
||||
use PhpParser\Node\Stmt\Finally_;
|
||||
use PhpParser\Node\Stmt\For_;
|
||||
use PhpParser\Node\Stmt\Foreach_;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\TryCatch;
|
||||
use PhpParser\Node\Stmt\While_;
|
||||
final class NodeTypeGroup
|
||||
{
|
||||
/**
|
||||
* These nodes have a public $stmts property that can be iterated - based on https://github.com/rectorphp/php-parser-nodes-docs
|
||||
* @var array<class-string<Node>>
|
||||
* @api
|
||||
*/
|
||||
public const STMTS_AWARE = [ClassMethod::class, Function_::class, If_::class, Else_::class, ElseIf_::class, Do_::class, Foreach_::class, TryCatch::class, While_::class, For_::class, Closure::class, Finally_::class, Case_::class, Catch_::class];
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\DependencyInjection\NodeManipulator;
|
||||
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\PostRector\Collector\PropertyToAddCollector;
|
||||
use Rector\PostRector\ValueObject\PropertyMetadata;
|
||||
final class PropertyConstructorInjectionManipulator
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover
|
||||
*/
|
||||
private $phpDocTagRemover;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PostRector\Collector\PropertyToAddCollector
|
||||
*/
|
||||
private $propertyToAddCollector;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, PhpDocTagRemover $phpDocTagRemover, PropertyToAddCollector $propertyToAddCollector, BetterNodeFinder $betterNodeFinder)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
$this->phpDocTagRemover = $phpDocTagRemover;
|
||||
$this->propertyToAddCollector = $propertyToAddCollector;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
/**
|
||||
* @api symfony
|
||||
*/
|
||||
public function refactor(Property $property, Type $type, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void
|
||||
{
|
||||
$propertyName = $this->nodeNameResolver->getName($property);
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $type);
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineAnnotationTagValueNode);
|
||||
$class = $this->betterNodeFinder->findParentType($property, Class_::class);
|
||||
if (!$class instanceof Class_) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$propertyMetadata = new PropertyMetadata($propertyName, $type, $property->flags);
|
||||
$this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata);
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
use Rector\Naming\Naming\PropertyNaming;
|
||||
@ -63,9 +62,9 @@ final class FuncCallStaticCallToMethodCallAnalyzer
|
||||
/**
|
||||
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\Variable
|
||||
*/
|
||||
public function matchTypeProvidingExpr(Class_ $class, ClassMethod $classMethod, ObjectType $objectType, Scope $scope)
|
||||
public function matchTypeProvidingExpr(Class_ $class, ClassMethod $classMethod, ObjectType $objectType)
|
||||
{
|
||||
$expr = $this->typeProvidingExprFromClassResolver->resolveTypeProvidingExprFromClass($class, $classMethod, $objectType, $scope);
|
||||
$expr = $this->typeProvidingExprFromClassResolver->resolveTypeProvidingExprFromClass($class, $classMethod, $objectType);
|
||||
if ($expr instanceof Expr) {
|
||||
if ($expr instanceof Variable) {
|
||||
$this->addClassMethodParamForVariable($expr, $objectType, $classMethod);
|
||||
|
@ -9,7 +9,6 @@ use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Reflection\ParametersAcceptorSelector;
|
||||
@ -49,7 +48,7 @@ final class TypeProvidingExprFromClassResolver
|
||||
/**
|
||||
* @return MethodCall|PropertyFetch|Variable|null
|
||||
*/
|
||||
public function resolveTypeProvidingExprFromClass(Class_ $class, ClassMethod $classMethod, ObjectType $objectType, Scope $scope) : ?Expr
|
||||
public function resolveTypeProvidingExprFromClass(Class_ $class, ClassMethod $classMethod, ObjectType $objectType) : ?Expr
|
||||
{
|
||||
$className = (string) $this->nodeNameResolver->getName($class);
|
||||
// A. match a method
|
||||
@ -59,7 +58,7 @@ final class TypeProvidingExprFromClassResolver
|
||||
return $methodCallProvidingType;
|
||||
}
|
||||
// B. match existing property
|
||||
$propertyFetch = $this->resolvePropertyFetchProvidingType($classReflection, $scope, $objectType);
|
||||
$propertyFetch = $this->resolvePropertyFetchProvidingType($classReflection, $objectType);
|
||||
if ($propertyFetch instanceof PropertyFetch) {
|
||||
return $propertyFetch;
|
||||
}
|
||||
@ -80,12 +79,12 @@ final class TypeProvidingExprFromClassResolver
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function resolvePropertyFetchProvidingType(ClassReflection $classReflection, Scope $scope, ObjectType $objectType) : ?PropertyFetch
|
||||
private function resolvePropertyFetchProvidingType(ClassReflection $classReflection, ObjectType $objectType) : ?PropertyFetch
|
||||
{
|
||||
$nativeReflectionClass = $classReflection->getNativeReflection();
|
||||
foreach ($nativeReflectionClass->getProperties() as $reflectionProperty) {
|
||||
/** @var PhpPropertyReflection $phpPropertyReflection */
|
||||
$phpPropertyReflection = $classReflection->getProperty($reflectionProperty->getName(), $scope);
|
||||
$phpPropertyReflection = $classReflection->getNativeProperty($reflectionProperty->getName());
|
||||
$readableType = $phpPropertyReflection->getReadableType();
|
||||
if (!$this->isMatchingType($readableType, $objectType)) {
|
||||
continue;
|
||||
|
@ -6,10 +6,8 @@ namespace Rector\Transform\Rector\FuncCall;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer;
|
||||
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
@ -18,7 +16,7 @@ use RectorPrefix202306\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\Transform\Rector\FuncCall\FuncCallToMethodCallRector\FuncCallToMethodCallRectorTest
|
||||
*/
|
||||
final class FuncCallToMethodCallRector extends AbstractScopeAwareRector implements ConfigurableRectorInterface
|
||||
final class FuncCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
@ -70,30 +68,39 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [FuncCall::class];
|
||||
return [Class_::class];
|
||||
}
|
||||
/**
|
||||
* @param FuncCall $node
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$classLike = $this->betterNodeFinder->findParentType($node, Class_::class);
|
||||
if (!$classLike instanceof Class_) {
|
||||
return null;
|
||||
}
|
||||
$classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class);
|
||||
if (!$classMethod instanceof ClassMethod) {
|
||||
return null;
|
||||
}
|
||||
if ($classMethod->isStatic()) {
|
||||
return null;
|
||||
}
|
||||
foreach ($this->funcNameToMethodCallNames as $funcNameToMethodCallName) {
|
||||
if (!$this->isName($node->name, $funcNameToMethodCallName->getOldFuncName())) {
|
||||
$hasChanged = \false;
|
||||
$class = $node;
|
||||
foreach ($node->getMethods() as $classMethod) {
|
||||
if ($classMethod->isStatic()) {
|
||||
continue;
|
||||
}
|
||||
$expr = $this->funcCallStaticCallToMethodCallAnalyzer->matchTypeProvidingExpr($classLike, $classMethod, $funcNameToMethodCallName->getNewObjectType(), $scope);
|
||||
return $this->nodeFactory->createMethodCall($expr, $funcNameToMethodCallName->getNewMethodName(), $node->args);
|
||||
if ($classMethod->isAbstract()) {
|
||||
continue;
|
||||
}
|
||||
$this->traverseNodesWithCallable($classMethod, function (Node $node) use($class, $classMethod, &$hasChanged) : ?Node {
|
||||
if (!$node instanceof FuncCall) {
|
||||
return null;
|
||||
}
|
||||
foreach ($this->funcNameToMethodCallNames as $funcNameToMethodCallName) {
|
||||
if (!$this->isName($node->name, $funcNameToMethodCallName->getOldFuncName())) {
|
||||
continue;
|
||||
}
|
||||
$expr = $this->funcCallStaticCallToMethodCallAnalyzer->matchTypeProvidingExpr($class, $classMethod, $funcNameToMethodCallName->getNewObjectType());
|
||||
$hasChanged = \true;
|
||||
return $this->nodeFactory->createMethodCall($expr, $funcNameToMethodCallName->getNewMethodName(), $node->args);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,165 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Transform\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\NodeAnalyzer\PropertyPresenceChecker;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\PropertyNaming;
|
||||
use Rector\PostRector\Collector\PropertyToAddCollector;
|
||||
use Rector\PostRector\ValueObject\PropertyMetadata;
|
||||
use Rector\Transform\ValueObject\MethodCallToMethodCall;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202306\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\Transform\Rector\MethodCall\MethodCallToMethodCallRector\MethodCallToMethodCallRectorTest
|
||||
*/
|
||||
final class MethodCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\PropertyNaming
|
||||
*/
|
||||
private $propertyNaming;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeAnalyzer\PropertyPresenceChecker
|
||||
*/
|
||||
private $propertyPresenceChecker;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PostRector\Collector\PropertyToAddCollector
|
||||
*/
|
||||
private $propertyToAddCollector;
|
||||
/**
|
||||
* @var MethodCallToMethodCall[]
|
||||
*/
|
||||
private $methodCallsToMethodsCalls = [];
|
||||
public function __construct(PropertyNaming $propertyNaming, PropertyPresenceChecker $propertyPresenceChecker, PropertyToAddCollector $propertyToAddCollector)
|
||||
{
|
||||
$this->propertyNaming = $propertyNaming;
|
||||
$this->propertyPresenceChecker = $propertyPresenceChecker;
|
||||
$this->propertyToAddCollector = $propertyToAddCollector;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change method one method from one service to a method call to in another service', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function __construct(
|
||||
private FirstDependency $firstDependency
|
||||
) {
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->firstDependency->go();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function __construct(
|
||||
private SecondDependency $secondDependency
|
||||
) {
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->secondDependency->away();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, [new MethodCallToMethodCall('FirstDependency', 'go', 'SecondDependency', 'away')])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$class = $this->betterNodeFinder->findParentType($node, Class_::class);
|
||||
if (!$class instanceof Class_) {
|
||||
return null;
|
||||
}
|
||||
$isMethodCallCurrentClass = $this->isMethodCallCurrentClass($node);
|
||||
if (!$node->var instanceof PropertyFetch && !$isMethodCallCurrentClass) {
|
||||
return null;
|
||||
}
|
||||
foreach ($this->methodCallsToMethodsCalls as $methodCallToMethodCall) {
|
||||
if (!$this->isMatch($node, $methodCallToMethodCall, $isMethodCallCurrentClass, $class)) {
|
||||
continue;
|
||||
}
|
||||
$newPropertyName = $this->matchNewPropertyName($methodCallToMethodCall, $class);
|
||||
if ($newPropertyName === null) {
|
||||
continue;
|
||||
}
|
||||
/** @var PropertyFetch $propertyFetch */
|
||||
$propertyFetch = $isMethodCallCurrentClass ? $node : $node->var;
|
||||
$newObjectType = new ObjectType($methodCallToMethodCall->getNewType());
|
||||
$propertyMetadata = new PropertyMetadata($newPropertyName, $newObjectType, Class_::MODIFIER_PRIVATE);
|
||||
$this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata);
|
||||
// rename property
|
||||
$node->var = new PropertyFetch($propertyFetch->var, $newPropertyName);
|
||||
// rename method
|
||||
$node->name = new Identifier($methodCallToMethodCall->getNewMethod());
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
Assert::allIsAOf($configuration, MethodCallToMethodCall::class);
|
||||
$this->methodCallsToMethodsCalls = $configuration;
|
||||
}
|
||||
private function isMethodCallCurrentClass(MethodCall $methodCall) : bool
|
||||
{
|
||||
return $methodCall->var instanceof Variable && $methodCall->var->name === 'this';
|
||||
}
|
||||
private function isMatch(MethodCall $methodCall, MethodCallToMethodCall $methodCallToMethodCall, bool $isMethodCallCurrentClass, Class_ $class) : bool
|
||||
{
|
||||
$oldTypeObject = new ObjectType($methodCallToMethodCall->getOldType());
|
||||
if ($isMethodCallCurrentClass) {
|
||||
$className = (string) $this->nodeNameResolver->getName($class);
|
||||
$objectType = new ObjectType($className);
|
||||
if (!$objectType->equals($oldTypeObject)) {
|
||||
return \false;
|
||||
}
|
||||
return $this->isName($methodCall->name, $methodCallToMethodCall->getOldMethod());
|
||||
}
|
||||
if (!$this->isName($methodCall->name, $methodCallToMethodCall->getOldMethod())) {
|
||||
return \false;
|
||||
}
|
||||
return $this->isObjectType($methodCall->var, $oldTypeObject);
|
||||
}
|
||||
private function matchNewPropertyName(MethodCallToMethodCall $methodCallToMethodCall, Class_ $class) : ?string
|
||||
{
|
||||
$newPropertyName = $this->propertyNaming->fqnToVariableName($methodCallToMethodCall->getNewType());
|
||||
$propertyMetadata = new PropertyMetadata($newPropertyName, new ObjectType($methodCallToMethodCall->getNewType()), Class_::MODIFIER_PRIVATE);
|
||||
$classContextProperty = $this->propertyPresenceChecker->getClassContextProperty($class, $propertyMetadata);
|
||||
if ($classContextProperty === null) {
|
||||
return $newPropertyName;
|
||||
}
|
||||
// re-use existing property name
|
||||
return $this->getName($classContextProperty);
|
||||
}
|
||||
}
|
@ -100,7 +100,7 @@ CODE_SAMPLE
|
||||
if ($classMethod->isStatic()) {
|
||||
return $this->refactorToInstanceCall($node, $staticCallToMethodCall);
|
||||
}
|
||||
$expr = $this->funcCallStaticCallToMethodCallAnalyzer->matchTypeProvidingExpr($classLike, $classMethod, $staticCallToMethodCall->getClassObjectType(), $scope);
|
||||
$expr = $this->funcCallStaticCallToMethodCallAnalyzer->matchTypeProvidingExpr($classLike, $classMethod, $staticCallToMethodCall->getClassObjectType());
|
||||
if ($staticCallToMethodCall->getMethodName() === '*') {
|
||||
$methodName = $this->getName($node->name);
|
||||
} else {
|
||||
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Transform\ValueObject;
|
||||
|
||||
use Rector\Core\Validation\RectorAssert;
|
||||
final class MethodCallToMethodCall
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $oldType;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $oldMethod;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $newType;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $newMethod;
|
||||
public function __construct(string $oldType, string $oldMethod, string $newType, string $newMethod)
|
||||
{
|
||||
$this->oldType = $oldType;
|
||||
$this->oldMethod = $oldMethod;
|
||||
$this->newType = $newType;
|
||||
$this->newMethod = $newMethod;
|
||||
RectorAssert::className($oldType);
|
||||
RectorAssert::methodName($oldMethod);
|
||||
RectorAssert::className($newType);
|
||||
RectorAssert::methodName($newMethod);
|
||||
}
|
||||
public function getOldType() : string
|
||||
{
|
||||
return $this->oldType;
|
||||
}
|
||||
public function getOldMethod() : string
|
||||
{
|
||||
return $this->oldMethod;
|
||||
}
|
||||
public function getNewType() : string
|
||||
{
|
||||
return $this->newType;
|
||||
}
|
||||
public function getNewMethod() : string
|
||||
{
|
||||
return $this->newMethod;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '2c13033108f884fb007ccfa74d29e85cc726b985';
|
||||
public const PACKAGE_VERSION = '059783fb07cbe5bd2259d4634d32f563ce862de0';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-08 22:29:53';
|
||||
public const RELEASE_DATE = '2023-06-08 22:49:04';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ final class RectorKernel
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CACHE_KEY = 'v76';
|
||||
private const CACHE_KEY = 'v77';
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface|null
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65::getLoader();
|
||||
return ComposerAutoloaderInit9d050947f5c31944d244056faf973a5a::getLoader();
|
||||
|
4
vendor/composer/autoload_classmap.php
vendored
4
vendor/composer/autoload_classmap.php
vendored
@ -1362,7 +1362,6 @@ return array(
|
||||
'Rector\\CodeQuality\\NodeFactory\\MissingPropertiesFactory' => $baseDir . '/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php',
|
||||
'Rector\\CodeQuality\\NodeFactory\\PropertyTypeDecorator' => $baseDir . '/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php',
|
||||
'Rector\\CodeQuality\\NodeManipulator\\ExprBoolCaster' => $baseDir . '/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php',
|
||||
'Rector\\CodeQuality\\NodeTypeGroup' => $baseDir . '/rules/CodeQuality/NodeTypeGroup.php',
|
||||
'Rector\\CodeQuality\\Rector\\Array_\\CallableThisArrayToAnonymousFunctionRector' => $baseDir . '/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => $baseDir . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
|
||||
@ -1758,7 +1757,6 @@ return array(
|
||||
'Rector\\DeadCode\\ValueObject\\VariableAndPropertyFetchAssign' => $baseDir . '/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php',
|
||||
'Rector\\DeadCode\\ValueObject\\VersionCompareCondition' => $baseDir . '/rules/DeadCode/ValueObject/VersionCompareCondition.php',
|
||||
'Rector\\Defluent\\NodeAnalyzer\\FluentChainMethodCallNodeAnalyzer' => $baseDir . '/packages/Defluent/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php',
|
||||
'Rector\\DependencyInjection\\NodeManipulator\\PropertyConstructorInjectionManipulator' => $baseDir . '/rules/DependencyInjection/NodeManipulator/PropertyConstructorInjectionManipulator.php',
|
||||
'Rector\\DependencyInjection\\Rector\\ClassMethod\\AddMethodParentCallRector' => $baseDir . '/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AssignPropertyFetchAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php',
|
||||
@ -2739,7 +2737,6 @@ return array(
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToNewRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php',
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToStaticCallRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToFuncCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToStaticCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\ReplaceParentCallByPropertyCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php',
|
||||
@ -2754,7 +2751,6 @@ return array(
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/FuncCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToStaticCall' => $baseDir . '/rules/Transform/ValueObject/FuncCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToFuncCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToFuncCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToPropertyFetch' => $baseDir . '/rules/Transform/ValueObject/MethodCallToPropertyFetch.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToStaticCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\NewArgToMethodCall' => $baseDir . '/rules/Transform/ValueObject/NewArgToMethodCall.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65
|
||||
class ComposerAutoloaderInit9d050947f5c31944d244056faf973a5a
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9d050947f5c31944d244056faf973a5a', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitabbd4d71331eac28853a6c6f03eeca65', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9d050947f5c31944d244056faf973a5a', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9d050947f5c31944d244056faf973a5a::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit9d050947f5c31944d244056faf973a5a::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
12
vendor/composer/autoload_static.php
vendored
12
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65
|
||||
class ComposerStaticInit9d050947f5c31944d244056faf973a5a
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -1613,7 +1613,6 @@ class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65
|
||||
'Rector\\CodeQuality\\NodeFactory\\MissingPropertiesFactory' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php',
|
||||
'Rector\\CodeQuality\\NodeFactory\\PropertyTypeDecorator' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php',
|
||||
'Rector\\CodeQuality\\NodeManipulator\\ExprBoolCaster' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php',
|
||||
'Rector\\CodeQuality\\NodeTypeGroup' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeTypeGroup.php',
|
||||
'Rector\\CodeQuality\\Rector\\Array_\\CallableThisArrayToAnonymousFunctionRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
|
||||
@ -2009,7 +2008,6 @@ class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65
|
||||
'Rector\\DeadCode\\ValueObject\\VariableAndPropertyFetchAssign' => __DIR__ . '/../..' . '/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php',
|
||||
'Rector\\DeadCode\\ValueObject\\VersionCompareCondition' => __DIR__ . '/../..' . '/rules/DeadCode/ValueObject/VersionCompareCondition.php',
|
||||
'Rector\\Defluent\\NodeAnalyzer\\FluentChainMethodCallNodeAnalyzer' => __DIR__ . '/../..' . '/packages/Defluent/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php',
|
||||
'Rector\\DependencyInjection\\NodeManipulator\\PropertyConstructorInjectionManipulator' => __DIR__ . '/../..' . '/rules/DependencyInjection/NodeManipulator/PropertyConstructorInjectionManipulator.php',
|
||||
'Rector\\DependencyInjection\\Rector\\ClassMethod\\AddMethodParentCallRector' => __DIR__ . '/../..' . '/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AssignPropertyFetchAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php',
|
||||
@ -2990,7 +2988,6 @@ class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToNewRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php',
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToFuncCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\ReplaceParentCallByPropertyCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php',
|
||||
@ -3005,7 +3002,6 @@ class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/FuncCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/FuncCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToFuncCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToFuncCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToPropertyFetch' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToPropertyFetch.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\NewArgToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/NewArgToMethodCall.php',
|
||||
@ -3142,9 +3138,9 @@ class ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitabbd4d71331eac28853a6c6f03eeca65::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9d050947f5c31944d244056faf973a5a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9d050947f5c31944d244056faf973a5a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9d050947f5c31944d244056faf973a5a::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user