Commit debe6b2
committed
Do not map the sealed-array
- `ConstantArrayType::mapValueType()` ran the callback over the unsealed value
slot even for sealed arrays, where that slot is just the explicit-`never`
marker. Callbacks that are not pure type transformers (e.g. the `array_map`
callback evaluation, `array_walk`, array-dim assignments in loops) would
replace the marker with whatever they returned and leak that type into the
otherwise-sealed shape.
- For the reported case, evaluating `fn (SomeEnum $type) => $type->value` against
the `never` marker produces an `ErrorType`, which `describe()` hides but
`UnresolvableTypeHelper` (via `TypeTraverser`) finds, wrongly reporting
"contains unresolvable type" on a fully-resolved `array{'foo'}`.
- Only transform the unsealed value type when the array is genuinely unsealed;
otherwise keep the existing marker untouched. This central fix covers every
caller of `mapValueType()`.
- Added a unit test on `ConstantArrayType::mapValueType()` and an
AnalyserIntegrationTest reproducing the array_map + enum scenario under
bleeding edge.never marker in ConstantArrayType::mapValueType()
1 parent 041824d commit debe6b2
4 files changed
Lines changed: 72 additions & 2 deletions
File tree
- src/Type/Constant
- tests/PHPStan
- Analyser
- data
- Type/Constant
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3186 | 3186 | | |
3187 | 3187 | | |
3188 | 3188 | | |
3189 | | - | |
3190 | | - | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
3191 | 3195 | | |
3192 | 3196 | | |
3193 | 3197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1608 | 1608 | | |
1609 | 1609 | | |
1610 | 1610 | | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
1611 | 1618 | | |
1612 | 1619 | | |
1613 | 1620 | | |
| |||
| 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 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
1619 | 1621 | | |
1620 | 1622 | | |
1621 | 1623 | | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
1622 | 1646 | | |
1623 | 1647 | | |
1624 | 1648 | | |
| |||
0 commit comments