Skip to content

Commit

Permalink
[CI] Add Rector (#18)
Browse files Browse the repository at this point in the history
* setup Rector

* ready
  • Loading branch information
TomasVotruba committed Sep 30, 2021
1 parent fd8d13b commit 1dae5c8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
-
name: 'ECS'
run: composer check-cs
-
name: 'Rector'
run: vendor/bin/rector --dry-run --ansi

name: ${{ matrix.actions.name }}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"symplify/phpstan-extensions": "^9.4",
"symplify/easy-coding-standard": "^9.4",
"symplify/rule-doc-generator": "^9.4",
"rector/rector-phpstan-rules": "^0.3.4",
"rector/rector-phpstan-rules": "^0.4",
"phpstan/extension-installer": "^1.1"
},
"autoload": {
Expand Down
2 changes: 2 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

$parameters = $containerConfigurator->parameters();

$parameters->set(Option::PARALLEL, true);

$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
Expand Down
37 changes: 33 additions & 4 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,42 @@

declare(strict_types=1);

use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Core\Configuration\Option;
use Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();

$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);
$parameters->set(Option::SKIP, [
// for tests
'*/Source/*',
'*/Fixture/*',
]);

// needed for DEAD_CODE list, just in split package like this
$containerConfigurator->import(__DIR__ . '/config/config.php');

// reuqired for PHP 8
$services = $containerConfigurator->services();
$services->defaults()
->public()
->autoconfigure()
->autowire();

// needed for sets bellow, only for this split package
$services->set(BinaryOpAnalyzer::class);
$services->set(TestsNodeAnalyzer::class);

$services->set(TypedPropertyRector::class);
$services->set(ClassPropertyAssignToConstructorPromotionRector::class);
$containerConfigurator->import(SetList::PHP_80);
$containerConfigurator->import(SetList::PHP_74);
$containerConfigurator->import(SetList::PHP_73);
$containerConfigurator->import(SetList::DEAD_CODE);
};

0 comments on commit 1dae5c8

Please sign in to comment.