-
-
Notifications
You must be signed in to change notification settings - Fork 449
Expand file tree
/
Copy pathTypeDeclarationLevel.php
More file actions
203 lines (180 loc) · 11.1 KB
/
Copy pathTypeDeclarationLevel.php
File metadata and controls
203 lines (180 loc) · 11.1 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
declare(strict_types=1);
namespace Rector\Config\Level;
use Rector\CodeQuality\Rector\Class_\ReturnIteratorInDataProviderRector;
use Rector\Contract\Rector\RectorInterface;
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\BooleanAnd\BinaryOpNullableToInstanceofRector;
use Rector\TypeDeclaration\Rector\Class_\AddTestsVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\Class_\ChildDoctrineRepositoryClassTypeRector;
use Rector\TypeDeclaration\Rector\Class_\MergeDateTimePropertyTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Class_\ObjectTypedPropertyFromJMSSerializerAttributeTypeRector;
use Rector\TypeDeclaration\Rector\Class_\PropertyTypeFromStrictSetterGetterRector;
use Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector;
use Rector\TypeDeclaration\Rector\Class_\ScalarTypedPropertyFromJMSSerializerAttributeTypeRector;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromContainerGetSetUpRector;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromDocblockSetUpDefinedRector;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromGetRepositorySetUpRector;
use Rector\TypeDeclaration\Rector\Class_\TypedStaticPropertyInBehatContextRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamFromDimFetchKeyUseRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamStringTypeFromSprintfUseRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeFromTryCatchTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ArrayParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanConstReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanStrictReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\NarrowObjectReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ObjectParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\PrivateMethodReturnTypeFromStrictNewArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNullableTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromGetRepositoryDocblockRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromMockObjectRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnCastRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromSymfonySerializerRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ScalarParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector;
use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureNeverReturnTypeRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeFromAssertInstanceOfRector;
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
use Rector\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector;
use Rector\TypeDeclaration\Rector\FuncCall\AddArrayFunctionClosureParamTypeRector;
use Rector\TypeDeclaration\Rector\FuncCall\AddArrowFunctionParamArrayWhereDimFetchRector;
use Rector\TypeDeclaration\Rector\FuncCall\NarrowArrayAnyAllNullableParamTypeRector;
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayReduceRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeFromIterableMethodCallRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeFromVariableCallRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
use Rector\TypeDeclaration\Rector\While_\WhileNullableToInstanceofRector;
final class TypeDeclarationLevel
{
/**
* The rule order matters, as its used in withTypeCoverageLevel() method
* Place the safest rules first, follow by more complex ones
*
* @var array<class-string<RectorInterface>>
*/
public const array RULES = [
// php 7.1, start with closure first, as safest
AddClosureVoidReturnTypeWhereNoReturnRector::class,
AddFunctionVoidReturnTypeWhereNoReturnRector::class,
AddTestsVoidReturnTypeWhereNoReturnRector::class,
ReturnIteratorInDataProviderRector::class,
ReturnTypeFromMockObjectRector::class,
TypedPropertyFromCreateMockAssignRector::class,
AddArrowFunctionReturnTypeRector::class,
BoolReturnTypeFromBooleanConstReturnsRector::class,
// private methods first, as safest - no external contract
PrivateMethodReturnTypeFromStrictNewArrayRector::class,
ReturnTypeFromStrictNewArrayRector::class,
// scalar and array from constant
ReturnTypeFromStrictConstantReturnRector::class,
StringReturnTypeFromStrictScalarReturnsRector::class,
NumericReturnTypeFromStrictScalarReturnsRector::class,
BoolReturnTypeFromBooleanStrictReturnsRector::class,
StringReturnTypeFromStrictStringReturnsRector::class,
NumericReturnTypeFromStrictReturnsRector::class,
ReturnTypeFromStrictTernaryRector::class,
ReturnTypeFromReturnDirectArrayRector::class,
ResponseReturnTypeControllerActionRector::class,
ReturnTypeFromReturnNewRector::class,
ReturnTypeFromReturnCastRector::class,
ReturnTypeFromSymfonySerializerRector::class,
AddVoidReturnTypeWhereNoReturnRector::class,
ReturnTypeFromStrictTypedPropertyRector::class,
ReturnNullableTypeRector::class,
// php 7.4
EmptyOnNullableObjectToInstanceOfRector::class,
WhileNullableToInstanceofRector::class,
BinaryOpNullableToInstanceofRector::class,
// php 7.4
TypedPropertyFromStrictConstructorRector::class,
AddParamTypeSplFixedArrayRector::class,
AddReturnTypeDeclarationFromYieldsRector::class,
AddParamTypeBasedOnPHPUnitDataProviderRector::class,
TypedPropertyFromStrictSetUpRector::class,
ReturnTypeFromStrictNativeCallRector::class,
AddReturnTypeFromTryCatchTypeRector::class,
ReturnTypeFromStrictTypedCallRector::class,
ChildDoctrineRepositoryClassTypeRector::class,
// php native types
KnownMagicClassMethodTypeRector::class,
// param
AddMethodCallBasedStrictParamTypeRector::class,
ParamTypeByParentCallTypeRector::class,
NarrowObjectReturnTypeRector::class,
// multi types (nullable, union)
ReturnUnionTypeRector::class,
// closures
AddClosureNeverReturnTypeRector::class,
AddClosureParamTypeForArrayMapRector::class,
AddClosureParamTypeForArrayReduceRector::class,
ClosureReturnTypeRector::class,
AddArrowFunctionParamArrayWhereDimFetchRector::class,
// more risky rules
ReturnTypeFromStrictParamRector::class,
AddParamTypeFromPropertyTypeRector::class,
MergeDateTimePropertyTypeDeclarationRector::class,
PropertyTypeFromStrictSetterGetterRector::class,
ParamTypeByMethodCallTypeRector::class,
ObjectParamTypeByMethodCallTypeRector::class,
ScalarParamTypeByMethodCallTypeRector::class,
ArrayParamTypeByMethodCallTypeRector::class,
TypedPropertyFromContainerGetSetUpRector::class,
TypedPropertyFromGetRepositorySetUpRector::class,
TypedPropertyFromAssignsRector::class,
AddReturnTypeDeclarationBasedOnParentClassMethodRector::class,
ReturnTypeFromStrictFluentReturnRector::class,
ReturnNeverTypeRector::class,
// jms attributes
ObjectTypedPropertyFromJMSSerializerAttributeTypeRector::class,
ScalarTypedPropertyFromJMSSerializerAttributeTypeRector::class,
// array parameter from dim fetch assign inside
AddClosureParamTypeFromVariableCallRector::class,
StrictArrayParamDimFetchRector::class,
AddParamFromDimFetchKeyUseRector::class,
AddParamStringTypeFromSprintfUseRector::class,
// possibly based on docblocks, but also helpful, intentionally last
AddArrayFunctionClosureParamTypeRector::class,
TypedPropertyFromDocblockSetUpDefinedRector::class,
AddClosureParamTypeFromIterableMethodCallRector::class,
TypedStaticPropertyInBehatContextRector::class,
// PHP 8.4
NarrowArrayAnyAllNullableParamTypeRector::class,
AddArrayAnyAllClosureParamTypeRector::class,
ClosureReturnTypeFromAssertInstanceOfRector::class,
// docblock @return into native return type, intentionally last
ReturnTypeFromGetRepositoryDocblockRector::class,
];
}