2021-05-06 14:00:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-03-04 14:33:48 +00:00
|
|
|
use Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
|
|
|
|
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
|
|
|
|
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
|
2022-03-04 14:33:48 +00:00
|
|
|
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
|
2022-04-15 12:16:12 +00:00
|
|
|
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
|
2022-07-03 16:42:20 +00:00
|
|
|
use Rector\Config\RectorConfig;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Rector\Core\ValueObject\PhpVersion;
|
2022-10-16 10:36:54 +00:00
|
|
|
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
|
2023-03-16 13:00:05 +00:00
|
|
|
use Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector;
|
2023-02-28 14:26:27 +00:00
|
|
|
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
|
|
|
|
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
|
|
|
|
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
2022-09-28 14:00:05 +00:00
|
|
|
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Rector\Set\ValueObject\SetList;
|
|
|
|
|
2022-07-03 16:42:20 +00:00
|
|
|
return static function (RectorConfig $rectorConfig): void {
|
2022-10-17 14:17:50 +00:00
|
|
|
$rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/modules', __DIR__ . '/tests', __DIR__ . '/public']);
|
2021-05-06 14:00:48 +00:00
|
|
|
|
2021-05-14 17:59:35 +00:00
|
|
|
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
|
2022-10-17 14:17:50 +00:00
|
|
|
$rectorConfig->bootstrapFiles([__DIR__ . '/vendor/codeigniter4/framework/system/Test/bootstrap.php']);
|
2021-05-14 17:59:35 +00:00
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
// Define what rule sets will be applied
|
2022-10-17 14:17:50 +00:00
|
|
|
$rectorConfig->sets([
|
|
|
|
SetList::PHP_81,
|
2022-07-03 16:42:20 +00:00
|
|
|
SetList::TYPE_DECLARATION,
|
|
|
|
SetList::CODE_QUALITY,
|
|
|
|
SetList::CODING_STYLE,
|
|
|
|
SetList::EARLY_RETURN,
|
|
|
|
SetList::DEAD_CODE,
|
|
|
|
]);
|
2021-05-06 14:00:48 +00:00
|
|
|
|
|
|
|
// auto import fully qualified class names
|
2022-07-03 16:42:20 +00:00
|
|
|
$rectorConfig->importNames();
|
2021-05-06 14:00:48 +00:00
|
|
|
|
2022-10-17 14:17:50 +00:00
|
|
|
$rectorConfig->phpVersion(PhpVersion::PHP_81);
|
2022-07-03 16:42:20 +00:00
|
|
|
|
|
|
|
$rectorConfig->skip([
|
2022-09-28 14:00:05 +00:00
|
|
|
// .mp3 files were somehow processed by rector, so skip all media files
|
|
|
|
__DIR__ . '/public/media/*',
|
|
|
|
|
2022-03-04 14:33:48 +00:00
|
|
|
__DIR__ . '/app/Views/errors/*',
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
// skip specific generated files
|
2021-08-27 10:58:22 +00:00
|
|
|
__DIR__ . '/modules/Admin/Language/*/PersonsTaxonomy.php',
|
2021-05-06 14:00:48 +00:00
|
|
|
|
|
|
|
// skip rules from used sets
|
|
|
|
ChangeOrIfReturnToEarlyReturnRector::class,
|
|
|
|
ChangeOrIfContinueToMultiContinueRector::class,
|
|
|
|
EncapsedStringsToSprintfRector::class,
|
|
|
|
UnSpreadOperatorRector::class,
|
2022-03-04 14:33:48 +00:00
|
|
|
ExplicitMethodCallOverMagicGetSetRector::class,
|
2022-09-28 14:00:05 +00:00
|
|
|
RemoveExtraParametersRector::class,
|
2022-10-16 10:36:54 +00:00
|
|
|
UnwrapFutureCompatibleIfPhpVersionRector::class,
|
2021-05-06 14:00:48 +00:00
|
|
|
|
|
|
|
// skip rule in specific directory
|
|
|
|
StringClassNameToClassConstantRector::class => [
|
|
|
|
__DIR__ . '/app/Language/*',
|
2021-08-27 10:58:22 +00:00
|
|
|
__DIR__ . '/modules/*/Language/*',
|
2021-05-06 14:00:48 +00:00
|
|
|
],
|
2022-10-17 14:17:50 +00:00
|
|
|
SymplifyQuoteEscapeRector::class => [__DIR__ . '/app/Language/*', __DIR__ . '/modules/*/Language/*'],
|
2022-03-04 14:33:48 +00:00
|
|
|
|
2022-10-17 14:17:50 +00:00
|
|
|
NewlineAfterStatementRector::class => [__DIR__ . '/app/Views'],
|
2023-02-28 14:26:27 +00:00
|
|
|
|
2023-03-16 13:00:05 +00:00
|
|
|
RemoveUnreachableStatementRector::class => [
|
|
|
|
__DIR__ . '/modules/Install/Controllers/InstallController.php',
|
|
|
|
],
|
|
|
|
|
2023-02-28 14:26:27 +00:00
|
|
|
ChangeAndIfToEarlyReturnRector::class => [__DIR__ . '/modules/Install/Controllers/InstallController.php'],
|
2021-05-06 14:00:48 +00:00
|
|
|
]);
|
|
|
|
|
2021-08-19 14:00:14 +00:00
|
|
|
// Path to phpstan with extensions, that PHPStan in Rector uses to determine types
|
2022-07-03 16:42:20 +00:00
|
|
|
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
|
2021-05-14 17:59:35 +00:00
|
|
|
|
2022-07-03 16:42:20 +00:00
|
|
|
$rectorConfig->ruleWithConfiguration(ConsistentPregDelimiterRector::class, [
|
|
|
|
ConsistentPregDelimiterRector::DELIMITER => '~',
|
2021-05-06 14:00:48 +00:00
|
|
|
]);
|
|
|
|
};
|