-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUseGetArgRector.php
More file actions
41 lines (34 loc) · 908 Bytes
/
UseGetArgRector.php
File metadata and controls
41 lines (34 loc) · 908 Bytes
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
<?php
declare(strict_types=1);
namespace Rector\RectorCompatTests\Rector;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Function_;
use Rector\Rector\AbstractRector;
final class UseGetArgRector extends AbstractRector
{
/**
* @return array<class-string<Class_>>
*/
public function getNodeTypes(): array
{
return [FuncCall::class];
}
/**
* @param FuncCall $node
*/
public function refactor(Node $node)
{
// here we should load Rector's php-parser 5.6, that already has getArg() method
$firstArg = $node->getArg('', 0);
if (! $firstArg instanceof Arg) {
return null;;
}
$firstArg->value = new String_('changed_value');
return $node;
}
}