mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-27 05:03:31 +00:00
Collect method call renames for future usage (#6149)
This commit is contained in:
parent
27f3544e8e
commit
be2a54e0b9
|
@ -280,6 +280,7 @@ parameters:
|
|||
paths:
|
||||
- bin/rector.php
|
||||
- rules/Php70/Rector/FuncCall/MultiDirnameRector.php
|
||||
- src/Application/FileProcessor/PhpFileProcessor.php
|
||||
|
||||
-
|
||||
message: '#Function "class_exists\(\)" cannot be used/left in the code#'
|
||||
|
@ -513,11 +514,6 @@ parameters:
|
|||
paths:
|
||||
- src/PhpParser/Parser/FunctionLikeParser.php
|
||||
|
||||
-
|
||||
message: '#Unreachable statement \- code above always terminates#'
|
||||
paths:
|
||||
- src/Application/FileProcessor/PhpFileProcessor.php
|
||||
|
||||
-
|
||||
message: '#Property with protected modifier is not allowed\. Use interface contract method instead#'
|
||||
paths:
|
||||
|
|
26
rules/Renaming/Collector/MethodCallRenameCollector.php
Normal file
26
rules/Renaming/Collector/MethodCallRenameCollector.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Renaming\Collector;
|
||||
|
||||
use Rector\Renaming\Contract\MethodCallRenameInterface;
|
||||
|
||||
final class MethodCallRenameCollector
|
||||
{
|
||||
/**
|
||||
* @var MethodCallRenameInterface[]
|
||||
*/
|
||||
private $methodCallRenames = [];
|
||||
|
||||
public function addMethodCallRename(MethodCallRenameInterface $methodCallRename): void
|
||||
{
|
||||
$this->methodCallRenames[] = $methodCallRename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MethodCallRenameInterface[]
|
||||
*/
|
||||
public function getMethodCallRenames(): array
|
||||
{
|
||||
return $this->methodCallRenames;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
|||
use Rector\Core\NodeManipulator\ClassManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Renaming\Collector\MethodCallRenameCollector;
|
||||
use Rector\Renaming\Contract\MethodCallRenameInterface;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey;
|
||||
|
@ -44,9 +45,15 @@ final class RenameMethodRector extends AbstractRector implements ConfigurableRec
|
|||
*/
|
||||
private $classManipulator;
|
||||
|
||||
public function __construct(ClassManipulator $classManipulator)
|
||||
/**
|
||||
* @var MethodCallRenameCollector
|
||||
*/
|
||||
private $methodCallRenameCollector;
|
||||
|
||||
public function __construct(ClassManipulator $classManipulator, MethodCallRenameCollector $methodCallRenameCollector)
|
||||
{
|
||||
$this->classManipulator = $classManipulator;
|
||||
$this->methodCallRenameCollector = $methodCallRenameCollector;
|
||||
}
|
||||
|
||||
public function getRuleDefinition(): RuleDefinition
|
||||
|
@ -130,6 +137,10 @@ CODE_SAMPLE
|
|||
Assert::allIsInstanceOf($methodCallRenames, MethodCallRenameInterface::class);
|
||||
|
||||
$this->methodCallRenames = $methodCallRenames;
|
||||
|
||||
foreach ($methodCallRenames as $methodCallRename) {
|
||||
$this->methodCallRenameCollector->addMethodCallRename($methodCallRename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user