2022-03-03 14:20:10 -05:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
|
2022-03-03 18:19:02 -05:00
|
|
|
use Rector\CodeQuality\Rector\For_\{ForRepeatedCountToOwnVariableRector, ForToForeachRector};
|
|
|
|
use Rector\CodeQuality\Rector\If_\{ConsecutiveNullCompareReturnsToNullCoalesceQueueRector, SimplifyIfElseToTernaryRector, SimplifyIfReturnBoolRector};
|
2023-05-09 12:46:52 -04:00
|
|
|
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
|
|
|
|
use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
|
|
|
|
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
|
|
|
|
use Rector\Set\ValueObject\LevelSetList;
|
|
|
|
use Rector\CodeQuality\Rector\Ternary\{SimplifyTautologyTernaryRector, SwitchNegatedTernaryRector};
|
|
|
|
use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector;
|
2022-03-03 14:20:10 -05:00
|
|
|
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
|
|
|
|
use Rector\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector;
|
2023-05-09 12:46:52 -04:00
|
|
|
use Rector\CodingStyle\Rector\ClassMethod\{NewlineBeforeNewAssignSetRector, OrderAttributesRector};
|
2022-03-03 14:20:10 -05:00
|
|
|
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
|
2023-05-09 12:46:52 -04:00
|
|
|
use Rector\CodingStyle\Rector\FuncCall\
|
|
|
|
{CallUserFuncArrayToVariadicRector,
|
|
|
|
CallUserFuncToMethodCallRector,
|
|
|
|
CountArrayToEmptyArrayComparisonRector,
|
|
|
|
VersionCompareFuncCallToConstantRector};
|
2022-03-03 14:20:10 -05:00
|
|
|
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
|
2023-05-09 12:46:52 -04:00
|
|
|
use Rector\Config\RectorConfig;
|
2022-03-03 18:19:02 -05:00
|
|
|
use Rector\DeadCode\Rector\ClassMethod\{RemoveUselessParamTagRector, RemoveUselessReturnTagRector};
|
2022-03-03 14:20:10 -05:00
|
|
|
use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector;
|
|
|
|
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
|
|
|
|
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
|
|
|
|
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
|
2022-03-03 18:19:02 -05:00
|
|
|
use Rector\EarlyReturn\Rector\If_\{ChangeIfElseValueAssignToEarlyReturnRector, RemoveAlwaysElseRector};
|
2023-05-09 12:46:52 -04:00
|
|
|
use Rector\PHPUnit\Set\PHPUnitSetList;
|
|
|
|
use Rector\TypeDeclaration\Rector\ClassMethod\{AddMethodCallBasedStrictParamTypeRector, ParamTypeByMethodCallTypeRector, ParamTypeByParentCallTypeRector};
|
2022-03-03 14:20:10 -05:00
|
|
|
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
|
|
|
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
|
|
|
|
|
2023-05-09 12:46:52 -04:00
|
|
|
return static function (RectorConfig $config): void {
|
|
|
|
// Import names with use statements
|
|
|
|
$config->importNames();
|
|
|
|
$config->importShortClasses(false);
|
2022-03-03 14:20:10 -05:00
|
|
|
|
2023-05-09 12:46:52 -04:00
|
|
|
$config->sets([
|
|
|
|
LevelSetList::UP_TO_PHP_81,
|
|
|
|
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
|
|
|
|
PHPUnitSetList::PHPUNIT_100,
|
2022-03-03 14:20:10 -05:00
|
|
|
]);
|
|
|
|
|
2023-05-09 12:46:52 -04:00
|
|
|
$config->rules([
|
2022-03-03 14:20:10 -05:00
|
|
|
AddArrayDefaultToArrayPropertyRector::class,
|
|
|
|
AddClosureReturnTypeRector::class,
|
|
|
|
AddMethodCallBasedStrictParamTypeRector::class,
|
|
|
|
CallUserFuncArrayToVariadicRector::class,
|
|
|
|
CallUserFuncToMethodCallRector::class,
|
2023-05-09 12:46:52 -04:00
|
|
|
CountArrayToEmptyArrayComparisonRector::class,
|
2022-03-03 14:20:10 -05:00
|
|
|
ChangeIfElseValueAssignToEarlyReturnRector::class,
|
|
|
|
ChangeNestedForeachIfsToEarlyContinueRector::class,
|
|
|
|
CompleteDynamicPropertiesRector::class,
|
|
|
|
ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class,
|
|
|
|
CountArrayToEmptyArrayComparisonRector::class,
|
|
|
|
ForRepeatedCountToOwnVariableRector::class,
|
|
|
|
ForToForeachRector::class,
|
2022-03-03 17:26:09 -05:00
|
|
|
// NewlineAfterStatementRector::class,
|
2022-03-03 14:20:10 -05:00
|
|
|
NewlineBeforeNewAssignSetRector::class,
|
|
|
|
ParamTypeByMethodCallTypeRector::class,
|
|
|
|
ParamTypeByParentCallTypeRector::class,
|
|
|
|
RemoveAlwaysElseRector::class,
|
|
|
|
RemoveDuplicatedCaseInSwitchRector::class,
|
|
|
|
RemoveFinalFromConstRector::class,
|
|
|
|
RemoveUnusedForeachKeyRector::class,
|
|
|
|
RemoveUselessParamTagRector::class,
|
|
|
|
RemoveUselessReturnTagRector::class,
|
|
|
|
RemoveUselessVarTagRector::class,
|
|
|
|
SimplifyIfElseToTernaryRector::class,
|
|
|
|
SimplifyIfReturnBoolRector::class,
|
|
|
|
SimplifyTautologyTernaryRector::class,
|
2023-05-09 12:46:52 -04:00
|
|
|
SymplifyQuoteEscapeRector::class,
|
|
|
|
StaticArrowFunctionRector::class,
|
2022-03-03 14:20:10 -05:00
|
|
|
SwitchNegatedTernaryRector::class,
|
|
|
|
TypedPropertyFromAssignsRector::class,
|
2023-05-09 12:46:52 -04:00
|
|
|
VersionCompareFuncCallToConstantRector::class,
|
2022-03-03 14:20:10 -05:00
|
|
|
WrapEncapsedVariableInCurlyBracesRector::class,
|
|
|
|
]);
|
2023-05-09 12:46:52 -04:00
|
|
|
|
|
|
|
$config->ruleWithConfiguration(OrderAttributesRector::class, [
|
|
|
|
'alphabetically',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$config->skip([
|
|
|
|
ReadOnlyPropertyRector::class,
|
|
|
|
RestoreDefaultNullToNullableTypePropertyRector::class,
|
|
|
|
]);
|
2022-03-03 14:20:10 -05:00
|
|
|
};
|