File tree Expand file tree Collapse file tree
custom-rules-annotations/utils/rector/tests/Rector/__Name__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Utils \Rector \Rector ;
6+
7+ use PhpParser \Node ;
8+ use Rector \Rector \AbstractRector ;
9+
10+ /**
11+ * @see \Rector\Tests\TypeDeclaration\Rector\__Name__\__Name__Test
12+ */
13+ final class __Name__ extends AbstractRector
14+ {
15+ /**
16+ * @return array<class-string<Node>>
17+ */
18+ public function getNodeTypes (): array
19+ {
20+ // @todo select node type
21+ return [\PhpParser \Node \Stmt \Class_::class];
22+ }
23+
24+ /**
25+ * @param \PhpParser\Node\Stmt\Class_ $node
26+ */
27+ public function refactor (Node $ node ): ?Node
28+ {
29+ // @todo change the node
30+
31+ return $ node ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclaration \Rector \__Name__ \Fixture ;
4+
5+ // @todo fill code before
6+
7+ ?>
8+ -----
9+ <?php
10+
11+ namespace Rector \Tests \TypeDeclaration \Rector \__Name__ \Fixture ;
12+
13+ // @todo fill code after
14+
15+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \TypeDeclaration \Rector \__Name__ ;
6+
7+ use PHPUnit \Framework \Attributes \DataProvider ;
8+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
9+
10+ final class __Name__Test extends AbstractRectorTestCase
11+ {
12+ #[DataProvider('provideData ' )]
13+ public function test (string $ filePath ): void
14+ {
15+ $ this ->doTestFile ($ filePath );
16+ }
17+
18+ public static function provideData (): \Iterator
19+ {
20+ return self ::yieldFilesFromDirectory (__DIR__ . '/Fixture ' );
21+ }
22+
23+ public function provideConfigFilePath (): string
24+ {
25+ return __DIR__ . '/config/configured_rule.php ' ;
26+ }
27+ }
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+
7+ return static function (RectorConfig $ rectorConfig ): void {
8+ $ rectorConfig ->rule (\Utils \Rector \Rector \__Name__::class);
9+ };
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \TypeDeclaration \Rector \__Name__ ;
6+
7+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
8+
9+ final class __Name__Test extends AbstractRectorTestCase
10+ {
11+ /**
12+ * @dataProvider provideData()
13+ */
14+ public function test (string $ filePath ): void
15+ {
16+ $ this ->doTestFile ($ filePath );
17+ }
18+
19+ public static function provideData (): \Iterator
20+ {
21+ return self ::yieldFilesFromDirectory (__DIR__ . '/Fixture ' );
22+ }
23+
24+ public function provideConfigFilePath (): string
25+ {
26+ return __DIR__ . '/config/configured_rule.php ' ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ # github action that checks code with Rector
2+ name : Rector
3+
4+ on :
5+ pull_request : null
6+
7+ jobs :
8+ rector :
9+ runs-on : ubuntu-latest
10+ if : github.event.pull_request.head.repo.full_name == '__CURRENT_REPOSITORY__'
11+ steps :
12+ -
13+ if : github.event.pull_request.head.repo.full_name == github.repository
14+ uses : actions/checkout@v4
15+ with :
16+ # Must be used to trigger workflow after push
17+ token : ${{ secrets.ACCESS_TOKEN }}
18+
19+ -
20+ uses : shivammathur/setup-php@v2
21+ with :
22+ php-version : 8.2
23+ coverage : none
24+
25+ - uses : " ramsey/composer-install@v3"
26+
27+ - run : vendor/bin/rector --ansi
28+ # @todo apply coding standard if used
29+
30+ -
31+ # commit only to core contributors who have repository access
32+ uses : stefanzweifel/git-auto-commit-action@v5
33+ with :
34+ commit_message : ' [rector] Rector fixes'
35+ commit_author :
' GitHub Action <[email protected] >' 36+ commit_user_email :
' [email protected] '
Original file line number Diff line number Diff line change 1+ stages :
2+ - setup
3+ - rector
4+ - commit_changes
5+
6+ setup :
7+ stage : setup
8+ # see https://github.com/thecodingmachine/docker-images-php
9+ image : thecodingmachine/php:8.2-v4-slim-cli
10+
11+ rector :
12+ stage : rector
13+ script :
14+ - vendor/bin/rector --ansi
15+ # @todo apply coding standard if used
16+
17+ commit_changes :
18+ stage : commit_changes
19+ script :
20+ -
git config --global user.email "[email protected] " 21+ - git config --global user.name "GitLab CI
22+ # - git checkout $CI_COMMIT_REF_NAME
23+ - git add .
24+ - git commit -m "[rector] Rector fixes"
25+ - git push origin $CI_COMMIT_REF_NAME
26+ only :
27+ - merge_requests
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+
7+ return RectorConfig::configure()
8+ ->withPaths([
9+ __PATHS__
10+ ])
11+ // uncomment to reach your current PHP version
12+ // ->withPhpSets()
13+ ->withTypeCoverageLevel(0)
14+ ->withDeadCodeLevel(0)
15+ ->withCodeQualityLevel(0);
You can’t perform that action at this time.
0 commit comments