Skip to content

Commit 003b1e4

Browse files
committed
add Rector
1 parent 9fce3d6 commit 003b1e4

3 files changed

Lines changed: 54 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,35 @@ jobs:
4545

4646
- name: Tests
4747
run: composer test
48+
49+
rector:
50+
name: Rector
51+
runs-on: ubuntu-latest
52+
53+
strategy:
54+
matrix:
55+
php:
56+
- 8.4
57+
fail-fast: false
58+
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Install PHP
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: ${{ matrix.php }}
67+
68+
- name: Cache PHP dependencies
69+
uses: actions/cache@v4
70+
with:
71+
path: vendor
72+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
73+
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
74+
75+
- name: Install dependencies
76+
run: composer install --prefer-dist --no-progress --no-suggest
77+
78+
- name: Tests
79+
run: vendor/bin/rector process --dry-run

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"phpunit/phpunit": "^8.0",
2727
"squizlabs/php_codesniffer": "^3.0",
2828
"oscarotero/php-cs-fixer-config": "^1.0",
29-
"friendsofphp/php-cs-fixer": "^2.15"
29+
"friendsofphp/php-cs-fixer": "^2.15",
30+
"rector/rector": "^1|^2"
3031
},
3132
"autoload": {
3233
"psr-4": {
@@ -43,6 +44,7 @@
4344
"phpunit",
4445
"phpcs"
4546
],
46-
"cs-fix": "php-cs-fixer fix"
47+
"cs-fix": "php-cs-fixer fix",
48+
"rector": "rector process"
4749
}
4850
}

rector.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\SetList;
7+
8+
return RectorConfig::configure()
9+
->withPaths([
10+
__DIR__ . '/src',
11+
__DIR__ . '/tests',
12+
])
13+
->withPhpSets()
14+
->withPreparedSets(typeDeclarations: true)
15+
->withDeadCodeLevel(2)
16+
->withCodeQualityLevel(10)
17+
->withCodingStyleLevel(0)
18+
;

0 commit comments

Comments
 (0)