-
-
Notifications
You must be signed in to change notification settings - Fork 359
/
phpstan.neon
345 lines (266 loc) · 15.1 KB
/
phpstan.neon
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
includes:
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
- vendor/symplify/phpstan-rules/config/rector-rules.neon
parameters:
level: 8
reportUnmatchedIgnoredErrors: false
errorFormat: symplify
# requires exact closure types
checkMissingCallableSignature: true
treatPhpDocTypesAsCertain: false
paths:
- rector.php
- bin
- config
- src
- rules
# tests
- tests
- rules-tests
- utils
scanDirectories:
- stubs
scanFiles:
- src/Contract/PhpParser/Node/StmtsAwareInterface.php
excludePaths:
- '*tests/*/Fixture/*'
- '*tests/*/Fixture*'
- '*tests/*/Source/*'
- '*tests/*/Source*'
# https://github.com/rectorphp/type-perfect/
type_perfect:
no_mixed: true
null_over_false: true
narrow_param: true
narrow_return: true
ignoreErrors:
-
identifier: missingType.generics
# phpstan class instance
- identifier: phpstanApi.class
# phpstan class constant value
- identifier: phpstanApi.classConstant
# phpstan instanceof
- identifier: phpstanApi.instanceofAssumption
# assert phpunit
-
identifier: method.alreadyNarrowedType
path: tests
# runtime php id
-
identifier: greaterOrEqual.alwaysTrue
path: src/Util/FileHasher.php
-
identifier: phpstanApi.constructor
# on runtime check
-
identifier: deadCode.unreachable
paths:
- src/Console/Notifier.php
- src/Util/FileHasher.php
# -
# identifier: argument.type
# is nested expr
-
message: '#Access to an undefined property PhpParser\\Node\\Expr\:\:\$expr#'
path: rules/DeadCode/NodeManipulator/LivingCodeManipulator.php
-
message: '#Function "var_dump\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php
# lack of generic array in nikic/php-parser
- '#Method (.*?) should return array<PhpParser\\Node\\(.*?)\> but returns array<PhpParser\\Node\>#'
# generics nullable bugs
-
message: '#Method (.*?) should return (.*?)\|null but returns PhpParser\\Node\|null#'
path: src/PhpParser/Node/BetterNodeFinder.php
-
message: '#Function "property_exists\(\)" cannot be used/left in the code#'
paths:
# on PhpParser Nodes
- src/NodeNameResolver/NodeNameResolver.php
- src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
- src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php
- '#(.*?) class\-string, string given#'
-
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
- '#Method Rector\\Arguments\\ArgumentDefaultValueReplacer\:\:processReplaces\(\) should return \(TCall of PhpParser\\Node\\Expr\\FuncCall\|PhpParser\\Node\\Expr\\MethodCall\|PhpParser\\Node\\Expr\\New_\|PhpParser\\Node\\Expr\\StaticCall\|PhpParser\\Node\\Stmt\\ClassMethod\)\|null but returns PhpParser\\Node\\Stmt\\ClassMethod\|null#'
# native filesystem calls, required for performance reasons
-
message: '#@(.*?) is forbidden to use#'
paths:
- src/Caching/ValueObject/Storage/FileCacheStorage.php
# many internal cases
- '#Calling (.*?) is not covered by backward compatibility promise\. The method might change in a minor PHPStan version#'
# known value object, nullable due to typed property
-
message: '#Cannot call method (.*?)\(\) on (.*?)\\ProcessPool\|null#'
path: src/Parallel/Application/ParallelFileProcessor.php
-
message: '#Use value object over return of values#'
paths:
- src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParser.php
- rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php
- rules/Php70/EregToPcreTransformer.php
# internal reflection
- '#Instead of "new ClassReflection\(\)" use ReflectionProvider service or "\(new PHPStan\\Reflection\\ClassReflection\(<desired_type>\)\)" for static reflection to work#'
- '#Callable callable\(PHPStan\\Type\\Type\)\: PHPStan\\Type\\Type invoked with 2 parameters, 1 required#'
# known value
- '#Method (.*?) should return 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|100000 but returns int#'
-
message: '#Function "class_exists\(\)" cannot be used/left in the code#'
paths:
# autoload check in bin file
- bin/rector.php
# for config class reflection
- src/Bootstrap/ExtensionConfigResolver.php
- src/Validation/RectorConfigValidator.php
# use of internal phpstan classes
-
message: '#Creating new PHPStan\\Reflection\\BetterReflection\\SourceLocator\\Optimized(.*?)SourceLocator is not covered by backward compatibility promise\. The class might change in a minor PHPStan version#'
path: src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php
-
message: '#@\\ini_set\(.*\)" is forbidden to use#'
path: bin/rector.php
-
message: '#Creating new PHPStan\\Parser\\(CachedParser|SimpleParser) is not covered by backward compatibility promise\. The class might change in a minor PHPStan version#'
path: src/PhpDocParser/PhpParser/SmartPhpParserFactory.php
# known existing class
-
message: '#Instead of "instanceof/is_a\(\)" use ReflectionProvider service or "\(new ObjectType\(<desired_type>\)\)\->isSuperTypeOf\(<element_type>\)" for static reflection to work#'
path: src/Skipper/Skipper/SkipSkipper.php
# the local instanceof for known types
- '#Instead of "instanceof/is_a\(\)" use ReflectionProvider service or "\(new ObjectType\(<desired_type>\)\)\->isSuperTypeOf\(<element_type>\)" for static reflection to work#'
# required for reflection
-
message: '#Function "(.*?)\(\)" cannot be used/left in the code#'
path: src/Util/Reflection/PrivatesAccessor.php
-
message: '#Method Rector\\Util\\ArrayParametersMerger\:\:mergeLeftToRightWithCallable\(\) has parameter \$mergeCallback with no signature specified for callable#'
path: src/Util/ArrayParametersMerger.php
# fixture class
- '#Class "Rector\\Tests\\Issues\\ScopeNotAvailable\\Variable\\ArrayItemForeachValueRector" is missing @see annotation with test case class reference#'
-
message: '#Class (.*?) not found#'
paths:
- rules-tests/*/config/*
-
message: '#Function "(function_exists|dump_node)\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php
# false positive on enums
- '#Method Rector\\Console\\Command\\SetupCICommand\:\:resolveCurrentCI\(\) never returns (.*?) so it can be removed from the return type#'
# stmts aware/expression generics
- '#PhpParser\\Node\\Stmt\\Expression is not generic#'
# chicken/egg
-
message: '#Function "(d|dd)\(\)" cannot be used/left in the code#'
path: tests/debug_functions.php
# debug functions
-
message: '#Function "function_exists\(\)" cannot be used/left in the code\: use ReflectionProvider\->has\*\(\) instead#'
path: tests/debug_functions.php
# checks for rector always autoloaded rules only
-
message: '#Function "(class_exists|interface_exists)\(\)" cannot be used/left in the code\: use ReflectionProvider\->has\*\(\) instead#'
path: src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php
- '#(.*?)\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#'
# dev rule
- '#Class "Rector\\Utils\\Rector\\MoveAbstractRectorToChildrenRector" is missing @see annotation with test case class reference#'
# optional as changes behavior, should be used explicitly outside PHP upgrade
- '#Register "Rector\\Php73\\Rector\\FuncCall\\JsonThrowOnErrorRector" service to "php73\.php" config set#'
# closure detailed
- '#Method Rector\\Config\\RectorConfig\:\:singleton\(\) has parameter \$concrete with no signature specified for Closure#'
# dynamic printer
-
message: '#Use explicit names over dynamic ones#'
paths:
- src/CustomRules/SimpleNodeDumper.php
- src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php
- src/PhpParser/Printer/BetterStandardPrinter.php
# known node variables
-
message: '#Access to an undefined property PhpParser\\Node\\Scalar\:\:\$value#'
path: src/CustomRules/SimpleNodeDumper.php
-
message: '#Avoid static access of constants, as they can change value\. Use interface and contract method instead#'
paths:
# caching and message of speicfic child Rector rules
- src/Rector/AbstractRector.php
# for cache
- src/Testing/PHPUnit/AbstractRectorTestCase.php
-
message: '#Interface "(.*?)" has only single implementer\. Consider using the class directly as there is no point in using the interface#'
paths:
# marker interface
- src/Contract/PhpParser/Node/StmtsAwareInterface.php
# generated class in /vendor
-
message: '#Offset (.*?) on null on left side of \?\? does not exist#'
path: src/Bootstrap/ExtensionConfigResolver.php
# wider types for external use
-
message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#'
path: src/Reflection/ClassModifierChecker.php
# false positive - should be fixed
-
message: '#Parameters should have "PhpParser\\Node\\Expr\\Closure" types as the only types passed to this method#'
-
message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#'
paths:
- src/VendorLocker/ParentClassMethodTypeOverrideGuard.php
- rules/Privatization/NodeManipulator/VisibilityManipulator.php
# more advanced usage, but not always working
# see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110
- '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'
# allowed internally only
-
message: '#Fetching (deprecated )?class constant (.*?) of (deprecated )?class (Rector\\Set\\ValueObject\\DowngradeLevelSetList|Rector\\Symfony\\Set\\(.*?))#'
path: src/Configuration/RectorConfigBuilder.php
# marker interface to be used ad-hoc
- '#Interface "Rector\\Configuration\\Deprecation\\Contract\\DeprecatedInterface" has only single implementer#'
# deprecated
- '#Register "Rector\\Php80\\Rector\\FunctionLike\\MixedTypeRector" service to "php80\.php" config set#'
- '#::provideMinPhpVersion\(\) never returns \d+ so it can be removed from the return type#'
# runtime comparison
- '#Comparison operation ".*" between int<\d+, \d+> and \d+ is always true#'
# from mapper interface
- '#mapToPhpParserNode\(\) never returns PhpParser\\.* so it can be removed from the return#'
# from constant string
- '#Method Rector\\.*::providePolyfillPackage\(\) never returns#'
- '#Method Rector\\.*::filterPolyfillPackages\(\) should return array\<#'
-
identifier: typePerfect.noMixedMethodCaller
paths:
- src/PhpParser/Parser/RectorParser.php
-
path: src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
message: '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory\:\:uniquateTypes\(\) should return array<TType of PHPStan\\Type\\Type> but returns list<PHPStan\\Type\\Type>#'
# known types
-
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
-
message: '#PHPDoc tag @var with type int is not subtype of native type array\|PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprNode\|Rector\\BetterPhpDocParser\\PhpDoc\\DoctrineAnnotationTagValueNode\|Rector\\BetterPhpDocParser\\PhpDoc\\StringNode\|Rector\\BetterPhpDocParser\\ValueObject\\PhpDoc\\DoctrineAnnotation\\CurlyListNode\|string#'
path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php
- '#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\|100000, 79999 given#'
# node vs stmts mix
- '#expects array<PhpParser\\Node\\Stmt>, array<PhpParser\\Node> given#'
- '#should return non\-empty\-string but returns string#'
# false positive, can accept non-class string
- '#Parameter \#1 \$name of method PHPStan\\BetterReflection\\Reflection\\Adapter\\ReflectionClass\:\:getAttributes\(\) expects class\-string\|null, string given#'
# false positive, checked above
-
path: rules/Php71/Rector/List_/ListToArrayDestructRector.php
message: '#Parameter \#1 \$items of class PhpParser\\Node\\Expr\\Array_ constructor expects array<PhpParser\\Node\\ArrayItem>, array<PhpParser\\Node\\ArrayItem\|null> given#'
-
path: rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php
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#'
# scope vs mutating scope
- '#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
- '#Parameter (.*?) expects list<(.*?)>, array<(.*?)> given#'
- '#should return list<(.*?)>\|null but returns non\-empty\-array<(.*?)>\|null#'