Repository navigation
Expand file tree
/
Copy pathphpstan.neon
More file actions
362 lines (305 loc) · 14.9 KB
/
Copy pathphpstan.neon
File metadata and controls
362 lines (305 loc) · 14.9 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
includes:
- vendor/symplify/phpstan-rules/config/rector-rules.neon
- phpstan-deprecated.neon
rules:
- Rector\Utils\PHPStan\Rule\RegisterRelatedPolyfillRectorRule
- Rector\Utils\PHPStan\Rule\NoResolveClassReflectionInForeachRule
- Rector\Utils\PHPStan\Rule\NoGetClassReflectionOnScopeRule
- Rector\Utils\PHPStan\Rule\RegisterRectorRule
parameters:
level: 8
# reportUnmatchedIgnoredErrors: false
errorFormat: symplify
# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
typeAliases:
StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\FileNode | \PhpParser\Node\Stmt\Declare_
# requires exact closure types
checkMissingCallableSignature: true
treatPhpDocTypesAsCertain: false
paths:
- bin
- config
- src
- rules
- scripts
# tests
- tests
- rules-tests
- utils
- scripts
- rector.php
- e2e/e2eTestRunner.php
scanDirectories:
- stubs
excludePaths:
- '*tests/*/Fixture/*'
- '*tests/*/Fixture*'
- '*tests/*/Source/*'
- '*tests/*/Source*'
# standalone dev benchmark, shells out and parses getopt by hand
- 'scripts/rector-jobsize-benchmark.php'
- 'scripts/rector-ab-benchmark.php'
# see https://github.com/symplify/phpstan-rules
symplify:
pathStrings: true
naming: true
complexity: true
configurable: true
static: true
phpunit: true
mocks: true
ctor: true
modern: true
# see https://github.com/TomasVotruba/type-coverage
type_coverage:
return_type: 99
param_type: 99
property_type: 99
constant_type: 99
type_perfect:
no_mixed: true
null_over_false: true
narrow_param: true
narrow_return: true
# offload breaks cold-cache parallel runs, keep collector data in result cache
shipmonkDeadCode:
cache:
offloadCollectorData: false
ignoreErrors:
# Scope is the correct source of the enclosing class reflection in the engine resolvers,
# in rules that reuse the same Scope for other calls, and in ObjectTypeSpecifier where the
# scope reflection is refreshed on class change while ReflectionProvider reads the original file
-
identifier: rector.getClassReflectionOnScope
paths:
- rules/DeadCode/Rector/ClassMethod/RemoveReturnTagIncompatibleWithNativeTypeRector.php
- rules/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector.php
- rules/Php55/Rector/FuncCall/GetCalledClassToStaticClassRector.php
- rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php
- rules/Php81/Rector/New_/MyCLabsConstructorCallToEnumFromRector.php
- rules/Renaming/Rector/MethodCall/RenameMethodRector.php
- rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php
- rules/TypeDeclaration/Rector/Closure/ClosureReturnTypeFromAssertInstanceOfRector.php
- src/Application/ChangedNodeScopeRefresher.php
- src/NodeTypeResolver/NodeTypeResolver.php
- src/NodeTypeResolver/NodeTypeResolver/NameTypeResolver.php
- src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php
- src/Reflection/ReflectionResolver.php
- src/StaticTypeMapper/Naming/NameScopeFactory.php
- utils/phpstan/src/Rule/NoResolveClassReflectionInForeachRule.php
# called magically by parent
-
message: '#^Unused Rector\\PhpParser\\Printer\\BetterStandardPrinter\:\:(pInterpolatedStringPart|pStmt_FileNode)$#'
identifier: shipmonk.deadMethod
path: src/PhpParser/Printer/BetterStandardPrinter.php
-
identifier: argument.templateType
path: rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php
-
identifier: argument.type
message: '#(.*?) class\-string, string given#'
-
identifier: argument.type
message: '#Parameter \#1 \$phpVersion of method Rector\\Config\\RectorConfig\:\:phpVersion\(\) expects 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|80500\|80600\|100000, 79999 given#'
# node vs stmts mix
-
identifier: argument.type
message: '#expects array<PhpParser\\Node\\Stmt>, array<PhpParser\\Node> given#'
# unable for the downgraded rector to find the class, but it is there
- identifier: symplify.commandHasAsCommandAttribute
# false positive, can accept non-class string
-
identifier: argument.type
message: '#Parameter \#1 \$name of method PHPStan\\BetterReflection\\Reflection\\Adapter\\ReflectionClass\:\:getAttributes\(\) expects class\-string\|null, string given#'
# false positive, checked above
-
identifier: argument.type
message: '#Parameter \#1 \$items of class PhpParser\\Node\\Expr\\Array_ constructor expects array<PhpParser\\Node\\ArrayItem>, array<PhpParser\\Node\\ArrayItem\|null> given#'
path: rules/Php71/Rector/List_/ListToArrayDestructRector.php
# scope vs mutating scope
-
identifier: argument.type
message: '#Parameter \#3 \$nodeCallback of method PHPStan\\Analyser\\NodeScopeResolver\:\:processNodes\(\) expects callable\(PhpParser\\Node, PHPStan\\Analyser\\Scope\)\: void, callable\(PhpParser\\Node, PHPStan\\Analyser\\MutatingScope\)\: void given#'
# list vs array
-
identifier: argument.type
message: '#Parameter (.*?) expects list<(.*?)>, array<(.*?)> given#'
-
identifier: argument.type
paths:
- rules/Privatization/TypeManipulator/TypeNormalizer.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php
- rules/TypeDeclarationDocblocks/Rector/Class_/AddVarArrayDocblockFromDimFetchAssignRector.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
# classes are part of *.php.inc fixture
-
identifier: class.notFound
message: '#Class (.*?) not found#'
paths:
- rules-tests/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector/config
- rules-tests/Renaming/Rector/Name/RenameClassRector/config
- rules-tests/Renaming/Rector/MethodCall/RenameMethodRector/config
- rules-tests/Arguments/Rector/ClassMethod/ArgumentAdderRector/config
-
identifier: deadCode.unreachable
paths:
- src/Console/Notifier.php
- src/Util/FileHasher.php
# stmts aware/expression generics
-
identifier: generics.notGeneric
message: '#PhpParser\\Node\\Stmt\\Expression is not generic#'
# runtime php id
-
identifier: greaterOrEqual.alwaysTrue
path: src/Util/FileHasher.php
# runtime comparison
-
identifier: greaterOrEqual.alwaysTrue
message: '#Comparison operation ".*" between int<\d+, \d+> and \d+ is always true#'
# required generics on interface array, not helpful
-
identifier: missingType.generics
message: '#Method (.*?)\:\:__construct\(\) has parameter#'
-
identifier: missingType.generics
message: '#(.*?) with generic interface (.*?)Interface does not specify its types#'
# generated class in /vendor
-
identifier: nullCoalesce.offset
message: '#Offset (.*?) on null on left side of \?\? does not exist#'
path: src/Bootstrap/ExtensionConfigResolver.php
# false positive
-
identifier: offsetAccess.invalidOffset
path: src/CustomRules/SimpleNodeDumper.php
-
identifier: offsetAccess.nonArray
path: src/PhpParser/NodeTraverser/RectorNodeTraverser.php
# phpstan internalls
- identifier: phpstanApi.class
- identifier: phpstanApi.classConstant
- identifier: phpstanApi.constructor
- identifier: phpstanApi.instanceofAssumption
- identifier: phpstanApi.method
# buggy, # see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110
-
identifier: phpstanApi.instanceofType
message: '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'
# is nested expr
-
identifier: property.notFound
paths:
- rules/DeadCode/NodeManipulator/LivingCodeManipulator.php
- src/PhpParser/Printer/BetterStandardPrinter.php
- src/CustomRules/SimpleNodeDumper.php
-
identifier: rector.noClassReflectionStaticReflection
paths:
- scripts
- src/Configuration/OnlyRuleResolver.php
- src/Util/Reflection/PrivatesAccessor.php
# the local instanceof for known types
-
identifier: rector.noInstanceOfStaticReflection
message: '#Instead of "instanceof/is_a\(\)" use ReflectionProvider service or "\(new ObjectType\(<desired_type>\)\)\->isSuperTypeOf\(<element_type>\)" for static reflection to work#'
# outside sets on purpose, as risky
-
identifier: rector.upgradeDowngradeRegisteredInSet
paths:
- rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php
- rules/Php80/Rector/NotIdentical/MbStrContainsRector.php
# not registered in a rector-src set on purpose: NullToStrictString is opt-in only (risky),
# the rest are registered in third-party sets (rector-laravel, drupal-rector) that cannot be
# installed here due to the rector/rector replace
-
identifier: rector.registerRector
paths:
- rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php
# lack of generic array in nikic/php-parser
-
identifier: return.type
message: '#Method (.*?) should return array<PhpParser\\Node\\(.*?)\> but returns array<PhpParser\\Node\>#'
# generics nullable bugs
-
identifier: return.type
paths:
- src/PhpParser/Node/BetterNodeFinder.php
- rules/DeadCode/Rector/Class_/RemoveRefactorDuplicatedNodeInstanceCheckRector.php
# known value
-
identifier: return.type
message: '#Method (.*?) should return 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|80500\|80600\|100000 but returns int#'
# from constant string
-
identifier: return.type
message: '#Method Rector\\.*::filterPolyfillPackages\(\) should return array\<#'
-
identifier: return.type
paths:
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
# from mapper interface
-
identifier: return.unusedType
message: '#mapToPhpParserNode\(\) never returns PhpParser\\.* so it can be removed from the return#'
# false positive
-
identifier: return.unusedType
message: '#Method (.*?)refactor\(\) (never returns|should return) (.*?)#'
path: rules/Php70/Rector/If_/IfToSpaceshipRector.php
-
identifier: symplify.forbiddenFuncCall
message: '#Function "property_exists\(\)" cannot be used/left in the code#'
paths:
- src/NodeNameResolver/NodeNameResolver.php
-
identifier: symplify.forbiddenFuncCall
message: '#Function "class_exists\(\)" cannot be used/left in the code#'
paths:
- bin/rector.php
- src/Bootstrap/ExtensionConfigResolver.php
- src/Configuration/RectorConfigBuilder.php
- src/Validation/RectorConfigValidator.php
- src/Testing/PHPUnit/AbstractLazyTestCase.php
- src/Configuration/OnlyRuleResolver.php
# debug and internal functions
-
identifier: symplify.forbiddenFuncCall
paths:
- src/functions/node_helper.php
- src/functions/rule_class_aliases.php
- src/Util/Reflection/PrivatesAccessor.php
# it may return array<Node|null> in case of empty array( , , ), very rare and would nullify all other types
- '#Method Rector\\PhpParser\\NodeTraverser\\RectorNodeTraverser\:\:traverseArray\(\) should return array<PhpParser\\Node> but returns array<PhpParser\\Node\|null>#'
# checks for rector always autoloaded rules only
-
identifier: symplify.forbiddenFuncCall
message: '#Function "(class_exists|interface_exists)\(\)" cannot be used/left in the code\: use ReflectionProvider\->has\*\(\) instead#'
paths:
- src/Skipper/Skipper/Skipper.php
-
identifier: symplify.noConstructorOverride
path: src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php
# dynamic printer
-
identifier: symplify.noDynamicName
message: '#Use explicit names over dynamic ones#'
# reference params in legacy/perf code, kept as original
-
identifier: symplify.noReference
message: '#Use explicit return value over magic &reference#'
paths:
- rules/Php70/EregToPcreTransformer.php
- src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
- rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php
- src/Parallel/Application/ParallelFileProcessor.php
-
identifier: symplify.noNullableServiceInConstructor
path: src/NodeTypeResolver/PHPStan/ObjectWithoutClassTypeWithParentTypes.php
# fixture Rector rules
-
identifier: symplify.seeAnnotationToTest
paths:
- tests/Issues/
- tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/Class_