Skip to content

Commit

Permalink
[CS] Added rectorphp/rector
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Dec 27, 2024
1 parent d3498b0 commit aac21fe
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 1 deletion.
260 changes: 260 additions & 0 deletions build/phprectorconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\Set\ValueObject\SetList;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/../examples',
__DIR__ . '/../make',
__DIR__ . '/../src',
__DIR__ . '/../tests',
])
->withSkip([
__DIR__ . '/../src/entities',
__DIR__ . '/../src/codelistsenum',
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
])
->withPhp73Sets()
->withSets([
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
])
->withParallel(60 * 5, 12, 16)
->withConfiguredRule(\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class, [
'always' => true,
])
->withRules([
/*
\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class,
\Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector::class,
\Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector::class,
\Rector\Arguments\Rector\MethodCall\RemoveMethodCallParamRector::class,
\Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class,
\Rector\CodeQuality\Rector\BooleanAnd\RemoveUselessIsObjectCheckRector::class,
\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class,
\Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector::class,
\Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class,
\Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class,
\Rector\CodeQuality\Rector\ClassConstFetch\ConvertStaticPrivateConstantToSelfRector::class,
\Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector::class,
\Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector::class,
\Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector::class,
\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class,
\Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class,
\Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector::class,
\Rector\CodeQuality\Rector\Class_\StaticToSelfStaticMethodCallOnFinalClassRector::class,
\Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class,
\Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class,
\Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class,
\Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector::class,
\Rector\CodeQuality\Rector\Expression\TernaryFalseExpressionToIfRector::class,
\Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class,
\Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class,
\Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class,
\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class,
\Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class,
\Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class,
\Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector::class,
\Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class,
\Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector::class,
\Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector::class,
\Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector::class,
\Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector::class,
\Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector::class,
\Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector::class,
\Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class,
\Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector::class,
\Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector::class,
\Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector::class,
\Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector::class,
\Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector::class,
\Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class,
\Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class,
\Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class,
\Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class,
\Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class,
\Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class,
\Rector\CodeQuality\Rector\If_\CombineIfRector::class,
\Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class,
\Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class,
\Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class,
\Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class,
\Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class,
\Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class,
\Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class,
\Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class,
\Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector::class,
\Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class,
\Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector::class,
\Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class,
\Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector::class,
\Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class,
\Rector\CodeQuality\Rector\NullsafeMethodCall\CleanupUnneededNullsafeOperatorRector::class,
\Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class,
\Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector::class,
\Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class,
\Rector\CodeQuality\Rector\Ternary\NumberCompareToMaxFuncCallRector::class,
\Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class,
\Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class,
\Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
\Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class,
\Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector::class,
\Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class,
\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class,
\Rector\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector::class,
\Rector\CodingStyle\Rector\ClassConst\SplitGroupedClassConstantsRector::class,
\Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector::class,
\Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class,
\Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class,
\Rector\CodingStyle\Rector\Closure\StaticClosureRector::class,
\Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class,
\Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class,
\Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector::class,
\Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class,
\Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector::class,
\Rector\CodingStyle\Rector\FuncCall\FunctionFirstClassCallableRector::class,
\Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector::class,
\Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class,
\Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class,
\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class,
\Rector\CodingStyle\Rector\Property\SplitGroupedPropertiesRector::class,
\Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class,
\Rector\CodingStyle\Rector\String_\UseClassKeywordForClassNameResolutionRector::class,
\Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class,
\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class,
\Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class,
\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class,
\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class,
\Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class,
\Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class,
\Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPublicMethodParameterRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnExprInConstructRector::class,
\Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class,
\Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector::class,
\Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class,
\Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class,
\Rector\DeadCode\Rector\For_\RemoveDeadContinueRector::class,
\Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class,
\Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class,
\Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class,
\Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class,
\Rector\DeadCode\Rector\If_\ReduceAlwaysFalseIfOrRector::class,
\Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector::class,
\Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class,
\Rector\DeadCode\Rector\If_\RemoveTypedPropertyDeadInstanceOfRector::class,
\Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
\Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class,
\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class,
\Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class,
\Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector::class,
\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class,
\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class,
\Rector\DeadCode\Rector\Property\RemoveUselessReadOnlyTagRector::class,
\Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class,
\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class,
\Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class,
\Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class,
\Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class,
\Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class,
\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class,
\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class,
\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class,
\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class,
\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class,
\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class,
\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class,
\Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector::class,
\Rector\Instanceof_\Rector\Ternary\FlipNegatedTernaryInstanceofRector::class,
\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class,
\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class,
\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class,
\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class,
\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class,
\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class,
\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class,
\Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector::class,
\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class,
\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class,
\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class,
\Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::class,
\Rector\Renaming\Rector\Class_\RenameAttributeRector::class,
\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class,
\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class,
\Rector\Renaming\Rector\FunctionLike\RenameFunctionLikeParamWithinCallLikeArgRector::class,
\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class,
\Rector\Renaming\Rector\Name\RenameClassRector::class,
\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class,
\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class,
\Rector\Renaming\Rector\String_\RenameStringRector::class,
\Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector::class,
\Rector\TypeDeclaration\Rector\BooleanAnd\BinaryOpNullableToInstanceofRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddTypeFromResourceDocblockRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanConstReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanStrictReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNullableTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromMockObjectRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnCastRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromSymfonySerializerRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictScalarReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector::class,
\Rector\TypeDeclaration\Rector\Class_\AddTestsVoidReturnTypeWhereNoReturnRector::class,
\Rector\TypeDeclaration\Rector\Class_\ChildDoctrineRepositoryClassTypeRector::class,
\Rector\TypeDeclaration\Rector\Class_\MergeDateTimePropertyTypeDeclarationRector::class,
\Rector\TypeDeclaration\Rector\Class_\PropertyTypeFromStrictSetterGetterRector::class,
\Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector::class,
\Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector::class,
\Rector\TypeDeclaration\Rector\Closure\AddClosureNeverReturnTypeRector::class,
\Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector::class,
\Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector::class,
\Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector::class,
\Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector::class,
\Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector::class,
\Rector\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector::class,
\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class,
\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector::class,
\Rector\TypeDeclaration\Rector\While_\WhileNullableToInstanceofRector::class,
\Rector\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector::class,
\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class,
\Rector\Visibility\Rector\ClassMethod\ExplicitPublicClassMethodRector::class,
\Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector::class,
\Rector\CodingStyle\Rector\Stmt\RemoveUselessAliasInUseStatementRector::class,
*/])
->withTypeCoverageLevel(0);
Loading

0 comments on commit aac21fe

Please sign in to comment.