Repository navigation
Expand file tree
/
Copy pathphpstan.neon
More file actions
218 lines (171 loc) · 8.12 KB
/
Copy pathphpstan.neon
File metadata and controls
218 lines (171 loc) · 8.12 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
parameters:
level: 8
paths:
- src
- bin/latte-lint
excludePaths:
analyse:
- src/Latte/Compiler/TagParserData.php
- src/Latte/Runtime/Html.php
fileExtensions:
- php
- phtml
ignoreErrors:
# --- Whole project ---
- # Factory/derive pattern — new static() is intentional in Node hierarchy
message: '#Unsafe usage of new static\(\)#'
paths:
- src/Latte/Compiler/Nodes/
- src/Latte/Essential/Nodes/
- src/Latte/Sandbox/Nodes/
- # Match with exhaustive else branch as safety net
message: '#Match expression does not handle remaining value.*#'
path: src/Latte
- # Latte callback system — callable has no fixed signature
message: '#no signature specified for (callable|Closure)#'
path: src/Latte
# --- AST Node classes: match() expressions with exhaustive typing ---
- # PHPStan sees redundant branches in match/ternary on nullable/union properties
message: '#(Left side of && is always false|Result of && is always false|always evaluate to (true|false)|Ternary operator condition is always true)#'
paths:
- src/Latte/Compiler/Nodes/
- src/Latte/Essential/Nodes/
- # getIterator() yields null for optional child nodes
message: '#Generator expects value type Latte\\Compiler\\Node, null given#'
paths:
- src/Latte/Compiler/Nodes/
- src/Latte/Essential/Nodes/
# --- Parsers: lookahead tokens can be null ---
- # Parser works with nullable tokens during lookahead/backtrack
message: '#Latte\\Compiler\\(Position|Range|Token)\|null#'
paths:
- src/Latte/Compiler/TagParser.php
- src/Latte/Compiler/TemplateParser.php
- src/Latte/Compiler/TemplateParserHtml.php
- # TemplateParser: nullable Tag when processing nested tags
message: '#on Latte\\Compiler\\Tag\|null#'
path: src/Latte/Compiler/TemplateParser.php
- # TemplateParser: nullable Closure for optional callbacks
message: '#Closure\|null given#'
path: src/Latte/Compiler/TemplateParser.php
- # TemplateParser: dynamic access to expression node properties
message: '#(undefined property.*ExpressionNode|Variable \$name might not be defined)#'
path: src/Latte/Compiler/TemplateParser.php
- # TemplateParserHtml: dynamic HTML element objects and destructuring
message: '#(object\{tag:.*not writable|undefined property.*object\{|has parameter \$elem with no type|array destructuring on list)#'
path: src/Latte/Compiler/TemplateParserHtml.php
# --- TagParser: generated trait TagParserData ---
- # Methods called from generated trait TagParserData (excluded from analysis)
message: '#^(Static method|Method) Latte\\Compiler\\TagParser::(checkFunctionName|checkPlaceholders|warnUnqualifiedConstant|handleBuiltinTypes|parseOffset|parseDocString|startPos|endPos)\(\) is unused\.$#'
path: src/Latte/Compiler/TagParser.php
- # Internal parser state machine — types from regex results and token operations
message: '#^(Cannot access offset 0 on|Cannot use array destructuring on|Instanceof between.*InterpolatedStringPartNode will always evaluate to false|Offset.*might not exist on|Unary operation.*on string results in an error)#'
path: src/Latte/Compiler/TagParser.php
# --- PrintContext::format() — regex-based code generation ---
- # Regex groups guarantee offset existence, PHPStan cannot see this
message: '#^Offset [1-5] (does not|might not) exist on array\{#'
path: src/Latte/Compiler/PrintContext.php
- # OperatorNode is abstract, print() exists on concrete subclasses
message: '#(OperatorNode::print\(\)|parenthesize\(\) expects Latte\\Compiler\\Nodes\\Php\\OperatorNode, Latte\\Compiler\\Node given)#'
path: src/Latte/Compiler/PrintContext.php
# --- SecurityPolicy: reference-based caching pattern ---
- # $res = &$cache[...] — PHPStan cannot analyze auto-vivification and reference state
message: '#(always evaluate to (true|false)|Result of \|\| is always true|is never read, only written|Unreachable statement|always exists and is not nullable)#'
path: src/Latte/Sandbox/SecurityPolicy.php
# --- Tracy bridge ---
- # Intentional version_compare() guards for Tracy compatibility
message: '#side of && is always true#'
path: src/Bridges/Tracy/BlueScreenPanel.php
- # Anonymous Extension class for collecting rendered templates (write-only by design)
message: '#Extension@anonymous.*LattePanel#'
path: src/Bridges/Tracy/LattePanel.php
- # Compiled phtml template — stdClass from Tracy context
message: '#on stdClass\|false#'
path: src/Bridges/Tracy/dist/panel.phtml
# --- Other ---
- # Linter: dynamic loading of Nette bridge extensions
identifier: class.notFound
path: src/Tools/Linter.php
-
message: '#expects Latte\\Extension, Nette\\#'
path: src/Tools/Linter.php
- # NodeTraverser: getIterator() yields references to typed properties,
# so `$subnode = $res` can throw TypeError. PHPStan doesn't model
# assignment through a reference bound to a typed property.
message: '#^Dead catch \- TypeError is never thrown in the try block\.$#'
identifier: catch.neverThrown
count: 1
path: src/Latte/Compiler/NodeTraverser.php
- # Blueprint: nullable type from reflection
message: '#expects string, string\|null given#'
path: src/Latte/Essential/Blueprint.php
- # class_alias for backward compatibility
identifier: class.notFound
path: src/Latte/Compiler/Nodes/PrintNode.php
- # codePointToUtf8: bitwise operations lose range information for chr()
# decodeNumber: $str + 0 is a standard PHP idiom for string-to-number conversion
message: '#(chr expects int\<0, 255\>|string.*results in an error)#'
path: src/Latte/Compiler/PhpHelpers.php
- # flock/ftruncate: PHPStan requires more specific int range
message: '#(flock expects int\<0, 7\>|ftruncate expects int\<0, max\>)#'
path: src/Latte/Runtime/Cache.php
- # array_slice() returns array, not list
message: '#expects list<Latte\\Compiler\\Token>, array<Latte\\Compiler\\Token> given#'
paths:
- src/Latte/Compiler/TemplateParser.php
- src/Latte/Compiler/TemplateParserHtml.php
-
message: '#^Offset 0 might not exist on array\{\}\|array\{string\}\.$#'
identifier: offsetAccess.notFound
count: 1
path: src/Latte/Compiler/TemplateLexer.php
-
message: '#^Method Latte\\Engine\:\:loadTemplate\(\) should return class\-string\<Latte\\Runtime\\Template\> but returns string\.$#'
identifier: return.type
count: 1
path: src/Latte/Engine.php
-
message: '#^Method Latte\\Essential\\Tracer\:\:generateTrace\(\) should return array\<array\{function\: string, file\: string, line\: int, args\: array\<mixed\>\}\> but returns array\<int\<\-1, max\>, array.+\>\.$#'
identifier: return.type
count: 1
path: src/Latte/Essential/Tracer.php
-
message: '#^Offset int\<min, \-2\>\|int\<0, max\> might not exist on non\-empty\-list\<string\>\.$#'
identifier: offsetAccess.notFound
count: 1
path: src/Latte/Helpers.php
-
message: '#^Expression on left side of \?\? is always null\.$#'
identifier: nullCoalesce.expr
count: 1
path: src/Latte/Runtime/HtmlHelpers.php
-
message: '#^Result of static method Latte\\Runtime\\HtmlHelpers\:\:triggerInvalidValue\(\) \(void\) is used\.$#'
identifier: staticMethod.void
count: 1
path: src/Latte/Runtime/HtmlHelpers.php
-
message: '#^Variable \$block on left side of \?\?\= always exists and is not nullable\.$#'
identifier: nullCoalesce.variable
count: 1
path: src/Latte/Runtime/Template.php
-
message: '#^Expression on left side of \?\? is always null\.$#'
identifier: nullCoalesce.expr
count: 1
path: src/Latte/Runtime/XmlHelpers.php
-
message: '#^Result of static method Latte\\Runtime\\HtmlHelpers\:\:triggerInvalidValue\(\) \(void\) is used\.$#'
identifier: staticMethod.void
count: 1
path: src/Latte/Runtime/XmlHelpers.php
-
message: '#^Call to function is_callable\(\) with arguments callable\(\)\: mixed, false and mixed will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: src/Latte/Sandbox/RuntimeChecker.php
-
message: '#^Class Latte\\Sandbox\\Nodes not found\.$#'
identifier: class.notFound
count: 1
path: src/Latte/Sandbox/SandboxExtension.php