Skip to content

Commit bd3e6e7

Browse files
committed
use newer laravel rector version
1 parent 7d2e0a8 commit bd3e6e7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"php": "^8.2",
66
"phpunit/phpunit": "10.*|11.*|12.*",
77
"nikic/php-parser": "5.4.*",
8-
"rector/rector": "dev-main",
8+
"rector/rector": "dev-main as 2.2.6",
99
"phpstan/phpstan": "2.1.*",
10-
"driftingly/rector-laravel": "^0.27.0"
10+
"driftingly/rector-laravel": "^2.1"
1111
},
1212
"autoload": {
1313
"psr-4": {

rector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44

55
use Rector\Config\RectorConfig;
66
use Rector\RectorCompatTests\Rector\UseGetArgRector;
7+
use RectorLaravel\Set\LaravelSetList;
78

89
return RectorConfig::configure()
910
->withPaths([
1011
__DIR__ . '/src',
1112
__DIR__ . '/tests',
1213
__DIR__ . '/fixture',
1314
])
15+
->withSets([
16+
LaravelSetList::LARAVEL_110,
17+
LaravelSetList::LARAVEL_CODE_QUALITY,
18+
])
1419
// uncomment to reach your current PHP version
1520
// ->withPhpSets()
1621
->withRules([UseGetArgRector::class])

src/Rector/UseGetArgRector.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
use PhpParser\Modifiers;
88
use PhpParser\Node;
9+
use PhpParser\Node\Arg;
910
use PhpParser\Node\Expr\FuncCall;
11+
use PhpParser\Node\Scalar\String_;
1012
use PhpParser\Node\Stmt\Class_;
1113
use PhpParser\Node\Stmt\Function_;
1214
use Rector\Rector\AbstractRector;
@@ -27,7 +29,13 @@ public function getNodeTypes(): array
2729
public function refactor(Node $node)
2830
{
2931
// here we should load Rector's php-parser 5.6, that already has getArg() method
32+
$firstArg = $node->getArg('', 0);
33+
if (! $firstArg instanceof Arg) {
34+
return null;;
35+
}
3036

31-
return $node->getArg('name', 5);
37+
$firstArg->value = new String_('changed_value');
38+
39+
return $node;
3240
}
3341
}

0 commit comments

Comments
 (0)