2020-09-25 10:41:42 +07:00
|
|
|
<?php
|
|
|
|
|
2021-02-16 10:44:29 +07:00
|
|
|
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
|
2021-02-01 13:23:04 +07:00
|
|
|
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
|
2021-03-13 01:17:32 +07:00
|
|
|
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
|
2021-04-12 20:44:31 +07:00
|
|
|
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
|
2021-02-04 22:55:38 +07:00
|
|
|
use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
|
2021-02-05 16:07:12 +07:00
|
|
|
use Rector\CodeQuality\Rector\If_\CombineIfRector;
|
2021-02-25 11:11:12 +07:00
|
|
|
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
|
2021-03-12 13:37:57 +07:00
|
|
|
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
|
2021-02-06 12:24:49 +07:00
|
|
|
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
|
2021-02-01 13:23:04 +07:00
|
|
|
use Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector;
|
2021-04-13 01:57:54 +07:00
|
|
|
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
|
2021-05-30 06:04:42 +07:00
|
|
|
use Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector;
|
2021-02-26 08:30:35 +07:00
|
|
|
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
|
2020-09-25 10:41:42 +07:00
|
|
|
use Rector\Core\Configuration\Option;
|
2021-01-08 13:40:57 +07:00
|
|
|
use Rector\Core\ValueObject\PhpVersion;
|
2021-03-20 11:54:45 +07:00
|
|
|
use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector;
|
2021-02-28 14:00:11 +07:00
|
|
|
use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector;
|
2021-05-11 20:16:11 +07:00
|
|
|
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
|
2021-02-10 16:45:38 +07:00
|
|
|
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
|
2021-02-02 02:39:20 +07:00
|
|
|
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
|
2021-02-02 15:08:32 +07:00
|
|
|
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
|
2021-02-26 08:30:35 +07:00
|
|
|
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
|
2021-02-22 19:48:58 +07:00
|
|
|
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
2021-05-24 03:46:44 +02:00
|
|
|
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
|
2021-05-26 13:29:51 +07:00
|
|
|
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
|
2021-04-23 14:35:33 +07:00
|
|
|
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
|
|
|
|
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
|
|
|
use Rector\Set\ValueObject\SetList;
|
2020-09-25 10:41:42 +07:00
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
2020-10-23 19:19:47 +07:00
|
|
|
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
|
2021-05-22 09:06:19 +07:00
|
|
|
use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector;
|
2021-06-02 10:29:44 +07:00
|
|
|
use Utils\Rector\RemoveVarTagFromClassConstantRector;
|
2020-09-28 18:56:04 +07:00
|
|
|
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
|
2020-09-25 10:41:42 +07:00
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
2021-05-10 15:57:40 +07:00
|
|
|
$containerConfigurator->import(SetList::PHP_73);
|
|
|
|
|
2020-09-25 10:41:42 +07:00
|
|
|
$parameters = $containerConfigurator->parameters();
|
|
|
|
|
|
|
|
// paths to refactor; solid alternative to CLI arguments
|
2021-03-31 23:12:39 +07:00
|
|
|
$parameters->set(Option::PATHS, [__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils/Rector']);
|
2020-09-25 10:41:42 +07:00
|
|
|
|
2021-03-24 08:38:22 +07:00
|
|
|
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
|
|
|
|
$parameters->set(Option::BOOTSTRAP_FILES, [
|
|
|
|
__DIR__ . '/system/Test/bootstrap.php',
|
|
|
|
]);
|
|
|
|
|
2020-09-25 10:41:42 +07:00
|
|
|
// is there a file you need to skip?
|
2021-01-05 22:16:43 +07:00
|
|
|
$parameters->set(Option::SKIP, [
|
2020-09-25 10:41:42 +07:00
|
|
|
__DIR__ . '/app/Views',
|
2020-09-25 10:50:30 +07:00
|
|
|
__DIR__ . '/system/Debug/Toolbar/Views/toolbar.tpl.php',
|
2020-09-26 04:45:42 +07:00
|
|
|
__DIR__ . '/system/ThirdParty',
|
2021-02-28 06:47:59 +07:00
|
|
|
__DIR__ . '/tests/system/Config/fixtures',
|
|
|
|
__DIR__ . '/tests/_support',
|
2021-02-28 09:33:18 +07:00
|
|
|
PassStrictParameterToFunctionParameterRector::class => [__DIR__ . '/tests/system/Database/Live/SelectTest.php'],
|
2021-04-23 14:35:33 +07:00
|
|
|
JsonThrowOnErrorRector::class,
|
|
|
|
StringifyStrNeedlesRector::class,
|
2020-09-25 10:41:42 +07:00
|
|
|
]);
|
|
|
|
|
2020-10-04 00:27:56 +07:00
|
|
|
// auto import fully qualified class names
|
2021-04-14 20:16:14 +07:00
|
|
|
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
|
2020-10-16 10:08:54 +07:00
|
|
|
$parameters->set(Option::ENABLE_CACHE, true);
|
2021-01-08 13:40:57 +07:00
|
|
|
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73);
|
2020-10-16 10:08:54 +07:00
|
|
|
|
2020-09-25 10:41:42 +07:00
|
|
|
$services = $containerConfigurator->services();
|
2021-05-14 20:16:31 +07:00
|
|
|
$services->load('Symplify\\PackageBuilder\\', __DIR__ . '/vendor/symplify/package-builder/src');
|
|
|
|
|
2020-09-28 18:56:04 +07:00
|
|
|
$services->set(UnderscoreToCamelCaseVariableNameRector::class);
|
2020-10-02 18:47:38 +07:00
|
|
|
$services->set(SimplifyUselessVariableRector::class);
|
2020-10-03 14:44:37 +07:00
|
|
|
$services->set(RemoveAlwaysElseRector::class);
|
2020-10-23 19:19:47 +07:00
|
|
|
$services->set(PassStrictParameterToFunctionParameterRector::class);
|
2020-10-30 20:51:53 +07:00
|
|
|
$services->set(CountArrayToEmptyArrayComparisonRector::class);
|
2021-02-01 13:23:04 +07:00
|
|
|
$services->set(ForToForeachRector::class);
|
2021-02-02 02:39:20 +07:00
|
|
|
$services->set(ChangeNestedForeachIfsToEarlyContinueRector::class);
|
2021-02-02 15:08:32 +07:00
|
|
|
$services->set(ChangeIfElseValueAssignToEarlyReturnRector::class);
|
2021-02-04 22:55:38 +07:00
|
|
|
$services->set(SimplifyStrposLowerRector::class);
|
2021-02-05 16:07:12 +07:00
|
|
|
$services->set(CombineIfRector::class);
|
2021-02-06 12:24:49 +07:00
|
|
|
$services->set(SimplifyIfReturnBoolRector::class);
|
2021-02-10 16:45:38 +07:00
|
|
|
$services->set(RemoveDuplicatedCaseInSwitchRector::class);
|
2021-02-16 10:44:29 +07:00
|
|
|
$services->set(InlineIfToExplicitIfRector::class);
|
2021-02-22 19:48:58 +07:00
|
|
|
$services->set(PreparedValueToEarlyReturnRector::class);
|
2021-02-25 11:11:12 +07:00
|
|
|
$services->set(ShortenElseIfRector::class);
|
2021-02-28 14:00:11 +07:00
|
|
|
$services->set(RemoveUnusedForeachKeyRector::class);
|
2021-03-12 13:37:57 +07:00
|
|
|
$services->set(SimplifyIfElseToTernaryRector::class);
|
2021-03-13 01:17:32 +07:00
|
|
|
$services->set(UnusedForeachValueToArrayKeysRector::class);
|
2021-03-20 11:54:45 +07:00
|
|
|
$services->set(RemoveConcatAutocastRector::class);
|
2021-04-12 20:44:31 +07:00
|
|
|
$services->set(ChangeArrayPushToArrayAssignRector::class);
|
2021-04-13 01:57:54 +07:00
|
|
|
$services->set(UnnecessaryTernaryExpressionRector::class);
|
2021-05-11 20:16:11 +07:00
|
|
|
$services->set(RemoveUnusedPrivatePropertyRector::class);
|
2021-05-22 09:06:19 +07:00
|
|
|
$services->set(RemoveErrorSuppressInTryCatchStmtsRector::class);
|
2021-05-24 03:46:44 +02:00
|
|
|
$services->set(TernaryToNullCoalescingRector::class);
|
2021-05-26 13:29:51 +07:00
|
|
|
$services->set(ListToArrayDestructRector::class);
|
2021-05-30 06:04:42 +07:00
|
|
|
$services->set(MoveVariableDeclarationNearReferenceRector::class);
|
2021-06-02 10:29:44 +07:00
|
|
|
$services->set(RemoveVarTagFromClassConstantRector::class);
|
2020-09-25 10:41:42 +07:00
|
|
|
};
|