Skip to content

Instantly share code, notes, and snippets.

@rotexdegba

rotexdegba/rector.yaml

Last active Jan 21, 2020
Embed
What would you like to do?
A yaml file containing base Rector configuration setting to be used by the Rector tool on all my php projects
# rector.yaml
imports:
# - { resource: 'vendor/rector/rector/config/set/code-quality/code-quality.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php52.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php53.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php54.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php55.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php56.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php70.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php71.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php72.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php73.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php74.yaml' }
parameters:
# PHP 7.2 "object" type hint
enable_object_type: true
services:
Rector\Architecture\Rector\Class_\ConstructorInjectionToActionInjectionRector: ~
Rector\Celebrity\Rector\NotEqual\CommonNotEqualRector: ~
Rector\Celebrity\Rector\BooleanOp\LogicalToBooleanRector: ~
Rector\Celebrity\Rector\FuncCall\SetTypeToCastRector: ~
Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector: ~
Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector: ~
Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector: ~
Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector: ~
Rector\CodeQuality\Rector\Assign\CombinedAssignRector: ~
Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector: ~
Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector: ~
Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector: ~
Rector\CodeQuality\Rector\For_\ForToForeachRector: ~
Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector: ~
Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector: ~
Rector\CodeQuality\Rector\FuncCall\InArrayAndArrayKeysToArrayKeyExistsRector: ~
Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector: ~
Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector: ~
Rector\CodeQuality\Rector\Concat\JoinStringConcatRector: ~
Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector: ~
Rector\CodeQuality\Rector\If_\ShortenElseIfRector: ~
Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector: ~
Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector: ~
Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector: ~
Rector\CodeQuality\Rector\BinaryOp\SimplifyDeMorganBinaryRector: ~
Rector\CodeQuality\Rector\Ternary\SimplifyDuplicatedTernaryRector: ~
Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector: ~
Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector: ~
Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector: ~
Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector: ~
Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector: ~
Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector: ~
Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector: ~
Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector: ~
Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector: ~
Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector: ~
Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector: ~
Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector: ~
Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector: ~
Rector\CodeQuality\Rector\FuncCall\StrlenZeroToIdenticalEmptyStringRector: ~
Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector: ~
Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector: ~
Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector: ~
Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector: ~
Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector: ~
Rector\CodingStyle\Rector\FuncCall\CallUserFuncCallToVariadicRector: ~
Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector: ~
Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector: ~
Rector\CodingStyle\Rector\Identical\IdenticalFalseToBooleanNotRector: ~
Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector: ~
Rector\CodingStyle\Rector\If_\NullableCompareToNullRector: ~
Rector\CodingStyle\Rector\FuncCall\SimpleArrayCallableToStringRector: ~
Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector: ~
Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector: ~
Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector: ~
Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector: ~
Rector\CodingStyle\Rector\Assign\UseIncrementAssignRector: ~
Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector: ~
Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector: ~
Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector:
$functionsToConstants:
php_sapi_name: PHP_SAPI
pi: M_PI
Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector: ~
Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector: ~
Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector: ~
Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector: ~
Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector: ~
Rector\DeadCode\Rector\Stmt\RemoveDeadStmtRector: ~
Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector: ~
Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector: ~
Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector: ~
Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector: ~
Rector\DeadCode\Rector\Instanceof_\RemoveDuplicatedInstanceOfRector: ~
Rector\DeadCode\Rector\ClassMethod\RemoveOverriddenValuesRector: ~
Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector: ~
Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector: ~
Rector\DeadCode\Rector\Class_\RemoveUnusedClassesRector: ~
Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParameterRector: ~
Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateConstantRector: ~
Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector: ~
Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector: ~
Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector: ~
Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector: ~
Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector: ~
Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector: ~
Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector: ~
# first swap arguments, then rename
Rector\Rector\Argument\SwapFuncCallArgumentsRector:
mysql_real_escape_string: [1, 0]
mysql_select_db: [1, 0]
mysql_set_charset: [1, 0]
mysql_query: [1, 0]
mysql_fetch_row: [1, 0]
Rector\Renaming\Rector\Function_\RenameFunctionRector:
mysql_affected_rows: 'mysqli_affected_rows'
mysql_close: 'mysqli_close'
mysql_data_seek: 'mysqli_data_seek'
mysql_errno: 'mysqli_errno'
mysql_error: 'mysqli_error'
mysql_fetch_array: 'mysqli_fetch_array'
mysql_fetch_assoc: 'mysqli_fetch_assoc'
mysql_fetch_lengths: 'mysqli_fetch_lengths'
mysql_fetch_object: 'mysqli_fetch_object'
mysql_fetch_row: 'mysqli_fetch_row'
mysql_field_seek: 'mysqli_field_seek'
mysql_free_result: 'mysqli_free_result'
mysql_get_client_info: 'mysqli_get_client_info'
mysql_get_host_info: 'mysqli_get_host_info'
mysql_get_proto_info: 'mysqli_get_proto_info'
mysql_get_server_info: 'mysqli_get_server_info'
mysql_info: 'mysqli_info'
mysql_insert_id: 'mysqli_insert_id'
mysql_num_rows: 'mysqli_num_rows'
mysql_ping: 'mysqli_ping'
mysql_query: 'mysqli_query'
mysql_real_escape_string: 'mysqli_real_escape_string'
mysql_select_db: 'mysqli_select_db'
mysql_set_charset: 'mysqli_set_charset'
mysql_stat: 'mysqli_stat'
mysql_thread_id: 'mysqli_thread_id'
mysql_numfields: 'mysqli_num_fields'
mysql_escape_string: 'mysqli_real_escape_string'
mysql_client_encoding: 'mysqli_character_set_name'
mysql_numrows: 'mysqli_num_rows'
mysql_list_processes: 'mysqli_thread_id'
mysql_num_fields: 'mysqli_field_count'
mysql_connect: 'mysqli_connect'
# http://php.net/manual/en/mysql.constants.php ↓
# http://php.net/manual/en/mysqli.constants.php
Rector\Renaming\Rector\ConstFetch\RenameConstantRector:
MYSQL_ASSOC: 'MYSQLI_ASSOC'
MYSQL_NUM: 'MYSQLI_NUM'
MYSQL_BOTH: 'MYSQLI_BOTH'
MYSQL_CLIENT_COMPRESS: 'MYSQLI_CLIENT_COMPRESS'
MYSQL_CLIENT_IGNORE_SPACE: 'MYSQLI_CLIENT_IGNORE_SPACE'
MYSQL_CLIENT_INTERACTIVE: 'MYSQLI_CLIENT_INTERACTIVE'
MYSQL_CLIENT_SSL: 'MYSQLI_CLIENT_SSL'
MYSQL_PRIMARY_KEY_FLAG: 'MYSQLI_PRI_KEY_FLAG'
Rector\PHPStan\Rector\Cast\RecastingRemovalRector: ~
Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector: ~
# @expectedException → $this->expectException()
Rector\PHPUnit\Rector\ExceptionAnnotationRector: ~
Rector\Renaming\Rector\MethodCall\RenameMethodRector:
PHPUnit\Framework\TestClass:
setExpectedException: 'expectedException'
setExpectedExceptionRegExp: 'expectedException'
Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetRector: ~
Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector: ~
Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsRector: ~
Rector\PHPUnit\Rector\MethodCall\SpecificAssertInternalTypeRector: ~
Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector: ~
Rector\Php52\Rector\Property\VarToPublicPropertyRector: ~
Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector: ~
Rector\Php53\Rector\Ternary\TernaryToElvisRector: ~
Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector: ~
Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector: ~
Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector: ~
Rector\Php55\Rector\String_\StringClassNameToClassConstantRector: ~
# inspired by level in psalm -
# https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063
Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector: ~
Rector\Php56\Rector\FuncCall\PowToExpRector: ~
Rector\Php70\Rector\FunctionLike\Php4ConstructorRector: ~
Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector: ~
Rector\Php70\Rector\FuncCall\RandomFunctionRector: ~
Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector: ~
Rector\Php70\Rector\FuncCall\MultiDirnameRector: ~
Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector: ~
Rector\Php70\Rector\List_\ListSplitStringRector: ~
Rector\Php70\Rector\List_\EmptyListRector: ~
Rector\Php70\Rector\FuncCall\CallUserMethodRector : ~
Rector\Php70\Rector\FuncCall\EregToPregMatchRector: ~
Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector: ~
Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector: ~
Rector\Php70\Rector\If_\IfToSpaceshipRector: ~
Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector: ~
Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector: ~
Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector: ~
Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector: ~
Rector\Php71\Rector\BinaryOp\IsIterableRector: ~
Rector\Php71\Rector\Name\ReservedObjectRector:
$reservedKeywordsToReplacements:
Object: 'BaseObject'
Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector: ~
Rector\Php71\Rector\Assign\AssignArrayToStringRector: ~
Rector\Php71\Rector\FuncCall\CountOnNullRector: ~
Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector: ~
Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector: ~
Rector\Php71\Rector\List_\ListToArrayDestructRector: ~
Rector\Php72\Rector\Each\WhileEachToForeachRector: ~
Rector\Php72\Rector\Each\ListEachRector: ~
Rector\Php72\Rector\Unset_\UnsetCastRector: ~
Rector\Php72\Rector\ConstFetch\BarewordStringRector: ~
Rector\Php72\Rector\FuncCall\GetClassOnNullRector: ~
Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector: ~
Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector: ~
Rector\Php72\Rector\FuncCall\StringsAssertNakedRector: ~
Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: ~
Rector\Php72\Rector\FuncCall\StringifyDefineRector: ~
Rector\Php73\Rector\BinaryOp\IsCountableRector: ~
Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector: ~
Rector\Php73\Rector\FuncCall\SensitiveDefineRector: ~
Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector: ~
Rector\Php73\Rector\String_\SensitiveHereNowDocRector: ~
Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector: ~
Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector: ~
Rector\Php73\Rector\FuncCall\RegexDashEscapeRector: ~
Rector\Php73\Rector\FuncCall\RemoveMissingCompactVariableRector: ~
Rector\Php74\Rector\Property\TypedPropertyRector: ~
Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector: ~
Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector: ~
Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector: ~
Rector\Php74\Rector\MagicConstClass\ClassConstantToSelfClassRector: ~
Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector: ~
Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector: ~
Rector\Php74\Rector\Double\RealToFloatTypeCastRector: ~
Rector\Php74\Rector\Assign\NullCoalescingOperatorRector: ~
Rector\Php74\Rector\Function_\ReservedFnFunctionRector: ~
Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector: ~
Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector: ~
Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector: ~
Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector: ~
Rector\Php80\Rector\FunctionLike\UnionTypesRector: ~
Rector\PhpDeglobalize\Rector\Class_\ChangeGlobalVariablesToPropertiesRector: ~
Rector\SOLID\Rector\ClassMethod\UseInterfaceOverImplementationInConstructorRector: ~
Rector\SOLID\Rector\If_\RemoveAlwaysElseRector: ~
Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector: ~
Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector: ~
Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector: ~
# Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector: ~
Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector: null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.