forked from deprecated-packages/symplify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpstan.neon
435 lines (350 loc) · 22.3 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
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- packages/phpstan-extensions/config/config.neon
- packages/phpstan-rules/config/symplify-rules.neon
# for cognitive rules
- packages/phpstan-rules/packages/cognitive-complexity/config/cognitive-complexity-services.neon
services:
-
class: Symplify\PHPStanRules\Rules\IfImplementsInterfaceThenNewTypeRule
tags: [phpstan.rules.rule]
arguments:
newTypesByInterface:
Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface: Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample
-
class: Symplify\PHPStanRules\Rules\IfNewTypeThenImplementInterfaceRule
tags: [phpstan.rules.rule]
arguments:
interfacesByNewTypes:
Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample: Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface
-
class: Symplify\PHPStanRules\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule
tags: [phpstan.rules.rule]
arguments:
maxMethodCognitiveComplexity: 8
-
class: Symplify\PHPStanRules\CognitiveComplexity\Rules\ClassLikeCognitiveComplexityRule
tags: [phpstan.rules.rule]
arguments:
maxClassCognitiveComplexity: 25
limitsByTypes:
PHPStan\Rules\Rule: 16
-
class: Symplify\PHPStanRules\Rules\RequireClassTypeInClassMethodByTypeRule
tags: [phpstan.rules.rule]
arguments:
requiredTypeInMethodByClass:
Symplify\PHPStanRules\Contract\ManyNodeRuleInterface:
getNodeTypes: 'PhpParser\Node'
parameters:
level: max
checkGenericClassInNonGenericObjectType: false
reportUnmatchedIgnoredErrors: false
parallel:
# to prevent full thread lagging pc
maximumNumberOfProcesses: 7
paths:
- packages
- ecs.php
- rector.php
excludes_analyse:
# there is some bug
- packages/package-builder/src/Testing/AbstractKernelTestCase.php
- packages/package-builder/src/Console/Command/AbstractSymplifyCommand.php
# functions false positive
- *packages/**/tests/**/config.php
- *packages/**/tests/**-config.php
- *packages/monorepo-builder/packages/init/templates/*
- *packages/coding-standard/tests/**/correct*
- *packages/coding-standard/tests/**/wrong*
- *packages/coding-standard/tests/**/Wrong*
- *packages/phpstan-extensions/**/Source/**
# tests
- packages/easy-coding-standard/packages/sniff-runner/tests/Application/FileProcessorSource/ReferenceUsedNamesOnlySniff/
# Symfony workaround
- packages/changelog-linker/src/DependencyInjection/Dummy/ResolveAutowiringExceptionHelper.php
# 3rd party
- packages/easy-coding-standard/packages/sniff-runner/src/ValueObject/File.php
# tests
- packages/phpstan-extensions/tests/Rules/ClassMethod/Source/*
# 3rd party
- packages/package-builder/src/Yaml/ParametersMerger.php
# requires PHP 7.4
- 'packages/easy-hydrator/tests/Fixture/TypedProperty.php'
- 'packages/easy-hydrator/tests/TypedPropertiesTest.php'
- '*/Source/*'
- '*/Fixture/*'
- */vendor/*
- */stubs/*
- packages/vendor-patches/tests/Finder/VendorFilesFinderSource/Vendor/some/package/src/PackageClass.php
- packages/phpstan-rules/tests/Rules/AllowedExclusiveDependencyRule/FixturePhp74/*
bootstrapFiles:
- tests/bootstrap.php
- packages/easy-coding-standard/packages/changed-files-detector/tests/ChangedFilesDetectorSource/OneClass.php
- packages/easy-coding-standard/tests/Finder/SourceFinderSource/Source/SomeClass.php
ignoreErrors:
# command argument value type conversion - known string
-
message: '#Cannot cast array<string>\|string\|null to string#'
path: '*packages/*Command.php'
# invalid 3rd party-code
- '#Parameter \#1 \$index of method PhpCsFixer\\Tokenizer\\Tokens::getNextTokenOfKind\(\) expects int, int\|null given#'
# required for autowiring, since only interface is autowired
- '#Call to an undefined method Symfony\\Component\\DependencyInjection\\ContainerInterface::getParameterBag\(\)#'
# intersect/union buggy
- '#expects Symfony\\Component\\DependencyInjection\\ContainerBuilder, Symfony\\Component\\DependencyInjection\\ContainerInterface given#'
# phpstan 0.10 news
- '#Parameter \#1 \$path of function dirname expects string, string\|false given#'
# mixed up iterables
- '#PHPDoc tag @return with type array<string\> is incompatible with native type Iterator#'
# Symfony 4.2 typehint BC-break
- '#Parameter \#1 \$command of class Symfony\\Component\\Process\\Process constructor expects array, array<string>\|string given#'
# false positive
- '#Unreachable statement \- code above always terminates#'
# false positive
- '#Cannot assign offset \(int\|string\) to PhpCsFixer\\Tokenizer\\Tokens#'
# yield iterator
- '#Parameter \#1 \$files of method Symplify\\SmartFileSystem\\Finder\\FinderSanitizer\:\:sanitize\(\) expects \(iterable<SplFileInfo\|string\>&Nette\\Utils\\Finder\)\|Symfony\\Component\\Finder\\Finder, array<int, SplFileInfo\> given#'
- '#Call to an undefined method ReflectionType\:\:getName\(\)#'
# mixed by default, handled by coding standards
- '#(has|with) no (return )?typehint specified#'
- '#Offset (.*?) does not exist on array\|null#'
- '#in iterable type#'
# the Filesystem method is only iterable way
- '#Method Symplify\\PHPStanRules\\CognitiveComplexity\\Tests\\AstCognitiveComplexityAnalyzer\\AstCognitiveComplexityAnalyzerTest\:\:parseFileToFistFunctionLike\(\) should return (.*?) but returns PhpParser\\Node\|null#'
- '#Method Symplify\\ChangelogLinker\\Github\\GithubRepositoryFromRemoteResolver\:\:resolveFromUrl\(\) should return string but return statement is missing#'
- '#Parameter \#1 \$path of function pathinfo expects string, string\|false\|null given#'
- '#Access to an undefined property PhpParser\\Node\\Expr\\Error(.*?)#'
- '#Cannot cast PhpParser\\Node\\Expr\|string to string#'
- '#Cannot call method (.*?) on PhpCsFixer\\Tokenizer\\Token\|null#'
- '#Cannot call method getSetFileInfo\(\) on Symplify\\SetConfigResolver\\ValueObject\\Set\|null#'
- '#Cannot call method getRealPath\(\) on Symplify\\SmartFileSystem\\SmartFileInfo\|null#'
- '#Parameter \#1 \$endPath of method Symfony\\Component\\Filesystem\\Filesystem\:\:makePathRelative\(\) expects string, string\|false given#'
# false positive
- '#Property Symplify\\ChangelogLinker\\ChangelogDumper\:\:\$content is never written, only read#'
-
message: '#Array with keys is not allowed\. Use value object to pass data instead#'
paths:
# yaml
- packages/sniffer-fixer-to-ecs-converter/src/FixerToECSConverter.php
# table data for symfony console output
- packages/symfony-route-usage/src/Command/ShowRouteUsageCommand.php
- packages/symfony-route-usage/src/Command/ShowDeadRoutesCommand.php
- packages/phpstan-php-config/src/CaseConverter/ServicesConverter.php
- packages/php-config-printer/src/Printer/SmartPhpConfigPrinter.php
# php scoper config array
- */scoper.inc.php
# Symfony API
- packages/rule-doc-generator/src/RuleCodeSamplePrinter/PHPStanRuleCodeSamplePrinter.php # 71
- packages/vendor-patches/src/Composer/ComposerPatchesConfigurationUpdater.php
- packages/easy-testing/src/MissplacedSkipPrefixResolver.php #23
-
message: '#Use value object over return of values#'
paths:
# php scoper config array
- */scoper.inc.php
# Symfony API
- packages/easy-coding-standard/src/Console/Output/JsonOutputFormatter.php
- packages/config-transformer/src/Configuration/Configuration.php
-
message: '#Instead of "SplFileInfo" class/interface use "Symplify\\SmartFileSystem\\SmartFileInfo"#'
paths:
- packages/smart-file-system/src/Finder/FinderSanitizer.php
- packages/smart-file-system/tests/Finder/FinderSanitizer/FinderSanitizerTest.php
-
message: '#Do not use static property#'
paths:
- packages/easy-testing/src/StaticFixtureSplitter.php # 19
# todo resolve later
-
message: '#Do not use trait#'
paths:
- packages/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php # 18
-
message: '#Do not use setter on a service#'
paths:
- packages/easy-coding-standard/packages/configuration/src/Configuration.php # 146
-
message: '#Do not call parent method if parent method is empty#'
paths:
- packages/smart-file-system/src/SmartFileInfo.php # 122
-
message: '#Use explicit return value over magic &reference#'
paths:
- packages/package-builder/src/Reflection/PrivatesCaller.php # 40
-
message: '#Instead of container injection, use specific service#'
paths:
- packages/package-builder/src/Parameter/ParameterProvider.php # 26
- packages/symfony-static-dumper/src/HttpFoundation/ControllerContentResolver.php # 37
# static cache
-
message: '#Do not use static property#'
paths:
- packages/easy-coding-standard-tester/src/Testing/AbstractCheckerTestCase.php # 268
- '#The path "/another\-one\.php" was not found#'
-
message: '#Trait method "assertDirectoryEquals\(\)" should not contain any logic, but only delegate to other class call#'
paths:
- packages/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php # 18
-
message: '#Do not use factory/method call in constructor\. Put factory in config and get service with dependency injection#'
paths:
- packages/easy-coding-standard/src/Set/EasyCodingStandardSetProvider.php # 23
- packages/set-config-resolver/src/Bootstrap/InvalidSetReporter.php # 22
- packages/package-builder/src/Parameter/ParameterProvider.php # 26
- packages/phpstan-rules/src/Rules/CheckClassNamespaceFollowPsr4Rule.php #31
# false positives
- '#Constant Symplify\\ChangelogLinker\\Tests\\ChangeTree\\ChangeFactory\\ChangeFactoryTest\:\:PULL_REQUEST is unused#'
- '#Property Symplify\\ChangelogLinker\\Tests\\ChangelogDumper\\WithTagsTest\:\:\$changes is never read, only written#'
- '#Property Symplify\\ChangelogLinker\\Tests\\ChangelogDumper\\WithTagsTest\:\:\$changelogDumper is never read, only written#'
# solve later
- '#Constant string value need to only have small letters, _, \-, \. and numbers#'
# use rector rule for this
- '#Use decoupled factory service to create "Symplify\\EasyTesting\\ValueObject\\InputAndExpected" object#'
- '#"@file_get_contents\(\$filename\)" is forbidden to use#'
-
message: '#Nested foreach with empty statement is not allowed#'
paths:
# xml nesting
- packages/sniffer-fixer-to-ecs-converter/src/SnifferToECSConverter.php
# child type
- '#Parameter \#1 \$node of method Symplify\\PHPStanRules\\Rules\\ForbiddenSpreadOperatorRule\:\:hasVariadicParam\(\) expects PhpParser\\Node\\Expr\\ArrowFunction\|PhpParser\\Node\\Expr\\Closure\|PhpParser\\Node\\Stmt\\ClassMethod\|PhpParser\\Node\\Stmt\\Function_, PhpParser\\Node\\Expr\\ArrowFunction\|PhpParser\\Node\\Expr\\Closure\|\(PhpParser\\Node\\Expr\\FuncCall&PhpParser\\Node\\FunctionLike\)\|\(PhpParser\\Node\\Expr\\MethodCall&PhpParser\\Node\\FunctionLike\)\|\(PhpParser\\Node\\Expr\\StaticCall&PhpParser\\Node\\FunctionLike\)\|PhpParser\\Node\\Stmt\\ClassMethod\|PhpParser\\Node\\Stmt\\Function_ given#'
-
message: '#SymfonyStyle service is not needed for only newline and text echo\. Use PHP_EOL and concatenation instead#'
paths:
- packages/console-color-diff/src/Console/Output/ConsoleDiffer.php # 11
- packages/easy-coding-standard/src/Console/Output/JsonOutputFormatter.php # 18
-
message: '#Cannot cast array<string\>\|bool\|string\|null to string#'
paths:
- packages/easy-coding-standard/packages/configuration/src/Configuration.php # 214
- packages/monorepo-builder/packages/release/src/Configuration/StageResolver.php # 26
- packages/phpstan-php-config/src/Command/ConvertCommand.php # 70
- packages/rule-doc-generator/src/Command/GenerateCommand.php # 54
-
message: '#Use another value object over array with string\-keys and objects, array<string, ValueObject\>#'
paths:
- packages/template-checker/src/Latte/LatteFilterManager.php # 88
- packages/easy-hydrator/tests/ArrayToValueObjectHydratorTest.php # 237
- packages/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php # 91
# nesting
- '#Parameter \#1 \$items of class PhpParser\\Node\\Expr\\Array_ constructor expects array<PhpParser\\Node\\Expr\\ArrayItem\|null\>, array<PhpParser\\Node\\Arg\> given#'
-
message: '#Instead of "SplFileInfo" class/interface use "Symplify\\SmartFileSystem\\SmartFileInfo"#'
path: packages/easy-ci/src/Finder/SrcTestsDirectoriesFinder.php
- '#Parameter \#1 \$type of method PhpParser\\Builder\\FunctionLike\:\:setReturnType\(\) expects PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|string, PhpParser\\Node\\Identifier\|PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|PhpParser\\Node\\UnionType given#'
- '#Cannot cast array<string\>\|bool\|string\|null to string#'
-
message: '#Cannot cast array<string\>\|bool\|string\|null to string#'
path: 'packages/psr4-switcher/src/Configuration/Psr4SwitcherConfiguration.php'
- '#Parameter \#5 \$default of method Symfony\\Component\\Console\\Command\\Command\:\:addOption\(\) expects array<string\>\|bool\|int\|string\|null, float given#'
-
message: '#Instead of container injection, use specific service#'
paths:
# tests helper
- packages/symfony-route-usage/tests/Helper/DatabaseLoaderHelper.php
# doctrine
- '#Property Symplify\\SymfonyRouteUsage\\Entity\\RouteVisit\:\:\$id is never written, only read#'
-
message: '#Do not use factory/method call in constructor\. Put factory in config and get service with dependency injection#'
paths:
# tests
- packages/symfony-route-usage/src/Database/TableInitiator.php
# skipped tests
- '#Property Symplify\\SymfonyRouteUsage\\Tests\\EntityRepository\\RouteVisitRepositoryTest\:\:\$routeVisitRepository is never written, only read#'
- '#Property Symplify\\SymfonyRouteUsage\\Tests\\Routing\\DeadRoutesProviderTest\:\:\$deadRoutesProvider is never written, only read#'
- '#Method Symplify\\Skipper\\SkipCriteriaResolver\\SkippedClassAndCodesResolver\:\:resolve\(\) should return array<string, array<string\>\|null\> but returns array<int\|string, mixed\>#'
-
message: '#Array destruct is not allowed\. Use value object to pass data instead#'
path: 'packages/smart-file-system/src/Normalizer/PathNormalizer.php'
- '#Parameter (.*?) class ReflectionClass constructor expects class\-string<T of object\>\|T of object, string given#'
-
message: '#"Doctrine\\ORM\\EntityManagerInterface" dependency is allowed only in "\*Repository" types#'
paths:
# database helper
- packages/symfony-route-usage/src/Database/TableInitiator.php
-
message: '#"%s" in sprintf\(\) format must be quoted#'
paths:
- packages/monorepo-builder/packages/release/src/Command/ReleaseCommand.php #110
-
message: '#Function "method_exists\(\)" cannot be used/left in the code#'
paths:
- packages/monorepo-builder/packages/release/src/Process/ProcessRunner.php
# PHPUnit 9/10 compat
- packages/symfony-static-dumper/tests/FileSystem/AssetsCopierTest.php
# existing method call validator
- packages/template-checker/src/Analyzer/MissingClassStaticCallLatteAnalyzer.php
# look for parent method
- packages/phpstan-rules/src/Rules/PreventParentMethodVisibilityOverrideRule.php
# PHP 7/8 compact
- packages/easy-hydrator/src/ParameterTypeRecognizer.php
-
message: '#Function "property_exists\(\)" cannot be used/left in the code#'
paths:
- packages/astral/src/NodeNameResolver/ClassLikeNodeNameResolver.php
# PHP compat
- packages/package-builder/src/Reflection/PrivatesAccessor.php
# multiple probabilities of Nodes that have stmts
- packages/phpstan-rules/src/Rules/RequireStringRegexMatchKeyRule.php #139
-
message: '#"self\:\:.*" regex need to use string named capture group instead of numeric#'
paths:
- packages/coding-standard/src/TokenRunner/DocBlock/MalformWorker/SuperfluousReturnNameMalformWorker.php #45
- packages/coding-standard/src/TokenRunner/DocBlock/MalformWorker/SuperfluousVarNameMalformWorker.php #51
-
message: '#Anonymous class is not allowed#'
paths:
- packages/astral/src/NodeTraverser/SimpleCallableNodeTraverser.php #35
-
message: '#Use controller class name based on route name instead#'
paths:
- packages/symfony-static-dumper/tests/test_project/src/Controller/OneArgumentController.php #13
- packages/symfony-static-dumper/tests/test_project/src/Controller/SomeController.php #13
- packages/symfony-static-dumper/tests/test_project/src/Controller/TwoArgumentsController.php #13
- '#Property Symplify\\SymfonyRouteUsage\\Entity\\RouteVisit\:\:\$routeHash is never read, only written#'
# the file must start with "Abstract" to be correct
-
message: '#Skipped tested file must start with "Skip" prefix#'
paths:
- packages/phpstan-rules/tests/Rules/PrefixAbstractClassRule/PrefixAbstractClassRuleTest.php
- packages/phpstan-rules/tests/Rules/CheckRequiredAbstractKeywordForClassNameStartWithAbstractRule/CheckRequiredAbstractKeywordForClassNameStartWithAbstractRuleTest.php
-
message: '#Argument "name" must be a constant#'
paths:
- packages/symfony-static-dumper/tests/test_project
- packages/phpstan-rules/tests/Rules/ForbiddenArrayWithStringKeysRule/FixturePhp80/SkipAttributeArrayKey.php
- '#Method Symplify\\PHPStanRules\\NodeFinder\\MethodCallNodeFinder\:\:findUsages\(\) should return array<PhpParser\\Node\\Expr\\MethodCall\> but returns array<PhpParser\\Node\>#'
- '#Method Symplify\\Astral\\NodeFinder\\ParentNodeFinder\:\:getFirstParentByType\(\) should return T of PhpParser\\Node\|null but returns class\-string<T of PhpParser\\Node\>\|T of PhpParser\\Node#'
# manually constructored for Symfony compiler pass, before DI is created
-
message: '#Do not use scalar or array as constructor parameter\. Use "Symplify\\PackageBuilder\\Parameter\\ParameterProvider" service instead#'
paths:
- packages/autowire-array-parameter/src/Skipper/ParameterSkipper.php
- '#Method Symplify\\PHPStanRules\\NodeFinder\\MethodCallNodeFinder\:\:findByName\(\) should return array<PhpParser\\Node\\Expr\\MethodCall\> but returns array<PhpParser\\Node\>#'
-
message: '#Assign in loop is not allowed#'
paths:
- packages/monorepo-builder/packages/merge/src/Validation/AutoloadPathValidator.php #30
- packages/phpstan-rules/src/Rules/AbstractInvokableControllerRule.php #50
- packages/phpstan-rules/src/Rules/ExclusiveDependencyRule.php #81
- packages/phpunit-upgrader/src/FileInfoDecorator/AssertContainsInfoDecorator.php #39
-
message: '#\$this as argument is not allowed#'
paths:
- packages/easy-hydrator/src/ClassConstructorValuesResolver.php #44
# required complexity, as get/set methods for API of composer.json
- '#Cognitive complexity for "Symplify\\ComposerJsonManipulator\\ComposerJsonFactory\:\:createFromArray\(\)" is \d+, keep it under 8#'
- '#\$this as argument is not allowed\. Refator method to service composition#'
- '#Class with base "Regex" name is already used in "MongoDB\\BSON\\Regex", "Symplify\\PHPStanRules\\ValueObject\\Regex"\. Use unique name to make classes easy to recognize#'
-
message: '#Class cognitive complexity is \d+, keep it under 25#'
path: packages/coding-standard/src/Php/PhpContentAnalyzer.php
-
message: '#Cognitive complexity for "Symplify\\CodingStandard\\Php\\PhpContentAnalyzer\:\:isPhpContent\(\)" is \d+, keep it under 8#'
path: packages/coding-standard/src/Php/PhpContentAnalyzer.php
- '#Content of method "create\(\)" is duplicated with method "create\(\)" in "Symplify\\MarkdownDiff\\Diff\\Output\\CompleteUnifiedDiffOutputBuilderFactory" class\. Use unique content or abstract service instead#'
-
message: '#Class cognitive complexity is 29, keep it under 16#'
path: packages/phpstan-rules/src/Rules/ForbiddenAssignInLoopRule.php