forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpstan.neon.dist
319 lines (266 loc) · 17.4 KB
/
phpstan.neon.dist
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
includes:
- phpstan-baseline.neon
- phpstan-v66-baseline.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- src/Core/DevOps/StaticAnalyze/PHPStan/extension.neon
- src/Core/DevOps/StaticAnalyze/PHPStan/rules.neon
- src/Core/DevOps/StaticAnalyze/PHPStan/core-rules.neon
parameters:
phpVersion: 80100
level: 8
treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: true
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: true # Could be set to false if necessary during PHPStan update
tmpDir: var/cache/phpstan
paths:
- src
- tests
type_coverage:
return_type: 99
param_type: 98
property_type: 55
bootstrapFiles:
- src/Core/DevOps/StaticAnalyze/phpstan-bootstrap.php
# run `php src/Core/DevOps/StaticAnalyze/phpstan-bootstrap.php` to create the container
symfony:
constantHassers: false
containerXmlPath: 'var/cache/phpstan_dev/Shopware_Core_DevOps_StaticAnalyze_StaticAnalyzeKernelPhpstan_devDebugContainer.xml'
consoleApplicationLoader: src/Core/DevOps/StaticAnalyze/console-application.php
excludePaths:
- src/WebInstaller/Resources/
- src/WebInstaller/ecs.php
- src/WebInstaller/vendor
- src/WebInstaller/Tests/_fixtures
- tests/e2e/cypress
- src/Core/DevOps/StaticAnalyze/Rector/ClassPackageRector.php
# vendor patches over autoload files
- src/Core/Framework/Adapter/Doctrine/Patch/AbstractAsset.php
# Symfony interface typehints `Predis\ClientInterface` which is by default not available
- src/Core/Framework/Adapter/Cache/ShopwareRedisAdapter.php
- src/Core/Framework/Adapter/Cache/ShopwareRedisTagAwareAdapter.php
# node_modules
- src/**/node_modules/*
- tests/**/node_modules/*
# twig override
- src/Core/Framework/Adapter/Twig/functions.php
# class behind feature flags
- src/Core/Checkout/Cart/Exception/InvalidCartException.php
# extends final class, which is ok for mocks
- src/Core/Content/Test/ImportExport/MockRepository.php
# @todo NEXT-22697 - Remove when re-enabling cms-aware
- src/Core/System/CustomEntity/Xml/Config/CustomEntityEnrichmentService.php
- tests/integration/Core/System/CustomEntity/Xml/Config/CmsAwareAndAdminUiTest.php
# PHPStan rule test files
- tests/unit/Core/DevOps/StaticAnalyse/PHPStan/Rules/data/*
# Compatibility traits for Redis can be removed, once we are requiring Redis 6.0.0
- src/Core/Test/Stub/Redis/RedisCompatibility.php
- src/Core/Test/Stub/Redis/RedisMultiCompatibility.php
ignoreErrors:
# The symfony extension checks against the "normal" container, not the test container
# Therefore some services in the tests are not found and the extension can not infer that all private services are public during test execution
-
message: '#Service ".*" is not registered in the container\.#'
paths:
- src/**/*Test.php
- tests/unit
- tests/integration
- src/Core/Framework/Test/TestCaseBase/*.php
-
message: '#Service ".*" is private#'
paths:
- src/**/*Test.php
- src/**/*TestCase.php
- tests/performance/**/*Bench.php
- tests/unit/**/*Test.php
- tests/integration/**/*Test.php
- tests/integration/**/*TestCase.php
# ignore errors caused by static::markTestSkipped
-
message: '#Unreachable statement - code above always terminates.#'
paths:
- src/**/*Test.php
- tests/**/*Test.php
# To fix this error, the \Shopware\Core\Framework\Struct\Collection::createNew method has to be implemented
# in every implementation of `Collection` and needs to return `new self` instead of `new static`. See https://github.com/phpstan/phpstan/issues/2773
-
message: '#Unsafe usage of new static\(\)#'
path: src/Core/Framework/Struct/Collection.php
# @final annotation of internal classes
- '#.*extends @final class Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\EntitySearchResult\.#'
- '#.*extends @final class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository.#'
- '#Class Shopware\\Tests\\Integration\\Elasticsearch\\Product\\EsAwareCriteria extends @final class Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Criteria\.#'
# dynamic hydrator performance
-
message: '#Access to an undefined property Shopware\\Core\\Framework\\DataAbstractionLayer\\Entity#'
path: src/*/*Hydrator.php
-
message: '#Access to protected property *#'
path: src/*/*Hydrator.php
-
message: '#Method Shopware\\Core\\Framework\\DataAbstractionLayer\\Entity::\_\_.*\(\) has.*#'
path: src/Core/Framework/DataAbstractionLayer/Entity.php
# can be removed with feature flag FEATURE_NEXT_12455
-
message: '#Method Shopware\\Core\\Checkout\\Cart\\Facade\\.*::getIterator\(\) return type with generic class ArrayIterator does not specify its types: TKey, TValue#'
path: src/Core/Checkout/Cart/Facade/Traits/ItemsIteratorTrait.php
# Is in the new super class nullable as the extended class
-
message: "#^PHPDoc type string\\|null of property Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\Field\\\\ReferenceVersionField\\:\\:\\$storageName is not covariant with PHPDoc type string of overridden property Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\Field\\\\FkField\\:\\:\\$storageName\\.$#"
count: 1
path: src/Core/Framework/DataAbstractionLayer/Field/ReferenceVersionField.php
# PhpStan cannot follow the referenced cursor
-
message: "#^Variable \\$extensions in empty\\(\\) always exists and is always falsy\\.$#"
count: 1
path: src/Core/Framework/DataAbstractionLayer/VersionManager.php
# Invalid trait usage
-
message: "#^Dead catch \\- ReflectionException is never thrown in the try block\\.$#"
count: 1
path: src/Core/Checkout/Cart/Error/Error.php
-
message: "#^Dead catch \\- ReflectionException is never thrown in the try block\\.$#"
count: 1
path: src/Core/Content/ProductExport/Error/Error.php
- # MockRepo extends final EntityRepository class, with is ok for tests
message: "#^Class Shopware\\Core\\Content\\Test\\ImportExport\\MockRepository extends @final class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository.$#"
count: 1
path: src/Core/Content/Test/ImportExport/MockRepository.php
- # Tests are skipped in setup, leading to PHPStan errors, should be re-enabled with NEXT-24549
message: "#^Property .* is never written, only read.$#"
paths:
- src/Core/Migration/Test/Migration1648803451FixInvalidMigrationOfBusinessEventToFlowTest.php
- src/Core/Migration/Test/Migration1639992771MoveDataFromEventActionToFlowTest.php
- src/Core/Migration/Test/Migration1632215760MoveDataFromEventActionToFlowTest.php
- src/Core/Migration/Test/Migration1625583619MoveDataFromEventActionToFlowTest.php
- # @deprecated tag:v6.6.0 Using autoload === true on associations is deprecated and must be refactored
message: '#^[a-zA-Z_]+\.[a-zA-Z_]+ association has a configured autoload\=\=\=true, this is forbidden for platform integrations$#'
paths:
- src/Core/System/SalesChannel/SalesChannelDefinition.php
- src/Core/Content/Rule/Aggregate/RuleCondition/RuleConditionDefinition.php
- src/Core/Content/Product/ProductDefinition.php
- src/Core/Content/Product/Aggregate/ProductMedia/ProductMediaDefinition.php
- src/Core/Checkout/Shipping/ShippingMethodDefinition.php
- src/Core/Checkout/Payment/PaymentMethodDefinition.php
- src/Core/System/NumberRange/NumberRangeDefinition.php
- # NEXT-25276 - Needs to be fixed with the update ot PHPUnit 10
message: '#deprecated interface PHPUnit\\Framework\\TestListener#'
path: src/Core/Test/PHPUnit/Extension/DatadogListener.php
# Internal deprecations of Shopware are handled in other places
- '#deprecated.*class Shopware\\#'
- '#deprecated.*interface Shopware\\#'
- # tests are allowed to add dummy classes in the same file
message: '#Multiple class\/interface\/trait is not allowed in single file#'
paths:
- src/**/Test/**
- tests/**
# It explicitly tests array access on object, so it works from twig scripts
-
message: "#Use explicit methods over array access on object$#"
path: src/Core/Framework/Test/Script/Service/ArrayFacadeTest.php
# @deprecated tag:v6.6.0 Adding a new required paramter app in Webhooks for the next major version
- message: '#PHPDoc tag \@param references unknown parameter: \$app#'
path: src/Core/Framework/Webhook/Hookable.php
# @deprecated tag:v6.6.0 - column availability_rule_id in table shipping_method can be nullable in the next major version. The shipping methods concerned will always interpreted as valid.
- message: '#Strict comparison using === between string and null will always evaluate to false.#'
path: src/Core/Checkout/Cart/Delivery/DeliveryValidator.php
- message: '#Strict comparison using === between string and null will always evaluate to false.#'
path: src/Core/Checkout/Shipping/ShippingMethodCollection.php
# XML parser classes are allowed to make use of dynamic assigns
-
message: '#Use explicit names over dynamic ones#'
paths:
- src/**/Xml/**
# Breaking changes which are not worth it
- '#Method Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection::filterAndReduceByProperty\(\) has parameter \$value with no type specified\.#'
- # Google Cloud Storage filesystem closes the stream even though it should not
message: '#Call to function is_resource\(\) with resource will always evaluate to true#'
paths:
- src/Core/Framework/Plugin/Util/AssetService.php
- src/Core/Content/Media/File/FileSaver.php
- # Will be fixed with NEXT-26122
message: '#Doing instanceof PHPStan\\Type\\.* is error-prone and deprecated. Use Type::.*\(\) instead#'
paths:
- src/Core/DevOps/StaticAnalyze/PHPStan/Rules/NoFlowStoreFunctionRule.php
- # Can not be fixed currently. See https://github.com/phpstan/phpstan/discussions/9159
message: '#Method Shopware\\Core\\Framework\\DataAbstractionLayer\\Field\\Field::getFlag\(\) should return \(TFlag of Shopware\\Core\\Framework\\DataAbstractionLayer\\Field\\Flag\\Flag\)\|null but returns Shopware\\Core\\Framework\\DataAbstractionLayer\\Field\\Flag\\Flag\|null#'
path: src/Core/Framework/DataAbstractionLayer/Field/Field.php
count: 1
# test plugin implementations in fixtures, the files can't be excluded as that would lead to errors when they are used
-
message: '#.*#'
paths:
- src/Core/Framework/Test/Store/_fixtures/AppStoreTestPlugin/*
- src/Core/Framework/Test/Plugin/_fixture/plugins/*
- src/Core/Framework/Test/Plugin/Requirement/_fixture/SwagRequirementValidTestExtension/*
- tests/integration/Core/System/CustomEntity/Xml/Config/_fixtures/plugins/*
- tests/integration/Core/Framework/Store/_fixtures/AppStoreTestPlugin/*
- # Hard to fix, as no proper var annotation could be used within the while loop
message: "#^Parameter \\#1 \\$mediaIds of method Shopware\\\\Core\\\\Content\\\\Media\\\\UnusedMediaPurger\\:\\:filterOutNewMedia\\(\\) expects array\\<string\\>, array\\<int, array\\<string, string\\>\\|string\\> given\\.$#"
count: 1
path: src/Core/Content/Media/UnusedMediaPurger.php
# NEXT-29041 - Needs to be fixed with a script, rest goes to baseline
- '#.* generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository.*not specify its types: TEntityCollection#'
- '#.* generic class Shopware\\Core\\System\\SalesChannel\\Entity\\SalesChannelRepository.*not specify its types: TEntityCollection#'
- # No need to fix for now, as the facades are only used in twig context
message: '#.* generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\EntitySearchResult.*does not specify its types: TEntityCollection#'
paths:
- src/Core/Framework/DataAbstractionLayer/Facade/RepositoryFacade.php
- src/Core/Framework/DataAbstractionLayer/Facade/SalesChannelRepositoryFacade.php
- # Needs a proper class-string annotation in `\Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition::getCollectionClass` and all child classes
message: '#PHPDoc tag @var with type .*Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection.* is not subtype of native type string#'
paths:
- src/Core/Framework/DataAbstractionLayer/Dbal/EntityReader.php
- src/Core/Framework/DataAbstractionLayer/EntityRepository.php
- src/Core/System/SalesChannel/Entity/SalesChannelRepository.php
- # It is not possible to specify the type of the EntitySearchResult, as the CmsSlotDataResolver and the ElementDataCollection are used for multiple entities at the same time
message: '#.* with generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection.*not specify its types: TElement#'
paths:
- src/Core/Content/Cms/DataResolver/CmsSlotsDataResolver.php
- src/Core/Content/Cms/DataResolver/Element/ElementDataCollection.php
- '#Parameter \#2 \$entitySearchResult of method Shopware\\Core\\Content\\Cms\\DataResolver\\Element\\ElementDataCollection::add\(\) expects Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\EntitySearchResult<Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection>, Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\EntitySearchResult<Shopware\\.*Collection> given#'
- # It is not possible to specify the type of the EntityResult, as the Aggregators are used for multiple entities at the same time
message: '#Method Shopware\\.*::hydrateEntityAggregation\(\) return type with generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\AggregationResult\\Metric\\EntityResult does not specify its types: TEntityCollection#'
paths:
- src/Core/Framework/DataAbstractionLayer/Dbal/EntityAggregator.php
- src/Elasticsearch/Framework/DataAbstractionLayer/ElasticsearchEntityAggregatorHydrator.php
- # For testing purpose this error can be ignored
message: '#Cannot assign new offset to Shopware\\Core\\Framework\\Script\\Facade\\ArrayFacade#'
path: src/Core/Framework/Test/Script/Service/ArrayFacadeTest.php
- # TestBuilders must not be internal
message: '#must be flagged @internal to not be captured by the BC checker#'
paths:
- src/Core/Test/Integration/Builder
- message: '#Method Shopware\\Core\\Test\\Stub\\Redis\\RedisStub::do.*\(\) is unused#'
path: src/Core/Test/Stub/Redis/RedisStub.php
# To not have a single case for each type, we check them dynamically.
- message: '#Use explicit names over dynamic ones#'
path: src/Core/Framework/Validation/HappyPathValidator.php
count: 2
services:
- # register the class so we can decorate it, but don't tag it as a rule, so only our decorator is used by phpstan
class: Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule
rules:
# rules from https://github.com/symplify/phpstan-rules
# domain
- Symplify\PHPStanRules\Rules\Enum\RequireUniqueEnumConstantRule
- Symplify\PHPStanRules\Rules\ForbiddenParamTypeRemovalRule
- Symplify\PHPStanRules\Rules\PreventParentMethodVisibilityOverrideRule
# paths
- Symplify\PHPStanRules\Rules\NoMissingDirPathRule
- Symplify\PHPStanRules\Rules\NoArrayAccessOnObjectRule
# dead-code
- Symplify\PHPStanRules\Rules\NoIssetOnObjectRule
# explicit naming
- Symplify\PHPStanRules\Rules\ForbiddenMultipleClassLikeInOneFileRule
- Symplify\PHPStanRules\Rules\Complexity\ForbiddenArrayMethodCallRule
# complexity rules
- Symplify\PHPStanRules\Rules\Explicit\NoMixedPropertyFetcherRule
- Symplify\PHPStanRules\Rules\Explicit\NoMixedMethodCallerRule
- Symplify\PHPStanRules\Rules\NoDynamicNameRule
# naming rules
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Symplify\NoReturnSetterMethodWithFluentSettersRule
- Symplify\PHPStanRules\Rules\NoVoidGetterMethodRule
- Symplify\PHPStanRules\Rules\UppercaseConstantRule
- Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule