Skip to content

Commit bd8565d

Browse files
committed
Add Rector
This will help us keep ahead of deprecations and help us write more modern code when we contribute, teaching some about newer ways PHP can do certain things
1 parent 1c07521 commit bd8565d

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

.github/workflows/checks.yml

+17
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,20 @@ jobs:
7373

7474
- name: Run mess detector
7575
run: composer phpmd
76+
77+
rector:
78+
runs-on: ubuntu-latest
79+
name: Rector
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Setup
86+
uses: ./.github/actions/setup
87+
with:
88+
php_version: 8.3
89+
laravel_version: 11
90+
91+
- name: Run mess detector
92+
run: composer rector

composer.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"orchestra/testbench": "^8.0|^9.0",
7272
"phpmd/phpmd": "^2.15",
7373
"phpunit/phpunit": "^10.0|^11.0",
74+
"rector/rector": "^1.2",
7475
"squizlabs/php_codesniffer": "^3.10"
7576
},
7677
"suggest": {
@@ -85,14 +86,18 @@
8586
"scripts": {
8687
"standards:check": [
8788
"@phpcs",
88-
"@phpmd"
89+
"@phpmd",
90+
"@rector"
8991
],
9092
"standards:fix": [
91-
"@phpcs:fix"
93+
"@phpcs:fix",
94+
"@rector:fix"
9295
],
9396
"test": "phpunit",
9497
"phpcs": "./vendor/bin/phpcs --standard=PSR12 --ignore=vendor .",
9598
"phpcs:fix": "./vendor/bin/phpcbf --standard=PSR12 --ignore=vendor .",
96-
"phpmd": "./vendor/bin/phpmd . github .phpmd/ruleset.xml --color"
99+
"phpmd": "./vendor/bin/phpmd . github .phpmd/ruleset.xml --color",
100+
"rector": "./vendor/bin/rector process --dry-run",
101+
"rector:fix": "./vendor/bin/rector process"
97102
}
98103
}

rector.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
4+
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
5+
use Rector\Config\RectorConfig;
6+
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
7+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
8+
9+
return RectorConfig::configure()
10+
->withPaths([
11+
__DIR__ . '/',
12+
])
13+
->withSkip([
14+
__DIR__ . '/vendor',
15+
])
16+
->withSkip([
17+
AddOverrideAttributeToOverriddenMethodsRector::class,
18+
JoinStringConcatRector::class,
19+
SimplifyEmptyCheckOnEmptyArrayRector::class,
20+
DisallowedEmptyRuleFixerRector::class
21+
])
22+
->withPhpSets()
23+
->withPreparedSets(
24+
true,
25+
true,
26+
false,
27+
true
28+
);

0 commit comments

Comments
 (0)