-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathDeadCodeLevel.php
More file actions
149 lines (137 loc) · 7.06 KB
/
DeadCodeLevel.php
File metadata and controls
149 lines (137 loc) · 7.06 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
declare(strict_types=1);
namespace Rector\Config\Level;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
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\Block\ReplaceBlockToItsStmtsRector;
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
use Rector\DeadCode\Rector\ClassLike\RemoveTypedPropertyNonMockDocblockRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveArgumentFromDefaultParentCallRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector;
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\RemoveUnusedPublicMethodParameterRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessAssignFromPropertyPromotionRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnExprInConstructRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector;
use Rector\DeadCode\Rector\Concat\RemoveUnusedClosureVariableUseRector;
use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector;
use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector;
use Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector;
use Rector\DeadCode\Rector\For_\RemoveDeadContinueRector;
use Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector;
use Rector\DeadCode\Rector\For_\RemoveDeadLoopRector;
use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector;
use Rector\DeadCode\Rector\FuncCall\RemoveFilterVarOnExactTypeRector;
use Rector\DeadCode\Rector\FunctionLike\NarrowTooWideReturnTypeRector;
use Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector;
use Rector\DeadCode\Rector\If_\ReduceAlwaysFalseIfOrRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\DeadCode\Rector\If_\RemoveTypedPropertyDeadInstanceOfRector;
use Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector;
use Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector;
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
use Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\DeadCode\Rector\Property\RemoveUselessReadOnlyTagRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector;
use Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector;
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
use Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector;
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
use Rector\DeadCode\Rector\TryCatch\RemoveDeadCatchRector;
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
/**
* Key 0 = level 0
* Key 50 = level 50
*
* Start at 0, go slowly higher, one level per PR, and improve your rule coverage
*
* From the safest rules to more changing ones.
*
* @experimental Since 0.19.7 This list can change in time, based on community feedback,
* what rules are safer than other. The safest rules will be always in the top.
*/
final class DeadCodeLevel
{
/**
* Mind that return type declarations are the safest to add,
* followed by property, then params
*
* @var array<class-string<RectorInterface>>
*/
public const RULES = [
// easy picks
RemoveUnusedForeachKeyRector::class,
RemoveDuplicatedArrayKeyRector::class,
RecastingRemovalRector::class,
RemoveAndTrueRector::class,
SimplifyMirrorAssignRector::class,
RemoveDeadContinueRector::class,
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
RemoveNullPropertyInitializationRector::class,
RemoveUselessReturnExprInConstructRector::class,
ReplaceBlockToItsStmtsRector::class,
RemoveFilterVarOnExactTypeRector::class,
RemoveTypedPropertyDeadInstanceOfRector::class,
TernaryToBooleanOrFalseToBooleanAndRector::class,
RemoveDoubleAssignRector::class,
RemoveUselessAssignFromPropertyPromotionRector::class,
RemoveConcatAutocastRector::class,
SimplifyIfElseWithSameContentRector::class,
SimplifyUselessVariableRector::class,
RemoveDeadZeroAndOneOperationRector::class,
// docblock
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveUselessReadOnlyTagRector::class,
RemoveNonExistingVarAnnotationRector::class,
RemoveUselessVarTagRector::class,
// prioritize safe belt on RemoveUseless*TagRector that registered previously first
RemoveNullTagValueNodeRector::class,
RemovePhpVersionIdCheckRector::class,
RemoveTypedPropertyNonMockDocblockRector::class,
RemoveAlwaysTrueIfConditionRector::class,
ReduceAlwaysFalseIfOrRector::class,
RemoveUnusedPrivateClassConstantRector::class,
RemoveUnusedPrivatePropertyRector::class,
RemoveUnusedClosureVariableUseRector::class,
RemoveDuplicatedCaseInSwitchRector::class,
RemoveDeadInstanceOfRector::class,
RemoveDeadCatchRector::class,
RemoveDeadTryCatchRector::class,
RemoveDeadIfForeachForRector::class,
RemoveDeadStmtRector::class,
UnwrapFutureCompatibleIfPhpVersionRector::class,
RemoveParentCallWithoutParentRector::class,
RemoveDeadConditionAboveReturnRector::class,
RemoveDeadLoopRector::class,
// removing methods could be risky if there is some magic loading them
RemoveUnusedPromotedPropertyRector::class,
RemoveUnusedPrivateMethodParameterRector::class,
RemoveUnusedPublicMethodParameterRector::class,
RemoveUnusedPrivateMethodRector::class,
RemoveUnreachableStatementRector::class,
RemoveUnusedVariableAssignRector::class,
// this could break framework magic autowiring in some cases
RemoveUnusedConstructorParamRector::class,
RemoveEmptyClassMethodRector::class,
RemoveDeadReturnRector::class,
RemoveArgumentFromDefaultParentCallRector::class,
NarrowTooWideReturnTypeRector::class,
];
}