Skip to content

[TASK] Add rector to composer.json with a simple null-config #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
command:
- fixer
- stan
- rector
php-version:
- '8.3'

Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"phpstan/extension-installer": "^1.4.1",
"phpstan/phpstan": "^1.11.4",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpunit/phpunit": "^8.5.38"
"phpunit/phpunit": "^8.5.38",
"rector/rector": "^1.1.0"
},
"suggest": {
"ext-mbstring": "for parsing UTF-8 CSS"
Expand Down Expand Up @@ -70,8 +71,10 @@
],
"ci:php:fixer": "\"./.phive/php-cs-fixer\" --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots --diff bin src tests",
"ci:php:stan": "phpstan --no-progress --configuration=config/phpstan.neon",
"ci:php:rector": "rector --no-progress-bar --dry-run --config=config/rector.php",
"ci:static": [
"@ci:php:fixer",
"@ci:php:rector",
"@ci:php:stan"
],
"ci:tests": [
Expand All @@ -80,22 +83,26 @@
"ci:tests:sof": "\"./vendor/bin/phpunit\" --stop-on-failure --do-not-cache-result",
"ci:tests:unit": "\"./vendor/bin/phpunit\" --do-not-cache-result",
"fix:php": [
"@fix:php:fixer"
"@fix:php:fixer",
"@fix:php:rector"
],
"fix:php:fixer": "\"./.phive/php-cs-fixer\" --config=config/php-cs-fixer.php fix bin src tests",
"fix:php:rector": "rector --config=config/rector.php",
"phpstan:baseline": "phpstan --configuration=config/phpstan.neon --generate-baseline=config/phpstan-baseline.neon"
},
"scripts-descriptions": {
"ci": "Runs all dynamic and static code checks.",
"ci:dynamic": "Runs all dynamic code checks (i.e., currently, the unit tests).",
"ci:php:fixer": "Checks the code style with PHP CS Fixer.",
"ci:php:stan": "Checks the types with PHPStan.",
"ci:php:rector": "Checks the code for possible code updates and refactoring.",
"ci:static": "Runs all static code analysis checks for the code.",
"ci:tests": "Runs all dynamic tests (i.e., currently, the unit tests).",
"ci:tests:sof": "Runs the unit tests and stops at the first failure.",
"ci:tests:unit": "Runs all unit tests.",
"fix:php": "Autofixes all autofixable issues in the PHP code.",
"fix:php:fixer": "Fixes autofixable issues found by PHP CS Fixer.",
"fix:php:rector": "Fixes autofixable issues found by Rector.",
"phpstan:baseline": "Updates the PHPStan baseline file to match the code."
}
}
21 changes: 21 additions & 0 deletions config/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return RectorConfig::configure()
->withPaths(
[
__DIR__ . '/../src',
__DIR__ . '/../tests',
]
)
// uncomment to reach your current PHP version
// ->withPhpSets()
->withRules(
[
// AddVoidReturnTypeWhereNoReturnRector::class,
]
);