Skip to content

Instantly share code, notes, and snippets.

@niepi
Forked from PhilETaylor/rector.php
Created August 22, 2023 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niepi/48662f69010bc1b826fbedf78e6eb88f to your computer and use it in GitHub Desktop.
Save niepi/48662f69010bc1b826fbedf78e6eb88f to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\CodeQuality\Rector\NullsafeMethodCall\CleanupUnneededNullsafeOperatorRector;
use Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector;
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
use Rector\CodingStyle\Rector\ClassConst\SplitGroupedClassConstantsRector;
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\CodeQuality\Rector\BinaryOp\ResponseStatusCodeRector;
use Rector\Symfony\CodeQuality\Rector\Class_\MakeCommandLazyRector;
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ActionSuffixRemoverRector;
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector;
use Rector\Symfony\CodeQuality\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
use Rector\Symfony\CodeQuality\Rector\MethodCall\LiteralGetToRequestClassConstantRector;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\TwigSetList;
use Rector\Symfony\Symfony27\Rector\MethodCall\ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector;
use Rector\Symfony\Symfony30\Rector\ClassMethod\FormTypeGetParentRector;
use Rector\Symfony\Symfony30\Rector\ClassMethod\GetRequestRector;
use Rector\Symfony\Symfony30\Rector\MethodCall\ChangeStringCollectionOptionToConstantRector;
use Rector\Symfony\Symfony30\Rector\MethodCall\FormTypeInstanceToClassConstRector;
use Rector\Symfony\Symfony30\Rector\MethodCall\ReadOnlyOptionToAttributeRector;
use Rector\Symfony\Symfony33\Rector\ClassConstFetch\ConsoleExceptionToErrorEventConstantRector;
use Rector\Symfony\Symfony34\Rector\ClassMethod\MergeMethodAnnotationToRouteAnnotationRector;
use Rector\Symfony\Symfony34\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
use Rector\Symfony\Symfony42\Rector\MethodCall\ContainerGetToConstructorInjectionRector;
use Rector\Symfony\Symfony42\Rector\New_\RootNodeTreeBuilderRector;
use Rector\Symfony\Symfony43\Rector\MethodCall\MakeDispatchFirstArgumentEventRector;
use Rector\Symfony\Symfony44\Rector\ClassMethod\ConsoleExecuteReturnIntRector;
use Rector\Symfony\Symfony44\Rector\MethodCall\AuthorizationCheckerIsGrantedExtractorRector;
use Rector\Symfony\Symfony52\Rector\StaticCall\BinaryFileResponseCreateToNewInstanceRector;
use Rector\Symfony\Symfony60\Rector\MethodCall\GetHelperControllerToServiceRector;
use Rector\Symfony\Twig134\Rector\Return_\SimpleFunctionAndFilterRector;
use Rector\Transform\Rector\String_\StringToClassConstantRector;
use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/config', __DIR__ . '/bin']);
$rectorConfig->rules([
ActionSuffixRemoverRector::class,
AuthorizationCheckerIsGrantedExtractorRector::class,
BinaryFileResponseCreateToNewInstanceRector::class,
ChangeArrayPushToArrayAssignRector::class,
ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector::class,
ChangeIfElseValueAssignToEarlyReturnRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeStringCollectionOptionToConstantRector::class,
CombineIfRector::class,
ConsoleExceptionToErrorEventConstantRector::class,
ConsoleExecuteReturnIntRector::class,
ContainerGetToConstructorInjectionRector::class,
CountArrayToEmptyArrayComparisonRector::class,
DeclareStrictTypesRector::class,
StringToClassConstantRector::class,
FormTypeGetParentRector::class,
FormTypeInstanceToClassConstRector::class,
FuncGetArgsToVariadicParamRector::class,
GetHelperControllerToServiceRector::class,
GetRequestRector::class,
InlineIfToExplicitIfRector::class,
LiteralGetToRequestClassConstantRector::class,
MakeCommandLazyRector::class,
MakeDispatchFirstArgumentEventRector::class,
MakeInheritedMethodVisibilitySameAsParentRector::class,
MergeMethodAnnotationToRouteAnnotationRector::class,
PreparedValueToEarlyReturnRector::class,
ReadOnlyOptionToAttributeRector::class,
RemoveAlwaysElseRector::class,
ReplaceSensioRouteAnnotationWithSymfonyRector::class,
ResponseReturnTypeControllerActionRector::class,
ResponseStatusCodeRector::class,
RootNodeTreeBuilderRector::class,
ShortenElseIfRector::class,
SimpleFunctionAndFilterRector::class,
SimplifyEmptyArrayCheckRector::class,
SimplifyIfElseToTernaryRector::class,
SimplifyIfReturnBoolRector::class,
SimplifyRegexPatternRector::class,
SimplifyStrposLowerRector::class,
SimplifyUselessVariableRector::class,
SplitGroupedClassConstantsRector::class,
TemplateAnnotationToThisRenderRector::class,
UnnecessaryTernaryExpressionRector::class,
UnusedForeachValueToArrayKeysRector::class,
IfIssetToCoalescingRector::class,
CleanupUnneededNullsafeOperatorRector::class,
BoolReturnTypeFromStrictScalarReturnsRector::class,
SwitchTrueToIfRector::class,
]);
$rectorConfig->importNames();
$rectorConfig->removeUnusedImports();
$rectorConfig->sets(
[
SetList::DEAD_CODE,
TwigSetList::TWIG_240,
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_62,
SymfonySetList::SYMFONY_63,
LevelSetList::UP_TO_PHP_82,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
DoctrineSetList::DOCTRINE_DBAL_40,
DoctrineSetList::DOCTRINE_ORM_29,
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
]
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment