-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathInfinityLoopRector.php
More file actions
48 lines (40 loc) · 1.17 KB
/
InfinityLoopRector.php
File metadata and controls
48 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace Rector\Tests\Issues\InfiniteLoop\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\NodeVisitor;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\Issues\InfiniteLoop\InfiniteLoopTest
*/
final class InfinityLoopRector extends AbstractRector
{
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes(): array
{
return [Assign::class, MethodCall::class];
}
/**
* @param Assign|MethodCall $node
* @return Assign|int|null|NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
*/
public function refactor(Node $node): Assign|null|int
{
if ($node instanceof Assign) {
return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
if (! $this->isName($node->name, 'modify')) {
return null;
}
return new Assign($node->var, $node);
}
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Road to left... to left... to lefthell..', []);
}
}