Commit 0ec5f54
Relax subtype matching to work with non-finite union guard types
Replace the `count(getFiniteTypes()) > 1` restriction with a
`!$guardType instanceof MixedType` check. This allows conditional
expressions with non-finite union guards (e.g. int|string) to match
when the specified type is a strict subtype, while still preventing
incorrect matches against mixed-based types that would cause *NEVER*
type collapses.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 5796511 commit 0ec5f54
File tree
3 files changed
+31
-2
lines changed- src/Analyser
- tests/PHPStan/Rules/Variables
- data
3 files changed
+31
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3226 | 3226 | | |
3227 | 3227 | | |
3228 | 3228 | | |
| 3229 | + | |
3229 | 3230 | | |
3230 | 3231 | | |
3231 | 3232 | | |
3232 | 3233 | | |
3233 | | - | |
3234 | | - | |
| 3234 | + | |
| 3235 | + | |
3235 | 3236 | | |
3236 | 3237 | | |
3237 | 3238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1485 | 1485 | | |
1486 | 1486 | | |
1487 | 1487 | | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
1488 | 1497 | | |
1489 | 1498 | | |
1490 | 1499 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments