Re: [RFC] [Discussion] Literal Scalar Types

From: Date: Mon, 15 Jun 2026 05:21:46 +0000
Subject: Re: [RFC] [Discussion] Literal Scalar Types
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-131256@lists.php.net to get a copy of this message
On 15.06.26 06:53, Ben Ramsey wrote:
On 6/14/26 20:22, Seifeddine Gmati 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.
I think I'm okay with this. David mentioned enums, and I do think enums are useful in many places where you want types like this, but there's a simplicity in this that I can't deny, and I like it.
I do like the simplicity of this. But - especially for floats and ints - the next level would be to allow not only
public function check(int -1|0|1 $minusOneThroughOne)
but also something like
public function check(int -1..1 $minusOneThrougOne)
which would then also allow
public function check (int 1..PHP_INT_MAX $positiveInt)
would that also be something to be considered? It seems like a logical alternate option to not have to add every value literally to the option list... Cheers Andreas -- ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andreas@heigl.org N 50°22'59.5" E 08°23'58" | | https://andreas.heigl.org | +---------------------------------------------------------------------+ | https://hei.gl/appointmentwithandreas | +---------------------------------------------------------------------+ | GPG-Key: https://hei.gl/keyandreasheiglorg | +---------------------------------------------------------------------+

Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc
« previous php.internals (#131256) next »