Skip to content

Commit 27548e2

Browse files
authored
[TASK] Use Rector in CI workflow (#25)
1 parent e61b27a commit 27548e2

15 files changed

+137
-60
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
paths-ignore:
99
- '.ddev/**'
1010
schedule:
11-
- cron: '44 4 * * *'
11+
- cron: '44 4 * * *'
1212

1313
env:
1414
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
@@ -145,10 +145,48 @@ jobs:
145145
- name: Lint PHP files
146146
run: composer ci:php:lint
147147

148+
php_rector:
149+
name: PHP Rector
150+
needs:
151+
- php_lint
152+
runs-on: ubuntu-latest
153+
154+
steps:
155+
- name: Checkout
156+
uses: actions/checkout@v2
157+
158+
- name: Install PHP
159+
uses: shivammathur/setup-php@v2
160+
with:
161+
coverage: none
162+
extensions: intl, zip
163+
ini-values: memory_limit=-1, error_reporting=E_ALL, display_errors=On
164+
php-version: latest
165+
166+
- name: Composer Cache Vars
167+
id: composer-cache-vars
168+
run: |
169+
echo "::set-output name=dir::$(composer config cache-files-dir)"
170+
echo "::set-output name=timestamp::$(date +"%s")"
171+
172+
- name: Cache Composer dependencies
173+
uses: actions/cache@v2
174+
with:
175+
path: ${{ steps.composer-cache-vars.outputs.dir }}
176+
key: ${{ runner.os }}-composer-latest-${{ steps.composer-cache-vars.outputs.timestamp }}
177+
restore-keys: |
178+
${{ runner.os }}-composer-latest-
179+
180+
- name: Install dependencies
181+
run: composer install ${{ env.COMPOSER_FLAGS }}
182+
183+
- name: Validation of Rector rules for PHP files
184+
run: composer ci:php:rector
185+
148186
php_coding_standards:
149187
name: PHP Coding Standards
150188
needs:
151-
- php_lint
189+
- php_rector
152190
runs-on: ubuntu-latest
153191

154192
steps:
@@ -186,7 +224,7 @@ jobs:
186224
php_sniff:
187225
name: PHP Code Sniffer
188226
needs:
189-
- php_lint
227+
- php_rector
190228
runs-on: ubuntu-latest
191229

192230
steps:
@@ -224,7 +262,7 @@ jobs:
224262
php_copypaste_detector:
225263
name: PHP Copy/Paste Detector
226264
needs:
227-
- php_lint
265+
- php_rector
228266
runs-on: ubuntu-latest
229267

230268
steps:
@@ -263,7 +301,6 @@ jobs:
263301
name: PHP Stan
264302
needs:
265303
- validation
266-
- php_lint
267304
- php_coding_standards
268305
- php_sniff
269306
- php_copypaste_detector
@@ -338,10 +375,6 @@ jobs:
338375
tests:
339376
name: Tests
340377
needs:
341-
- php_lint
342-
- php_coding_standards
343-
- php_sniff
344-
- php_copypaste_detector
345378
- php_stan
346379
runs-on: ${{ matrix.os }}
347380
continue-on-error: ${{ matrix.experimental }}

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
],
9393
"ci:php": [
9494
"@ci:php:lint",
95+
"@ci:php:rector",
9596
"@ci:php:cs-fixer",
9697
"@ci:php:sniff",
9798
"@ci:php:copypaste",
@@ -100,6 +101,7 @@
100101
"ci:php:copypaste": "phpcpd src tests",
101102
"ci:php:cs-fixer": "php-cs-fixer fix -v --dry-run --using-cache no --diff",
102103
"ci:php:lint": "phplint --no-progress",
104+
"ci:php:rector": "rector process --dry-run --no-progress-bar",
103105
"ci:php:sniff": "phpcs --standard=PSR12 src tests",
104106
"ci:php:sniff:strict": "phpcs src tests",
105107
"ci:php:stan": "phpstan analyse --no-progress",
@@ -134,10 +136,12 @@
134136
],
135137
"fix:composer:normalize": "@composer normalize",
136138
"fix:php": [
139+
"@fix:php:rector",
137140
"@fix:php:sniff",
138141
"@fix:php:cs"
139142
],
140143
"fix:php:cs": "php-cs-fixer fix",
144+
"fix:php:rector": "rector process --no-diffs",
141145
"fix:php:sniff": "phpcbf --standard=PSR12 src",
142146
"test:php:unit": [
143147
"Composer\\Config::disableProcessTimeout",
@@ -198,8 +202,7 @@
198202
"tools:php:copypaste": "phpcpd src tests",
199203
"tools:php:cs-fixer": "php-cs-fixer fix -v --dry-run --diff",
200204
"tools:php:lint": "phplint",
201-
"tools:php:rector": "rector process --dry-run --no-progress-bar --no-diffs",
202-
"tools:php:rector:process": "rector process --no-diffs",
205+
"tools:php:rector": "rector process --dry-run",
203206
"tools:php:sniff": "phpcs --standard=PSR12 src tests",
204207
"tools:php:sniff:strict": "phpcs src tests",
205208
"tools:php:stan": "phpstan analyse",

rector.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Rector\Core\Configuration\Option;
1515
use Rector\Php74\Rector\Property\TypedPropertyRector;
1616
use Rector\Set\ValueObject\LevelSetList;
17+
use Rector\Set\ValueObject\SetList;
1718
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1819

1920
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -30,6 +31,17 @@
3031

3132
// Define what rule sets will be applied
3233
$containerConfigurator->import(LevelSetList::UP_TO_PHP_74);
34+
$containerConfigurator->import(SetList::CODE_QUALITY);
35+
$containerConfigurator->import(SetList::CODING_STYLE);
36+
$containerConfigurator->import(SetList::DEAD_CODE);
37+
$containerConfigurator->import(SetList::NAMING);
38+
//$containerConfigurator->import(SetList::ORDER);
39+
$containerConfigurator->import(SetList::PRIVATIZATION);
40+
$containerConfigurator->import(SetList::PSR_4);
41+
//$containerConfigurator->import(SetList::TYPE_DECLARATION);
42+
//$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
43+
$containerConfigurator->import(SetList::UNWRAP_COMPAT);
44+
//$containerConfigurator->import(SetList::EARLY_RETURN);
3345

3446
// get services (needed for register a single rule)
3547
// $services = $containerConfigurator->services();

src/Command/Typo3/Patch/ApplyCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function configure()
6565
*
6666
* @see https://review.typo3.org/Documentation/rest-api-changes.html#change-id
6767
*/
68-
public function execute(InputInterface $input, OutputInterface $output)
68+
protected function execute(InputInterface $input, OutputInterface $output)
6969
{
7070
// Get parameters
7171
if (!is_array($changeIds = $input->getArgument('change-id'))) {

src/Command/Typo3/Patch/RemoveCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function configure()
4848
* @throws InvalidArgumentException
4949
* @throws UnexpectedValueException
5050
*/
51-
public function execute(InputInterface $input, OutputInterface $output)
51+
protected function execute(InputInterface $input, OutputInterface $output)
5252
{
5353
// Get parameters
5454
if (!is_array($changeIds = $input->getArgument('change-id'))) {

src/Exception/CommandExecutionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
namespace GsTYPO3\CorePatches\Exception;
1313

14-
class CommandExecutionException extends RuntimeException
14+
final class CommandExecutionException extends RuntimeException
1515
{
1616
}

src/Exception/InvalidArgumentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
use Symfony\Component\Console\Exception\InvalidArgumentException as InvalidArgumentExceptionBase;
1515

16-
class InvalidArgumentException extends InvalidArgumentExceptionBase implements ExceptionInterface
16+
final class InvalidArgumentException extends InvalidArgumentExceptionBase implements ExceptionInterface
1717
{
1818
}

src/Exception/InvalidOptionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
use Symfony\Component\Console\Exception\InvalidOptionException as InvalidOptionExceptionBase;
1515

16-
class InvalidOptionException extends InvalidOptionExceptionBase implements ExceptionInterface
16+
final class InvalidOptionException extends InvalidOptionExceptionBase implements ExceptionInterface
1717
{
1818
}

src/Exception/InvalidPatchException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
namespace GsTYPO3\CorePatches\Exception;
1313

14-
class InvalidPatchException extends UnexpectedValueException
14+
final class InvalidPatchException extends UnexpectedValueException
1515
{
1616
}

src/Exception/InvalidResponseException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
namespace GsTYPO3\CorePatches\Exception;
1313

14-
class InvalidResponseException extends UnexpectedValueException
14+
final class InvalidResponseException extends UnexpectedValueException
1515
{
1616
}

0 commit comments

Comments
 (0)