collection-crud/tools/rector.php

86 lines
4.5 KiB
PHP

<?php declare(strict_types=1);
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\For_\{ForRepeatedCountToOwnVariableRector, ForToForeachRector};
use Rector\CodeQuality\Rector\If_\{ConsecutiveNullCompareReturnsToNullCoalesceQueueRector, SimplifyIfElseToTernaryRector, SimplifyIfReturnBoolRector};
use Rector\CodeQuality\Rector\Ternary\{SimplifyDuplicatedTernaryRector, SimplifyTautologyTernaryRector, SwitchNegatedTernaryRector};
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
use Rector\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\FuncCall\{CallUserFuncArrayToVariadicRector, CallUserFuncToMethodCallRector, CountArrayToEmptyArrayComparisonRector};
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Core\Configuration\Option;
use Rector\DeadCode\Rector\ClassMethod\{RemoveUselessParamTagRector, RemoveUselessReturnTagRector};
use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\{ChangeIfElseValueAssignToEarlyReturnRector, RemoveAlwaysElseRector};
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Restoration\Rector\Property\MakeTypedPropertyNullableIfCheckedRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\{SymfonyLevelSetList, SymfonySetList};
use Rector\TypeDeclaration\Rector\ClassMethod\{AddArrayParamDocTypeRector, AddArrayReturnDocTypeRector, AddMethodCallBasedStrictParamTypeRector, ParamTypeByMethodCallTypeRector, ParamTypeByParentCallTypeRector};
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
require_once __DIR__ . '/common.inc.php';
return static function (ContainerConfigurator $config): void {
$parameters = $config->parameters();
$parameters->set(Option::AUTO_IMPORT_NAMES, TRUE);
$parameters->set(Option::IMPORT_SHORT_CLASSES, TRUE);
$parameters->set(Option::SKIP, [
ReadOnlyPropertyRector::class,
]);
walk_array([$config, 'import'], [
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
LevelSetList::UP_TO_PHP_81,
SymfonyLevelSetList::UP_TO_SYMFONY_60,
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
]);
$services = $config->services();
walk_array([$services, 'set'], [
SimplifyDeMorganBinaryRector::class,
CompleteDynamicPropertiesRector::class,
ForRepeatedCountToOwnVariableRector::class,
ForToForeachRector::class,
ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class,
SimplifyIfElseToTernaryRector::class,
SimplifyIfReturnBoolRector::class,
SimplifyDuplicatedTernaryRector::class,
SimplifyTautologyTernaryRector::class,
SwitchNegatedTernaryRector::class,
AddArrayDefaultToArrayPropertyRector::class,
RemoveFinalFromConstRector::class,
NewlineBeforeNewAssignSetRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
CallUserFuncArrayToVariadicRector::class,
CallUserFuncToMethodCallRector::class,
CountArrayToEmptyArrayComparisonRector::class,
NewlineAfterStatementRector::class,
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveUnusedForeachKeyRector::class,
RemoveUselessVarTagRector::class,
RemoveDuplicatedCaseInSwitchRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeIfElseValueAssignToEarlyReturnRector::class,
RemoveAlwaysElseRector::class,
MakeTypedPropertyNullableIfCheckedRector::class,
AddArrayParamDocTypeRector::class,
AddArrayReturnDocTypeRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
ParamTypeByMethodCallTypeRector::class,
ParamTypeByParentCallTypeRector::class,
AddClosureReturnTypeRector::class,
TypedPropertyFromAssignsRector::class,
]);
};