Commit 56b1476
Fix phpstan/phpstan#10076: Union of string literal and class-string<T> loses literal members
- GenericClassStringType::isSuperTypeOf() returned Yes for non-class-string
constants when the generic type was MixedType (including TemplateMixedType)
- This caused TypeCombinator::union to absorb string literals like 'object'
and 'array' into class-string<T>, losing them from the union
- Added a check: when generic type is MixedType but the constant string is
not a class-string, return Maybe instead of Yes
- New regression test in tests/PHPStan/Rules/Functions/data/bug-10076.php1 parent 4c6ef6e commit 56b1476
3 files changed
Lines changed: 28 additions & 0 deletions
File tree
- src/Type/Generic
- tests/PHPStan/Rules/Functions
- data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2817 | 2817 | | |
2818 | 2818 | | |
2819 | 2819 | | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
2820 | 2825 | | |
| 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 | + | |
| 20 | + | |
0 commit comments