-
Notifications
You must be signed in to change notification settings - Fork 5
/
rector.php
93 lines (90 loc) · 4.05 KB
/
rector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Rector Configuration
*
* phpcs:disable
*/
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\Config\RectorConfig;
use Rector\Contract\Rector\RectorInterface;
use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector;
use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector;
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
/**
* Rector Configuration
*
* Overtime this file will have more rules enabled for it. Right now, most of
* them are commented out. They will be spread out over multiple pull requests.
*
* Rules that are known to cause issues and should not be used:
*
* - RenameForeachValueVariableToMatchMethodCallReturnTypeRector: causes variables to be converted to snakeCase
* - RemoveUselessParamTagRector: Conflicts with WordPress Coding Standards
* - MixedTypeRector: Conflicts with WordPress Coding Standards
* - ChangeOrIfContinueToMultiContinueRector: doesn't make sense.
*/
return RectorConfig::configure()
->withIndent( "\t" )
->withPaths( [ __DIR__ . '/src' ] )
->withPreparedSets(
earlyReturn: true,
deadCode: true,
instanceOf: true,
)
->withTypeCoverageLevel(7)
->withPhpSets( php81: true )
->withRules(
[
AddVoidReturnTypeWhereNoReturnRector::class,
RenameForeachValueVariableToMatchExprVariableRector::class,
LongArrayToShortArrayRector::class,
]
)
->withSkip([
AddVoidReturnTypeWhereNoReturnRector::class => [
__DIR__ . '/src/mantle/testing/concerns/trait-core-shim.php',
__DIR__ . '/tests/Testing/CoreTestShimTest.php',
__DIR__ . '/tests/testing/CoreTestShimTest.php',
],
RemoveUselessParamTagRector::class,
MixedTypeRector::class,
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class,
FirstClassCallableRector::class,
StrContainsRector::class,
AddArrowFunctionReturnTypeRector::class,
ChangeAndIfToEarlyReturnRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
RemoveAlwaysElseRector::class,
EmptyOnNullableObjectToInstanceOfRector::class,
ReturnBinaryOrToEarlyReturnRector::class => [
__DIR__ . '/src/mantle/http-client/class-response.php',
],
]);