It may be worth mentioning that within the Pattern Matching RFC future
scope, and mentioned a couple times within the discussion thread for the
RFC, there is a similar proposal that would allow for this without using
specific literal types.

It's outlined in
https://github.com/Crell/php-rfcs/blob/master/pattern-matching/future.md
under "Parameter or return guards"

It would allow for:

```
function setLogLevel (string $level is 'debug' | 'info' | 'warning' |
'error'): void {}
```

Of course, I don't think that a potential future scope of an in-draft RFC
is reason to dismiss a more direct implementation of literal scalar types,
but it may be useful to compare other ways we could achieve the same
functionality. I personally find pattern matching within parameter/return
types more versatile while keeping direct typing system more simplified.
Specifically for a range feature that Ben Ramsey brought up, pattern
matching for parameters seems much more appropriate.

All that being said, I would gladly welcome literal scalar types.

On Sun, Jun 14, 2026, 21:24 Seifeddine Gmati <[email protected]>
wrote:

> Hello Internals,
>
> I'd like to start the discussion on a new RFC adding literal scalar
> types to PHP.
>
> - RFC: https://wiki.php.net/rfc/literal_scalar_types
> - Implementation: https://github.com/php/php-src/pull/22314
>
> Thanks,
> Seifeddine.
>

Reply via email to