Commit ca76429
Use isSuperTypeOf as guard in IntersectionType::isAcceptedBy() instead of special-casing callable&array
Replace the callable&array-specific narrowing logic with a general
approach: after the standard lazyMaxMin check, if it returns Yes,
verify with isSuperTypeOf that the accepting type is actually a
supertype of the full intersection. This catches cases where
MixedType's accepts-everything behavior causes false acceptances
(e.g. array<int> falsely accepting array<mixed>&hasOffsetValue
or array<mixed>&callable intersections).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8bbf9bb commit ca76429
3 files changed
Lines changed: 25 additions & 16 deletions
File tree
- src/Type
- tests/PHPStan/Rules/Methods
- data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | 302 | | |
318 | | - | |
| 303 | + | |
319 | 304 | | |
320 | 305 | | |
321 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
322 | 314 | | |
323 | 315 | | |
324 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4055 | 4055 | | |
4056 | 4056 | | |
4057 | 4057 | | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
| 4061 | + | |
4058 | 4062 | | |
4059 | 4063 | | |
4060 | 4064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
50 | 63 | | |
0 commit comments