Repository navigation
Expand file tree
/
Copy pathphpstan.neon.dist
More file actions
363 lines (360 loc) · 17 KB
/
Copy pathphpstan.neon.dist
File metadata and controls
363 lines (360 loc) · 17 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
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
- tests/php/PHPStan/rules.neon
parameters:
level: max
treatPhpDocTypesAsCertain: false
# Templates read their context as properties of their scope, and __get()
# returns each one escaped, as a string. This types those reads by __get().
# The view itself offers the same reads to code that holds it.
universalObjectCratesClasses:
- MWPD\BasicScaffold\Infrastructure\TemplateScope
- MWPD\BasicScaffold\Infrastructure\View
paths:
- basic-scaffold.php
- src
- tests
- views
bootstrapFiles:
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
excludePaths:
- tests/php/Fixture/views/broken-view.php
# Fixtures for the architecture rules break those rules on purpose.
- tests/php/PHPStan/Fixture
# Bootstrap contract fixtures deliberately make invalid hook calls.
- tests/php/Fixture/BootstrapContract
# Stand-ins for WordPress classes, which the WordPress stubs declare.
- tests/php/Fixture/WordPress
ignoreErrors:
# Ignore errors related to ReflectionClass subtype, see https://github.com/phpstan/phpstan/issues/4078
- '#SimpleInjector::get_dependencies_for\(\) has parameter \$reflection with generic class ReflectionClass but does not specify its types#'
- '#SimpleInjector::ensure_is_instantiable\(\) has parameter \$reflection with generic class ReflectionClass but does not specify its types#'
- '#SimpleInjector::get_class_reflection\(\) return type with generic class ReflectionClass does not specify its types#'
# Settings for the architecture rules (tests/php/PHPStan/rules.neon), see
# docs/architecture-rules.md. Rename the namespaces together with the
# plugin's namespace.
architecture:
# Code the rules apply to.
namespace: MWPD\BasicScaffold
# Parts of that namespace that are not plugin code.
excludedNamespaces:
- MWPD\BasicScaffold\Tests
capabilitiesOnServices:
# Lifecycle capabilities only work on services the plugin orchestrates.
service: MWPD\BasicScaffold\Infrastructure\Service
capabilities:
- MWPD\BasicScaffold\Infrastructure\Registerable
- MWPD\BasicScaffold\Infrastructure\Conditional
- MWPD\BasicScaffold\Infrastructure\Delayed
- MWPD\BasicScaffold\Infrastructure\HasDependencies
- MWPD\BasicScaffold\Infrastructure\Activateable
- MWPD\BasicScaffold\Infrastructure\Deactivateable
- MWPD\BasicScaffold\Infrastructure\SiteActivateable
- MWPD\BasicScaffold\Infrastructure\NetworkActivateable
- MWPD\BasicScaffold\Infrastructure\SiteDeactivateable
- MWPD\BasicScaffold\Infrastructure\NetworkDeactivateable
- MWPD\BasicScaffold\Infrastructure\SiteInitializable
- MWPD\BasicScaffold\Infrastructure\SiteUninitializable
- MWPD\BasicScaffold\Infrastructure\SiteUninstallable
- MWPD\BasicScaffold\Infrastructure\NetworkUninstallable
- MWPD\BasicScaffold\Infrastructure\Registration\ObservesRegistration
- MWPD\BasicScaffold\Infrastructure\HasAssets
delayed: MWPD\BasicScaffold\Infrastructure\Delayed
registerable: MWPD\BasicScaffold\Infrastructure\Registerable
hasAssets: MWPD\BasicScaffold\Infrastructure\HasAssets
finalByDefault:
# Classes designed to be extended (design principle 6).
baseClasses:
- MWPD\BasicScaffold\Infrastructure\View\SimpleView
namesWithoutTypeKind:
# Reviewed type names that encode their kind (design principle 8).
allowed: []
noStaticState:
# Methods allowed to keep static state (design principle 5).
allowed:
- MWPD\BasicScaffold\BasicScaffoldPluginFactory::create
pluginFactoryOnlyAtEdges:
# Only WordPress entry points may obtain the graph statically.
factories:
- MWPD\BasicScaffold\BasicScaffoldPluginFactory
# Reviewed static callables that get the graph and delegate at once.
bridges:
# WordPress stores the uninstall callback and calls it statically.
- MWPD\BasicScaffold\BasicScaffoldUninstallHook::uninstall
noGlobalState:
# Classes that read request input and sanitize and normalize it
# into internal types (design principles 7 and 9). This never
# permits global statements or $GLOBALS access.
inputAdapters: []
exceptions:
# Where the plugin's exceptions live, and the interface they all
# implement (design principle 10).
namespace: MWPD\BasicScaffold\Exception
marker: MWPD\BasicScaffold\Exception\BasicScaffoldException
# Code in that namespace that is not an exception.
notExceptions:
- MWPD\BasicScaffold\Exception\Stringify
exceptionsKeepCause:
# Reviewed Class::method recoveries that need no catch body.
# Explain the recovery beside each entry (design principle 10).
emptyCatches: []
noWordPressErrorMechanisms:
# Classes that hand a WP_Error to WordPress where it expects one.
boundaryAdapters: []
outputOnlyThroughViews:
# Named classes allowed to output without a rendered view
# (design principle 7). Templates are checked by rawIsEscaped.
allowed: []
rawIsEscaped:
# A raw() read bypasses automatic escaping; templates must escape
# it for its output context (design principle 9).
escapingFunctions:
- esc_html
- esc_attr
- esc_url
- esc_js
- esc_textarea
- esc_xml
- wp_kses
- wp_kses_post
- wp_kses_data
- absint
- intval
dependencyDirection:
# The layer generated plugins build on (design principle 4).
infrastructure: MWPD\BasicScaffold\Infrastructure
# The only classes that know the concrete classes and wire the
# plugin together (design principle 5).
compositionRoot:
- MWPD\BasicScaffold\BasicScaffoldPlugin
- MWPD\BasicScaffold\BasicScaffoldPluginFactory
# The uninstall bridge is an edge like the bootstrap: it asks
# the factory for the plugin.
- MWPD\BasicScaffold\BasicScaffoldUninstallHook
# The bootstrap declares no class, so the rule names its code
# after the namespace and the file: it builds the fallback
# autoloader and asks the factory for the plugin.
- MWPD\BasicScaffold\basic-scaffold
# Directories of the view templates that run in production.
views:
- %currentWorkingDirectory%/views
noServiceLocator:
# Feature subsystems receive collaborators; only the composition
# root configures the graph (design principle 5).
container: MWPD\BasicScaffold\Infrastructure\ServiceContainer
injector: MWPD\BasicScaffold\Infrastructure\Injector
allowedInjectorMethods:
- make
newOnlyWhereAllowed:
# Interfaces whose implementations create objects for a living, on
# top of classes named ...Factory (design principle 5).
factories:
- MWPD\BasicScaffold\Infrastructure\Injector
- MWPD\BasicScaffold\Infrastructure\Instantiator
# Classes that represent a value rather than a collaborator, and
# may be created anywhere.
valueObjects:
- MWPD\BasicScaffold\Infrastructure\ServiceContainer\LazilyInstantiatedService
- MWPD\BasicScaffold\Infrastructure\View\ViewLocations
- MWPD\BasicScaffold\Infrastructure\View\ViewConfiguration
# Created by SimpleView for each render: the scope a template
# runs in, which only hands calls on to that view. Replacing it
# means replacing the view, through ViewFactory.
- MWPD\BasicScaffold\Infrastructure\View\SimpleTemplateScope
# Markup a presenter vouches for, created where it is built.
- MWPD\BasicScaffold\Infrastructure\View\SafeHtml
- MWPD\BasicScaffold\Infrastructure\Lifecycle\SiteId
- MWPD\BasicScaffold\Infrastructure\Lifecycle\NetworkId
- MWPD\BasicScaffold\Infrastructure\Lifecycle\LifecycleScope
- MWPD\BasicScaffold\Infrastructure\Lifecycle\SiteContext
- MWPD\BasicScaffold\Infrastructure\Lifecycle\NetworkContext
- MWPD\BasicScaffold\Infrastructure\Lifecycle\SiteSelection
- MWPD\BasicScaffold\Infrastructure\Lifecycle\NetworkSelection
- MWPD\BasicScaffold\Infrastructure\Registration\RegistrationRecord
- MWPD\BasicScaffold\Infrastructure\Asset\AssetContext
- MWPD\BasicScaffold\Infrastructure\Asset\AssetHandle
- MWPD\BasicScaffold\Infrastructure\Asset\AssetLocation
- MWPD\BasicScaffold\Infrastructure\Asset\AssetPath
- MWPD\BasicScaffold\Infrastructure\Asset\Script
- MWPD\BasicScaffold\Infrastructure\Asset\Style
# A read-only wrapper around the registration log, like the
# lazy service wrapper above.
- MWPD\BasicScaffold\Infrastructure\Registration\ReadOnlyRegistrationReport
- DateTimeImmutable
- DateInterval
- ArrayIterator
- SplObjectStorage
constructorsOnlyAssign:
# Reviewed Class::__construct exceptions to storing dependencies
# only (design principle 7). Explain each allowance beside it.
allowed: []
hooks:
# The methods a feature service adds and removes hooks in, with
# the interface each belongs to (design principle 7).
lifecycleMethods:
register: MWPD\BasicScaffold\Infrastructure\Registerable
activate: MWPD\BasicScaffold\Infrastructure\Activateable
deactivate: MWPD\BasicScaffold\Infrastructure\Deactivateable
activate_site: MWPD\BasicScaffold\Infrastructure\SiteActivateable
activate_network: MWPD\BasicScaffold\Infrastructure\NetworkActivateable
deactivate_site: MWPD\BasicScaffold\Infrastructure\SiteDeactivateable
deactivate_network: MWPD\BasicScaffold\Infrastructure\NetworkDeactivateable
initialize_site: MWPD\BasicScaffold\Infrastructure\SiteInitializable
uninitialize_site: MWPD\BasicScaffold\Infrastructure\SiteUninitializable
uninstall_site: MWPD\BasicScaffold\Infrastructure\SiteUninstallable
uninstall_network: MWPD\BasicScaffold\Infrastructure\NetworkUninstallable
# Functions that tell what kind of request this is. register()
# leaves them to Conditional::is_needed().
contextFunctions:
- is_admin
- is_network_admin
- is_user_admin
- wp_doing_ajax
- wp_doing_cron
- wp_is_json_request
- is_customize_preview
- is_singular
- is_front_page
- is_home
- is_archive
# Functions that ask which hooks have run or are running.
# Delayed::get_registration_action() states when to register.
timingFunctions:
- did_action
- doing_action
- did_filter
- doing_filter
- current_action
- current_filter
queryContextNeedsDelay:
# Query-dependent conditions need Delayed, so is_needed() can
# wait until WordPress has run the query (design principle 7).
queryFunctions:
- is_singular
- is_single
- is_page
- is_front_page
- is_home
- is_archive
- is_search
- is_404
- is_attachment
- is_feed
- is_main_query
# The admin screen is available from current_screen onward.
screenFunctions:
- get_current_screen
# The prefix of each kind of name the plugin creates, and the class
# constants that hold it (design principle 13). Rename the prefixes
# together with the plugin.
prefixedNames:
hooks:
prefix: mwpd.basic_scaffold.
constants:
- HOOK_PREFIX
# Hooks of WordPress the plugin fires itself.
allowed: []
managed: []
options:
prefix: mwpd_basic_scaffold_
constants: []
# Options of WordPress the plugin reads.
allowed:
- date_format
- time_format
- timezone_string
- gmt_offset
- blogname
- home
- siteurl
# Where WordPress records the plugins active on a site,
# which a network deactivation reads.
- active_plugins
# Options of WordPress the plugin also writes, and so may read.
# Uninstalling removes the plugin's own uninstall callback from
# the main site of each network (#34).
managed:
- uninstall_plugins
transients:
prefix: mwpd_basic_scaffold_
constants: []
allowed: []
managed: []
meta:
prefix: mwpd_basic_scaffold_
constants: []
allowed: []
managed: []
assets:
prefix: mwpd-basic-scaffold-
constants: []
# Scripts and styles of WordPress the plugin enqueues.
allowed:
- jquery
- wp-api-fetch
- wp-components
- wp-element
- wp-i18n
managed: []
postTypes:
prefix: mwpd_bs_
constants: []
allowed: []
managed: []
taxonomies:
prefix: mwpd_bs_
constants: []
allowed: []
managed: []
shortcodes:
prefix: mwpd_basic_scaffold_
constants: []
allowed: []
managed: []
restRoutes:
prefix: mwpd/basic-scaffold
constants: []
allowed: []
managed: []
cron:
prefix: mwpd_basic_scaffold_
constants: []
allowed: []
managed: []
adminPages:
prefix: mwpd-basic-scaffold-
constants: []
allowed: []
managed: []
settings:
prefix: mwpd_basic_scaffold_
constants: []
# Core settings pages use their page slug as the option group;
# a field on a core page must join that group.
allowed:
- general
- writing
- reading
- discussion
- media
managed: []
ajax:
prefix: mwpd_basic_scaffold_
constants: []
allowed: []
managed: []
# Static methods that create a name of a kind, checked like the
# WordPress functions above, and the classes that only pass such names
# on to WordPress (design principle 13).
prefixedDeclarations:
methods:
# The asset declarations create the handle, so it is checked
# where a service declares an asset.
assets:
- MWPD\BasicScaffold\Infrastructure\Asset\Style::file
- MWPD\BasicScaffold\Infrastructure\Asset\Style::inline
- MWPD\BasicScaffold\Infrastructure\Asset\Script::file
forwarders:
# Registers and enqueues the handles declared above.
assets:
- MWPD\BasicScaffold\Infrastructure\Asset\WordPressAssets