Commit 8278442
committed
Narrow backed-enum scalar cast to
Per @arnaudlb's review: the scalar→backed-enum coercion should not fire
when the property type already accepts the scalar literally, e.g.
`Suit|string|int`. In that case the caller opted into accepting the raw
scalar and promoting it to an enum case would be a surprising silent
conversion.
Add `(ZEND_TYPE_PURE_MASK(pi->type) & ~MAY_BE_NULL) == 0` so the cast
only runs for pure-enum types (`Enum`) and their nullable variant
(`?Enum`). Union types get the engine's standard type check.Enum / ?Enum only1 parent 25226d3 commit 8278442
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
769 | 769 | | |
770 | 770 | | |
771 | 771 | | |
772 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
773 | 777 | | |
774 | 778 | | |
775 | 779 | | |
| |||
0 commit comments