mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 12:14:02 +01:00
add relatedTypesAndMethods property to collect defluented methods
This commit is contained in:
parent
4cff4cede5
commit
4ca2743a29
@ -3,15 +3,18 @@
|
|||||||
namespace Rector\Rector\Dynamic;
|
namespace Rector\Rector\Dynamic;
|
||||||
|
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Stmt\Nop;
|
|
||||||
use PhpParser\Node\Stmt\Return_;
|
use PhpParser\Node\Stmt\Return_;
|
||||||
use PhpParser\Node\Expr\Variable;
|
use PhpParser\Node\Expr\Variable;
|
||||||
use PhpParser\NodeTraverser;
|
|
||||||
use Rector\Node\Attribute;
|
use Rector\Node\Attribute;
|
||||||
use Rector\Rector\AbstractRector;
|
use Rector\Rector\AbstractRector;
|
||||||
|
|
||||||
final class FluentReplaceRector extends AbstractRector
|
final class FluentReplaceRector extends AbstractRector
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string[][]
|
||||||
|
*/
|
||||||
|
private $relatedTypesAndMethods;
|
||||||
|
|
||||||
public function isCandidate(Node $node): bool
|
public function isCandidate(Node $node): bool
|
||||||
{
|
{
|
||||||
if (! $node instanceof Return_) {
|
if (! $node instanceof Return_) {
|
||||||
@ -30,6 +33,12 @@ final class FluentReplaceRector extends AbstractRector
|
|||||||
public function refactor(Node $node): ?Node
|
public function refactor(Node $node): ?Node
|
||||||
{
|
{
|
||||||
$this->removeNode = true;
|
$this->removeNode = true;
|
||||||
|
|
||||||
|
$className = $node->getAttribute(Attribute::CLASS_NAME);
|
||||||
|
$methodName = $node->getAttribute(Attribute::METHOD_NAME);
|
||||||
|
|
||||||
|
$this->relatedTypesAndMethods[$className][] = $methodName;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class ActionClass
|
|||||||
{
|
{
|
||||||
$this->someClass = new SomeClass();
|
$this->someClass = new SomeClass();
|
||||||
|
|
||||||
$this->someClass->someFunction()
|
$this->someClass->someFunction();
|
||||||
$this->someClass->otherFunction();
|
$this->someClass->otherFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user