A PHP internals RFC discussion proposes adding literal scalar types to PHP, allowing function signatures to express exact accepted values like `0|1|2` or `"ascii"|"utf-8"` as types. The RFC author argues this fills gaps that enums cannot: retrofitting existing scalar APIs without breaking callers, defining open value sets that can grow without BC breaks, and enabling direct scalar interop (array keys, JSON, strict equality). A community member counters that enums already cover most use cases, questioning whether the scope of change is justified, and arguing backed enums handle scalar interop through value exposure.

7m read timeFrom externals.io
Post cover image
192 Impressions