Skip to content

Commit

Permalink
[TASK] Add Rector script and configuration (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertsoft authored Aug 13, 2022
1 parent 311267b commit 1aea6ed
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@
],
"fix:composer:normalize": "@composer normalize",
"fix:php": [
"@fix:php:rector",
"@fix:php:cs"
],
"fix:php:cs": "php-cs-fixer fix"
"fix:php:cs": "php-cs-fixer fix",
"fix:php:rector": [
"@composer require --dev rector/rector",
"@php rector process",
"@composer remove --dev rector/rector"
]
}
}
61 changes: 61 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2022 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->skip([
__DIR__ . '/tests/Unit/Fixtures',

FinalizeClassesWithoutChildrenRector::class => [
__DIR__ . '/src/CsFixerConfig.php',
],
]);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_72,
DowngradeLevelSetList::DOWN_TO_PHP_72,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::NAMING,
SetList::PRIVATIZATION,
SetList::PSR_4,
SetList::TYPE_DECLARATION,
SetList::TYPE_DECLARATION_STRICT,
SetList::EARLY_RETURN,

// PHPUnit rules
PHPUnitLevelSetList::UP_TO_PHPUNIT_80,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::PHPUNIT_EXCEPTION,
PHPUnitSetList::REMOVE_MOCKS,
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
]);
};

0 comments on commit 1aea6ed

Please sign in to comment.