On Mon, Jun 15, 2026, 11:59 PM Bob Weinand <[email protected]> wrote:
> Hey Seifeddine, > > > Am 15.06.2026 um 03:22 schrieb Seifeddine Gmati <[email protected] > >: > > > > 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. > > I think you are solving the wrong (or rather: only a specific subset of > the) problem. What you _actually_ probably want is pattern support in type > positions. Let me know if I'm wrong in my assumption here. > > I.e. basically support expressions as specified by > https://wiki.php.net/rfc/pattern-matching in property and function > argument/return positions. Which does this, and ranges and everything else > you'd need. > > Which is a worthwhile addition, but we should first get pattern-matching > done, then we can do one RFC broadening the applicability of patterns. > > Bob Hi Bob, My interest is not pattern matching; my focus is on the type system and expanding it to be more expressive. My main motivation is that static analysis tools (like PHPStan, Psalm, and Mago) already do many things that PHP itself cannot, and I believe those features belong in the engine. Literal types serve as a fundamental building block for future type system features such as array shapes, tuples, and potentially even conditional types. While this RFC works alongside the pattern matching proposal by Larry and Ilija, neither requires the other. The two are unrelated for several reasons. So to answer your question, no, I am not looking for pattern matching. I see these as two distinct features that address different needs within the language. Cheers, Seifeddine.
