File tree Expand file tree Collapse file tree 6 files changed +104
-4
lines changed
Expand file tree Collapse file tree 6 files changed +104
-4
lines changed Original file line number Diff line number Diff line change 1414 actions :
1515 -
1616 name : ' Rector dev + PHPUnit 12 global for Rector'
17- run : composer require --dev "rector/rector:dev-main" -W
17+ run : composer require --dev "rector/rector:dev-main as 2.2.6 " -W
1818 php : 8.3
1919
2020 name : ${{ matrix.actions.name }}
Original file line number Diff line number Diff line change 1+ # see https://github.com/rectorphp/rector/issues/9470#issuecomment-3453388719
2+ name : Rector Laravel and PHP Parser
3+
4+ on :
5+ pull_request : null
6+ push :
7+ branches :
8+ - main
9+
10+ jobs :
11+ compat_tests :
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - uses : actions/checkout@v4
16+
17+ -
18+ uses : shivammathur/setup-php@v2
19+ with :
20+ php-version : " 8.2"
21+ coverage : none
22+
23+ - uses : " ramsey/composer-install@v2"
24+
25+ - run : composer require "phpunit/phpunit:11.*" -W
26+
27+ - run : vendor/bin/rector p fixture --debug --clear-cache
Original file line number Diff line number Diff line change 44 "require-dev" : {
55 "php" : " ^8.2" ,
66 "phpunit/phpunit" : " 10.*|11.*|12.*" ,
7- "rector/rector" : " dev-main" ,
8- "phpstan/phpstan" : " ^2.1"
7+ "nikic/php-parser" : " 5.4.*" ,
8+ "rector/rector" : " dev-main as 2.2.6" ,
9+ "phpstan/phpstan" : " 2.1.*" ,
10+ "driftingly/rector-laravel" : " ^2.1"
911 },
1012 "autoload" : {
1113 "psr-4" : {
1416 },
1517 "autoload-dev" : {
1618 "psr-4" : {
17- "Rector\\ RectorCompatTests\\ Tests\\ " : " tests"
19+ "Rector\\ RectorCompatTests\\ Tests\\ " : " tests" ,
20+ "Fixture\\ " : " fixture"
1821 }
1922 }
2023}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Fixture ;
4+
5+ final class FixtureWithFuncCall
6+ {
7+ public function run (): int
8+ {
9+ return strlen ('hello ' );
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Rector \Config \RectorConfig ;
6+ use Rector \RectorCompatTests \Rector \UseGetArgRector ;
7+ use RectorLaravel \Set \LaravelSetList ;
8+
9+ return RectorConfig::configure ()
10+ ->withPaths ([
11+ __DIR__ . '/src ' ,
12+ __DIR__ . '/tests ' ,
13+ __DIR__ . '/fixture ' ,
14+ ])
15+ ->withRules ([UseGetArgRector::class])
16+ ->withTypeCoverageLevel (0 )
17+ ->withDeadCodeLevel (0 )
18+ ->withCodeQualityLevel (0 );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \RectorCompatTests \Rector ;
6+
7+ use PhpParser \Modifiers ;
8+ use PhpParser \Node ;
9+ use PhpParser \Node \Arg ;
10+ use PhpParser \Node \Expr \FuncCall ;
11+ use PhpParser \Node \Scalar \String_ ;
12+ use PhpParser \Node \Stmt \Class_ ;
13+ use PhpParser \Node \Stmt \Function_ ;
14+ use Rector \Rector \AbstractRector ;
15+
16+ final class UseGetArgRector extends AbstractRector
17+ {
18+ /**
19+ * @return array<class-string<Class_>>
20+ */
21+ public function getNodeTypes (): array
22+ {
23+ return [FuncCall::class];
24+ }
25+
26+ /**
27+ * @param FuncCall $node
28+ */
29+ public function refactor (Node $ node )
30+ {
31+ // 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+ }
36+
37+ $ firstArg ->value = new String_ ('changed_value ' );
38+
39+ return $ node ;
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments