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;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Rector\Core\Configuration\Option;
|
|
|
|
use Rector\Core\ValueObject\PhpVersion;
|
|
|
|
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
|
|
|
|
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
|
|
|
|
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
2021-05-14 17:59:35 +00:00
|
|
|
use Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Rector\Set\ValueObject\SetList;
|
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
|
|
// get parameters
|
|
|
|
$parameters = $containerConfigurator->parameters();
|
|
|
|
|
|
|
|
$parameters->set(Option::PATHS, [
|
|
|
|
__DIR__ . '/app',
|
2022-03-04 14:33:48 +00:00
|
|
|
// __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
|
|
|
|
$parameters->set(Option::BOOTSTRAP_FILES, [
|
2022-03-04 14:33:48 +00:00
|
|
|
__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
|
2021-05-14 17:59:35 +00:00
|
|
|
$containerConfigurator->import(SetList::PHP_80);
|
2021-05-12 14:00:25 +00:00
|
|
|
$containerConfigurator->import(SetList::TYPE_DECLARATION);
|
|
|
|
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
|
|
|
|
$containerConfigurator->import(SetList::CODE_QUALITY);
|
|
|
|
$containerConfigurator->import(SetList::CODING_STYLE);
|
|
|
|
$containerConfigurator->import(SetList::EARLY_RETURN);
|
|
|
|
$containerConfigurator->import(SetList::DEAD_CODE);
|
|
|
|
$containerConfigurator->import(SetList::ORDER);
|
2021-05-06 14:00:48 +00:00
|
|
|
|
|
|
|
// auto import fully qualified class names
|
|
|
|
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
|
2022-03-04 14:33:48 +00:00
|
|
|
// TODO: add parallel
|
|
|
|
// $parameters->set(Option::PARALLEL, true);
|
2021-05-14 17:59:35 +00:00
|
|
|
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
|
2021-05-06 14:00:48 +00:00
|
|
|
|
|
|
|
$parameters->set(Option::SKIP, [
|
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,
|
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
|
|
|
],
|
2021-05-14 17:59:35 +00:00
|
|
|
OptionalParametersAfterRequiredRector::class => [
|
|
|
|
__DIR__ . '/app/Validation',
|
|
|
|
],
|
2022-03-04 14:33:48 +00:00
|
|
|
|
|
|
|
NewlineAfterStatementRector::class => [
|
|
|
|
__DIR__ . '/app/Views',
|
|
|
|
]
|
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
|
2021-05-14 17:59:35 +00:00
|
|
|
$parameters->set(
|
|
|
|
Option::PHPSTAN_FOR_RECTOR_PATH,
|
|
|
|
__DIR__ . '/phpstan.neon',
|
|
|
|
);
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
$services = $containerConfigurator->services();
|
|
|
|
$services->set(ConsistentPregDelimiterRector::class)->call('configure', [
|
|
|
|
[
|
|
|
|
ConsistentPregDelimiterRector::DELIMITER => '~',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
};
|