Newer
Older

Yassine Doghri
committed
<?php
declare(strict_types=1);

Yassine Doghri
committed
use Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector;

Yassine Doghri
committed
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;

Yassine Doghri
committed
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
use Rector\Config\RectorConfig;

Yassine Doghri
committed
use Rector\Core\ValueObject\PhpVersion;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector;

Yassine Doghri
committed
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {

Yassine Doghri
committed
// get parameters
$rectorConfig->paths([

Yassine Doghri
committed
__DIR__ . '/app',
__DIR__ . '/modules',
__DIR__ . '/tests',
__DIR__ . '/public',

Yassine Doghri
committed
]);
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
$rectorConfig->bootstrapFiles([

Yassine Doghri
committed
__DIR__ . '/vendor/codeigniter4/framework/system/Test/bootstrap.php',

Yassine Doghri
committed
// Define what rule sets will be applied
$rectorConfig->sets([SetList::PHP_80,
SetList::TYPE_DECLARATION,
SetList::TYPE_DECLARATION_STRICT,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::EARLY_RETURN,
SetList::DEAD_CODE,
]);

Yassine Doghri
committed
// auto import fully qualified class names
$rectorConfig->importNames();
// TODO: add parallel run
// $rectorConfig->parallel();

Yassine Doghri
committed
$rectorConfig->phpVersion(PhpVersion::PHP_80);
$rectorConfig->skip([

Yassine Doghri
committed
__DIR__ . '/app/Views/errors/*',

Yassine Doghri
committed
// skip specific generated files

Yassine Doghri
committed
__DIR__ . '/modules/Admin/Language/*/PersonsTaxonomy.php',

Yassine Doghri
committed
// skip rules from used sets
ChangeOrIfReturnToEarlyReturnRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
EncapsedStringsToSprintfRector::class,
UnSpreadOperatorRector::class,

Yassine Doghri
committed
ExplicitMethodCallOverMagicGetSetRector::class,

Yassine Doghri
committed
// skip rule in specific directory
StringClassNameToClassConstantRector::class => [
__DIR__ . '/app/Language/*',

Yassine Doghri
committed
__DIR__ . '/modules/*/Language/*',

Yassine Doghri
committed
],
SymplifyQuoteEscapeRector::class => [
__DIR__ . '/app/Language/*',
__DIR__ . '/modules/*/Language/*',
],
OptionalParametersAfterRequiredRector::class => [
__DIR__ . '/app/Validation',
],

Yassine Doghri
committed
NewlineAfterStatementRector::class => [
__DIR__ . '/app/Views',
]

Yassine Doghri
committed
]);

Yassine Doghri
committed
// Path to phpstan with extensions, that PHPStan in Rector uses to determine types
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
$rectorConfig->ruleWithConfiguration(ConsistentPregDelimiterRector::class, [
ConsistentPregDelimiterRector::DELIMITER => '~',