Repository navigation
Expand file tree
/
Copy pathphpstan.neon.dist
More file actions
191 lines (182 loc) · 9.4 KB
/
Copy pathphpstan.neon.dist
File metadata and controls
191 lines (182 loc) · 9.4 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
# PHPStan configuration for WordPress Core.
#
# To overload this configuration, copy this file to phpstan.neon and adjust as needed.
#
# https://phpstan.org/config-reference
includes:
# The base configuration file for using PHPStan with the WordPress core codebase.
- tests/phpstan/base.neon
# Type-specifying extension so PHPUnit assertions (e.g. assertArrayHasKey(),
# assertInstanceOf(), assertNotNull()) narrow types in the analysis. Only the
# extension is included, not phpstan-phpunit's rules.neon, to avoid introducing
# new strict rules.
- vendor/phpstan/phpstan-phpunit/extension.neon
# Preexisting errors that should be ignored, one baseline per error identifier
# so that the remaining work on each is visible as a single shrinking file.
# Each is meant to reach zero and be deleted, taking its line below with it.
# https://phpstan.org/user-guide/baseline
#
# Regenerate with `composer phpstan:baselines`, which rewrites both the files
# and the list between the markers. Do not edit that list by hand.
# phpstan:baselines start
- tests/phpstan/baselines/argument.type.neon
- tests/phpstan/baselines/argument.unresolvableType.neon
- tests/phpstan/baselines/assign.propertyType.neon
- tests/phpstan/baselines/binaryOp.invalid.neon
- tests/phpstan/baselines/booleanAnd.alwaysFalse.neon
- tests/phpstan/baselines/booleanAnd.leftAlwaysTrue.neon
- tests/phpstan/baselines/booleanAnd.rightAlwaysTrue.neon
- tests/phpstan/baselines/booleanNot.alwaysFalse.neon
- tests/phpstan/baselines/booleanNot.alwaysTrue.neon
- tests/phpstan/baselines/booleanOr.alwaysFalse.neon
- tests/phpstan/baselines/booleanOr.alwaysTrue.neon
- tests/phpstan/baselines/class.notFound.neon
- tests/phpstan/baselines/deadCode.unreachable.neon
- tests/phpstan/baselines/empty.offset.neon
- tests/phpstan/baselines/empty.property.neon
- tests/phpstan/baselines/empty.variable.neon
- tests/phpstan/baselines/function.alreadyNarrowedType.neon
- tests/phpstan/baselines/function.impossibleType.neon
- tests/phpstan/baselines/function.resultUnused.neon
- tests/phpstan/baselines/greaterOrEqual.alwaysTrue.neon
- tests/phpstan/baselines/identical.alwaysFalse.neon
- tests/phpstan/baselines/identical.alwaysTrue.neon
- tests/phpstan/baselines/if.alwaysFalse.neon
- tests/phpstan/baselines/if.alwaysTrue.neon
- tests/phpstan/baselines/isset.offset.neon
- tests/phpstan/baselines/isset.property.neon
- tests/phpstan/baselines/method.childParameterType.neon
- tests/phpstan/baselines/method.unused.neon
- tests/phpstan/baselines/notIdentical.alwaysTrue.neon
- tests/phpstan/baselines/nullCoalesce.property.neon
- tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon
- tests/phpstan/baselines/offsetAccess.notFound.neon
- tests/phpstan/baselines/offsetAssign.valueType.neon
- tests/phpstan/baselines/parameter.defaultValue.neon
- tests/phpstan/baselines/parameter.notFound.neon
- tests/phpstan/baselines/parameterByRef.type.neon
- tests/phpstan/baselines/parameterByRef.unusedType.neon
- tests/phpstan/baselines/property.defaultValue.neon
- tests/phpstan/baselines/property.nonObject.neon
- tests/phpstan/baselines/property.notFound.neon
- tests/phpstan/baselines/property.private.neon
- tests/phpstan/baselines/property.protected.neon
- tests/phpstan/baselines/return.type.neon
- tests/phpstan/baselines/return.unusedType.neon
- tests/phpstan/baselines/ternary.alwaysTrue.neon
- tests/phpstan/baselines/varTag.noVariable.neon
- tests/phpstan/baselines/variable.undefined.neon
# phpstan:baselines end
parameters:
# https://phpstan.org/user-guide/rule-levels
level: 5
reportUnmatchedIgnoredErrors: true
# The following ignored errors are not intended to be fixed, as distinct from the baselines
# included above.
#
# A baseline records work still to be done. Every entry in one is in scope to be fixed, and
# each file is meant to reach zero and then be deleted. An entry here is the opposite: a
# decision that the code is right as written and the report is not actionable, whether
# because PHPStan cannot see what makes the code safe, or because satisfying it would mean
# changing code that has no other reason to change.
#
# So prefer fixing an error, and baseline it when it cannot be fixed yet. Add it here only
# when it should never be fixed, and say why.
ignoreErrors:
# Level 0:
- # Inner functions aren't supported by PHPStan.
message: '#Function wxr_[a-z_]+ not found#'
path: src/wp-admin/includes/export.php
-
identifier: function.inner
path: src/wp-admin/includes/export.php
count: 13
-
identifier: function.inner
path: src/wp-admin/includes/file.php
count: 1
-
identifier: function.inner
path: src/wp-includes/canonical.php
count: 1
# In core, @internal is advisory for extenders: it marks a symbol that plugins should not rely on. Core itself is
# one codebase and its own uses of these symbols are intended. PHPStan scopes @internal by root namespace, and
# since core symbols live in the global namespace, it reports every use outside the declaring class or file.
#
# The identifier depends on where the symbol is used (e.g. new.internalClass, parameter.internalInterface,
# varTag.internalTrait), so the entry matches on the message instead, which always names the symbol right after
# "internal <kind>". The name must not contain a backslash, so uses of @internal symbols from namespaced
# third-party libraries like SimplePie and Requests are still reported. A bundled library in the global
# namespace cannot be told apart from core that way, so it must be excluded by its prefix instead. Currently
# that is only sodium_compat (ParagonIE_), which marks much of its API as @internal. These checks are only
# enabled by bleedingEdge; functions, class constants, instantiations, and static calls are checked from level 0,
# and methods, properties, and type references from level 2.
-
message: '#\binternal (?:static )?(?:class|interface|trait|enum|function|method|constant|property) (?!ParagonIE_)\w++(?!\\)#'
reportUnmatched: false
# Level 2:
# ValueError is PHP 8.0+; core throws it conditionally so the docblocks are correct for WP's 7.4+ range,
# but bleedingEdge's version-aware check treats the class as non-existent against the PHP 7.4 floor.
-
message: '#^PHPDoc tag @throws with type InvalidArgumentException\|ValueError is not subtype of Throwable$#'
path: src/wp-includes/compat.php
reportUnmatched: false
# Level 5:
# substr_compare()'s $length has always accepted null, meaning "compare the full length". PHP 7.4 spelled
# that `int $length = null`, where the null default makes the parameter implicitly nullable, and PHP 8.0
# only made it explicit as `?int $length = null`. The behavior never differed: verified on PHP 7.4 that
# passing null compares the whole string rather than coercing to a length of 0.
#
# PHPStan reads the two spellings from two sources and only one is right. Its PHP 8 stub carries `?int`,
# but the pre-8.0 `resources/functionMap.php` records the type as plain `int`, having dropped the implicit
# nullability when it was transcribed from the old manual. Because `phpVersion.min` is 70400, the legacy
# map wins and null is reported as invalid.
#
# This lives here rather than in a baseline because a baseline entry records work still to be done, and
# there is none: the call is correct on every version WordPress supports, and the fault is in PHPStan's
# data. Passing an explicit length purely to satisfy it would change working code to suit a tooling bug.
# `reportUnmatched: false` so this entry lapses quietly if PHPStan corrects the map.
-
message: '#^Parameter \#4 \$length of function substr_compare expects int, null given\.$#'
path: src/wp-includes/html-api/class-wp-html-tag-processor.php
reportUnmatched: false
# HTML API:
# These errors are ignored for the sake of making it easier to keep the HTML Processor in sync with the HTML spec.
-
message: '#^Comparison operation "\>" between 999\|1000 and 0 is always true\.$#'
identifier: greater.alwaysTrue
count: 1
path: src/wp-includes/html-api/class-wp-html-processor.php
-
message: '#^Comparison operation "\>\=" between 0 and 8 is always false\.$#'
identifier: greaterOrEqual.alwaysFalse
count: 1
path: src/wp-includes/html-api/class-wp-html-processor.php
-
message: '#^Left side of && is always true\.$#'
identifier: booleanAnd.leftAlwaysTrue
count: 1
path: src/wp-includes/html-api/class-wp-html-processor.php
-
message: '#^Unreachable statement \- code above always terminates\.$#'
identifier: deadCode.unreachable
count: 15
path: src/wp-includes/html-api/class-wp-html-processor.php
-
message: '#^If condition is always true\.$#'
identifier: if.alwaysTrue
count: 2
path: src/wp-includes/html-api/class-wp-html-processor.php
-
message: '#^Dead catch \- Exception is never thrown in the try block\.$#'
identifier: catch.neverThrown
count: 1
path: src/wp-includes/html-api/class-wp-html-processor.php
-
# The early return at the start of step() narrows $last_error to null, and PHPStan does not see that
# bookmark_token() sets it to ERROR_EXCEEDED_MAX_BOOKMARKS before throwing. So it reports that the
# check in the catch block can never match, when in fact it always does.
message: '#^Strict comparison using \=\=\= between ''exceeded\-max…'' and null will always evaluate to false\.$#'
identifier: identical.alwaysFalse
count: 1
path: src/wp-includes/html-api/class-wp-html-processor.php