code-quality/config/rector.php

93 lines
5 KiB
PHP
Raw Normal View History

2022-10-12 17:46:05 +00:00
<?php declare(strict_types=1);
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector;
use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector;
use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
2022-12-12 19:01:10 +00:00
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
2022-10-12 17:46:05 +00:00
use Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector;
use Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector;
use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
2023-09-01 05:52:22 +00:00
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
2022-10-12 17:46:05 +00:00
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector;
2022-12-12 19:01:10 +00:00
use Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector;
2022-10-12 17:46:05 +00:00
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
2022-12-12 19:01:10 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;
2022-10-12 17:46:05 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
2022-12-12 19:01:10 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
2022-10-12 17:46:05 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
2022-12-12 19:01:10 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector;
2022-10-12 17:46:05 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector;
2022-12-12 19:01:10 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
2022-10-12 17:46:05 +00:00
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
2022-12-12 19:01:10 +00:00
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector;
2022-10-12 17:46:05 +00:00
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
return RectorConfig::configure()
2024-02-03 09:58:53 +00:00
->withPhpSets(php83: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
earlyReturn: true,
strictBooleans: true,
)
->withRules([
2022-10-12 17:46:05 +00:00
AddArrowFunctionReturnTypeRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
2022-12-12 19:01:10 +00:00
AddParamTypeFromPropertyTypeRector::class,
AddParamTypeSplFixedArrayRector::class,
2022-10-12 17:46:05 +00:00
AddReturnTypeDeclarationBasedOnParentClassMethodRector::class,
2022-12-12 19:01:10 +00:00
AddReturnTypeDeclarationFromYieldsRector::class,
2022-10-12 17:46:05 +00:00
BooleanNotIdenticalToNotIdenticalRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeNestedIfsToEarlyReturnRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
2022-12-12 19:01:10 +00:00
ClassOnThisVariableObjectRector::class,
2022-10-12 17:46:05 +00:00
CountArrayToEmptyArrayComparisonRector::class,
ExplicitBoolCompareRector::class,
InlineArrayReturnAssignRector::class,
InlineIsAInstanceOfRector::class,
NewlineBeforeNewAssignSetRector::class,
NullableCompareToNullRector::class,
ParamTypeByMethodCallTypeRector::class,
ParamTypeByParentCallTypeRector::class,
PreparedValueToEarlyReturnRector::class,
ReplaceMultipleBooleanNotRector::class,
ReturnBinaryOrToEarlyReturnRector::class,
ReturnEarlyIfVariableRector::class,
2022-12-12 19:01:10 +00:00
ReturnTypeFromReturnDirectArrayRector::class,
2022-10-12 17:46:05 +00:00
ReturnTypeFromReturnNewRector::class,
2022-12-12 19:01:10 +00:00
ReturnTypeFromStrictConstantReturnRector::class,
2022-10-12 17:46:05 +00:00
ReturnTypeFromStrictNativeCallRector::class,
ReturnTypeFromStrictNewArrayRector::class,
2022-12-12 19:01:10 +00:00
ReturnTypeFromStrictTypedCallRector::class,
2022-10-12 17:46:05 +00:00
ReturnTypeFromStrictTypedPropertyRector::class,
SimplifyConditionsRector::class,
SimplifyEmptyArrayCheckRector::class,
2022-12-12 19:01:10 +00:00
SimplifyEmptyCheckOnEmptyArrayRector::class,
2022-10-12 17:46:05 +00:00
StaticArrowFunctionRector::class,
StaticClosureRector::class,
ThrowWithPreviousExceptionRector::class,
TypedPropertyFromStrictConstructorRector::class,
2023-09-01 05:52:22 +00:00
RemoveAlwaysElseRector::class,
])
;