Skip to content

Commit 8a2fc62

Browse files
committed
Added downgrade sets for Rector, targetting PHP 7.4 and Symfony 5
1 parent b6002ac commit 8a2fc62

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

.github/workflows/code_samples.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
name: Validate code samples
99
runs-on: "ubuntu-22.04"
1010
strategy:
11+
fail-fast: false
1112
matrix:
1213
php:
1314
- "8.4" # Upper supported version
@@ -47,6 +48,12 @@ jobs:
4748

4849
- name: Run PHPStan analysis
4950
run: composer phpstan
51+
52+
- if: matrix.php == '8.4' # ibexa/rector supports PHP 8.3 and higher
53+
name: Run Rector check
54+
run: |
55+
composer require --dev ibexa/rector:~4.6.x-dev
56+
composer check-rector
5057
5158
code-samples-inclusion-check:
5259
name: Check code samples inclusion

composer.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"url": "https://updates.ibexa.co"
1212
}
1313
],
14+
"require": {
15+
"php": "^7.4 || ^8.0"
16+
},
1417
"require-dev": {
1518
"ibexa/automated-translation": "4.6.x-dev",
1619
"ibexa/code-style": "^1.0",
@@ -82,7 +85,14 @@
8285
"scripts": {
8386
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
8487
"check-cs": "@fix-cs --dry-run",
85-
"phpstan": "phpstan analyse"
88+
"phpstan": "phpstan analyse",
89+
"check-rector": "rector process --dry-run --ansi"
90+
},
91+
"suggest": {
92+
"ibexa/rector": "Add Rector to check for code refactoring opportunities"
93+
},
94+
"scripts-descriptions": {
95+
"check-rector": "Check for code refactoring opportunities"
8696
},
8797
"config": {
8898
"allow-plugins": false

rector.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
use Rector\Config\RectorConfig;
10+
use Ibexa\Contracts\Rector\Sets\IbexaSetList;
11+
use Rector\Symfony\DowngradeSymfony70\Rector\Class_\DowngradeSymfonyCommandAttributeRector;
12+
use Rector\DowngradePhp82\Rector\FuncCall\DowngradeIteratorCountToArrayRector;
13+
14+
return RectorConfig::configure()
15+
->withPaths([
16+
__DIR__ . '/code_samples',
17+
])
18+
->withSkip([
19+
DowngradeIteratorCountToArrayRector::class,
20+
])
21+
->withSets([
22+
IbexaSetList::IBEXA_46->value,
23+
])
24+
->withDowngradeSets(php74: true)
25+
->withRules([
26+
DowngradeSymfonyCommandAttributeRector::class,
27+
]);

0 commit comments

Comments
 (0)