Skip to content

Commit 0ea9bf8

Browse files
committed
Add rector to CI
1 parent 8b2a549 commit 0ea9bf8

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ jobs:
4444
matrix:
4545
php:
4646
- version: "8.0"
47-
phpunit: "9"
47+
phpunit: "9"
48+
args: ""
4849
- version: "8.1"
4950
phpunit: "10"
51+
args: ""
5052
- version: "8.2"
5153
phpunit: "10"
54+
args: ""
5255
- version: "8.3"
53-
phpunit: "10"
56+
phpunit: "11"
57+
args: ""
58+
- version: "8.4"
59+
phpunit: "12"
60+
args: --display-deprecations --display-phpunit-deprecations
5461

5562
name: "Test: PHP ${{ matrix.php.version }}"
5663

@@ -72,4 +79,21 @@ jobs:
7279
version: "${{ matrix.php.phpunit }}"
7380
php_version: "${{ matrix.php.version }}"
7481
php_extensions: xdebug
75-
args: --coverage-text
82+
args: "--coverage-text ${{ matrix.php.args }}"
83+
84+
rector:
85+
runs-on: ubuntu-latest
86+
name: Rector
87+
88+
steps:
89+
- uses: actions/checkout@v5
90+
- name: Cache Composer dependencies
91+
uses: actions/cache@v4
92+
with:
93+
path: /tmp/composer-cache
94+
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
95+
- uses: php-actions/composer@v6
96+
with:
97+
php_version: "8.4"
98+
- name: Check compatibility
99+
run: composer rector

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
"nerou/cli-parser": "^0.1"
1919
},
2020
"require-dev": {
21-
"squizlabs/php_codesniffer": "^4.0",
22-
"humbug/box": "^3.16 || ^4.0"
21+
"humbug/box": "^3.16 || ^4.0",
22+
"rector/rector": "^2.0",
23+
"squizlabs/php_codesniffer": "^4.0"
2324
},
2425
"prefer-stable": true,
2526
"autoload": {
@@ -37,12 +38,14 @@
3738
"phpcpd": "./tools/phpcpd src",
3839
"psalm": "./tools/psalm --no-diff --use-baseline=psalm.baseline.xml --php-version=8.1",
3940
"update-psalm-baseline": "./tools/psalm --no-diff --set-baseline=psalm.baseline.xml",
41+
"rector": "./vendor/bin/rector process --dry-run",
4042
"build": "./vendor/bin/box compile",
4143
"tests": [
4244
"@phpcs",
4345
"@phpunit",
4446
"@phpcpd",
45-
"@psalm"
47+
"@psalm",
48+
"@rector"
4649
]
4750
},
4851
"scripts-descriptions": {
@@ -51,9 +54,8 @@
5154
"phpunit": "Runs unit/integration tests.",
5255
"phpcpd": "Runs copied code finder.",
5356
"psalm": "Runs static analysis.",
54-
"psalm-stats": "Print files with unsafe types based on psalm.",
5557
"update-psalm-baseline": "Updates baseline for psalm. CAUTION should not be run as a regular procedure!",
56-
"lines": "Gathers statistics about lines of code.",
58+
"rector": "Runs PHP compatibility checks and code smell analysis.",
5759
"build": "Build PHAR",
5860
"tests": "Runs all available tests."
5961
}

rector.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Rector\Config\RectorConfig;
5+
use Rector\ValueObject\PhpVersion;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->paths([
10+
__DIR__.'/src',
11+
__DIR__.'/test'
12+
]);
13+
14+
$rectorConfig->phpVersion(PhpVersion::PHP_85);
15+
16+
$rectorConfig->sets([
17+
LevelSetList::UP_TO_PHP_80
18+
]);
19+
};

0 commit comments

Comments
 (0)