mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 04:03:55 +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;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Nop;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\NodeTraverser;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\Rector\AbstractRector;
|
||||
|
||||
final class FluentReplaceRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var string[][]
|
||||
*/
|
||||
private $relatedTypesAndMethods;
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
if (! $node instanceof Return_) {
|
||||
@ -30,6 +33,12 @@ final class FluentReplaceRector extends AbstractRector
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$this->removeNode = true;
|
||||
|
||||
$className = $node->getAttribute(Attribute::CLASS_NAME);
|
||||
$methodName = $node->getAttribute(Attribute::METHOD_NAME);
|
||||
|
||||
$this->relatedTypesAndMethods[$className][] = $methodName;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class ActionClass
|
||||
{
|
||||
$this->someClass = new SomeClass();
|
||||
|
||||
$this->someClass->someFunction()
|
||||
$this->someClass->someFunction();
|
||||
$this->someClass->otherFunction();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user