Commit 9f0b709
Move HasOffset type stripping from isValidVariance to generalizeInferredTemplateType
Instead of working around the equals check in TemplateTypeVariance::isValidVariance(),
strip HasOffsetValueType and HasOffsetType during template type generalization in
TemplateTypeHelper::generalizeInferredTemplateType(). This normalizes inferred
template types before they reach the invariance check, so equals() naturally
returns true without needing special handling.
Changing IntersectionType::equals() globally was investigated but breaks scope
tracking and type narrowing (introduces false positives in PHPStan self-analysis).
The generalization approach is more targeted: it only affects inferred template
type arguments for non-covariant templates, which is the correct normalization
point for this precision.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 7b29df6 commit 9f0b709
2 files changed
Lines changed: 11 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
150 | 161 | | |
151 | 162 | | |
152 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | | - | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
| |||
180 | 177 | | |
181 | 178 | | |
182 | 179 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | 180 | | |
191 | 181 | | |
192 | 182 | | |
| |||
269 | 259 | | |
270 | 260 | | |
271 | 261 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | 262 | | |
0 commit comments