-
-
Notifications
You must be signed in to change notification settings - Fork 448
Expand file tree
/
Copy pathphpstan.neon
More file actions
421 lines (348 loc) · 16.9 KB
/
Copy pathphpstan.neon
File metadata and controls
421 lines (348 loc) · 16.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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
includes:
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
- vendor/symplify/phpstan-rules/config/rector-rules.neon
rules:
- Rector\Utils\PHPStan\Rule\RegisterRelatedPolyfillRectorRule
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
# tests
- tests
- rules-tests
- utils
- scripts
- rector.php
- e2e/e2eTestRunner.php
scanDirectories:
- stubs
excludePaths:
- '*tests/*/Fixture/*'
- '*tests/*/Fixture*'
- '*tests/*/Source/*'
- '*tests/*/Source*'
# see https://github.com/symplify/phpstan-rules
symplify:
pathStrings: true
# see https://github.com/TomasVotruba/type-coverage
type_coverage:
declare: 99
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
# see https://github.com/TomasVotruba/unused-public
unused_public:
methods: true
properties: true
constants: true
ignoreErrors:
# keepComments() is a generic helper; do not narrow it after the deprecated CombineIfRector stopped calling it
-
identifier: typePerfect.narrowPublicClassMethodParamType
path: src/BetterPhpDocParser/Comment/CommentsMerger.php
# the deprecated set objects are still resolved internally, until every extension bonds its rules
-
message: '#deprecated (class|interface) Rector\\(Set|Bridge)\\#'
path: src/Configuration/RectorConfigBuilder.php
# EARLY_RETURN set is deprecated (empty, merged into code-quality), still mapped internally until removed
-
identifier: classConstant.deprecated
paths:
- src/Configuration/RectorConfigBuilder.php
# the deprecated SetList::PHP_* constants are still resolved internally by the level sets and their tests
-
identifier: classConstant.deprecated
paths:
- config/set/level
- tests/Bridge/SetRectorsResolverTest.php
# the deprecated github/gitlab output formatters are still tested until removed in next minor version
-
identifier: new.deprecatedClass
path: tests/ChangesReporting/Output/GitHubOutputFormatterTest.php
-
identifier: method.deprecatedClass
path: tests/ChangesReporting/Output/GitHubOutputFormatterTest.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#'
# 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
-
identifier: argument.type
message: '#Parameter \#3 \$assign of method Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector\:\:processSimplifyUselessVariable\(\) expects PhpParser\\Node\\Expr\\Assign\|PhpParser\\Node\\Expr\\AssignOp, PhpParser\\Node\\Expr given#'
path: rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.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
-
identifier: arguments.count
message: '#Callable callable\(PHPStan\\Type\\Type\)\: PHPStan\\Type\\Type invoked with 2 parameters, 1 required#'
# classes are part of *.php.inc fixture
-
identifier: class.notFound
message: '#Class (.*?) not found#'
paths:
- rules-tests/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector/config
- 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#'
# known value object, nullable due to typed property
-
identifier: method.nonObject
message: '#Cannot call method (.*?)\(\) on (.*?)\\ProcessPool\|null#'
path: src/Parallel/Application/ParallelFileProcessor.php
-
identifier: missingType.callable
message: '#Method Rector\\Util\\ArrayParametersMerger\:\:mergeLeftToRightWithCallable\(\) has parameter \$mergeCallback with no signature specified for callable#'
path: src/Util/ArrayParametersMerger.php
# 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
# known non-empty class method
-
identifier: offsetAccess.notFound
message: '#Offset 0 might not exist on array<PhpParser\\Node\\Stmt>\|null#'
path: rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php
-
identifier: offsetAccess.notFound
message: '#Offset float\|int\|string might not exist on string#'
path: rules/Php70/EregToPcreTransformer.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
# 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
- rules/Arguments/ArgumentDefaultValueReplacer.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
- src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
- src/BetterPhpDocParser/NodeDecorator/DoctrineAnnotationDecorator.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/Reporting/DeprecatedRulesReporter.php
- src/Configuration/OnlyRuleResolver.php
# debug and internal functions
-
identifier: symplify.forbiddenFuncCall
paths:
- src/functions/node_helper.php
- tests/debug_functions.php
- src/Util/Reflection/PrivatesAccessor.php
# 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/SkipCriteriaResolver/SkippedClassResolver.php
# native filesystem calls, required for performance reasons
-
identifier: symplify.forbiddenNode
message: '#@(.*?) is forbidden to use#'
path: src/Caching/ValueObject/Storage/FileCacheStorage.php
-
identifier: symplify.forbiddenNode
message: '#@\\ini_set\(.*\)" is forbidden to use#'
path: bin/rector.php
-
message: '#PHPDoc tag @var with type array<string> is not subtype of native type array#'
path: src/Bootstrap/ExtensionConfigResolver.php
-
identifier: symplify.forbiddenStaticClassConstFetch
message: '#Avoid static access of constants, as they can change value\. Use interface and contract method instead#'
paths:
- src/PostRector/Rector/AbstractPostRector.php
- src/Testing/PHPUnit/AbstractRectorTestCase.php
-
identifier: symplify.forbiddenStaticClassConstFetch
path: src/Rector/AbstractRector.php
-
identifier: symplify.noConstructorOverride
path: src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php
# dynamic printer
-
identifier: symplify.noDynamicName
message: '#Use explicit names over dynamic ones#'
paths:
- src/CustomRules/SimpleNodeDumper.php
- src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php
# copied from /vendor, to keep as original as possible
-
identifier: symplify.noDynamicName
path: src/PhpParser/NodeTraverser/RectorNodeTraverser.php
-
identifier: symplify.noReference
message: '#Use explicit return value over magic &reference#'
paths:
- src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php
- rules/Php70/EregToPcreTransformer.php
- src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
-
identifier: symplify.noReference
message: '#Use explicit return value over magic &reference#'
# fixture Rector rules
-
identifier: symplify.seeAnnotationToTest
paths:
- tests/Issues/
- tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/Class_
-
identifier: typePerfect.noMixedMethodCaller
path: src/PhpParser/Parser/RectorParser.php
# known types
-
identifier: varTag.nativeType
message: '#PHPDoc tag @var with type array<string, int> is not subtype of native type array<int<1, max>>#'
path: rules/Naming/PhpArray/ArrayFilter.php
-
identifier: varTag.nativeType
path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php