Re: [RFC] [Discussion] Bound-Erased Generic Types
| From: | Derick Rethans | Date: | Mon, 25 May 2026 15:28:10 +0000 |
| Subject: | Re: [RFC] [Discussion] Bound-Erased Generic Types | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131010@lists.php.net to get a copy of this message | ||
On Sun, 10 May 2026, Seifeddine Gmati wrote:
> I'd like to start the discussion on a new RFC adding bound-erased
> generics types to PHP.
>
> Generic type parameters can be declared on classes, interfaces,
> traits, functions, methods, closures, and arrow functions, with
> bounds, defaults, and variance markers. Type parameters erase to their
> bound at runtime; the pre-erasure form is preserved for Reflection and
> consumed by static analyzers.
>
> - RFC: https://wiki.php.net/rfc/bound_erased_generic_types
> - Implementation: https://github.com/php/php-src/pull/21969
I have just read through this well-put-together RFC again. It however
does not change my opinion that I don't believe that having types
declared, but not generally enforced, is a good idea.
I have had several conversions with PHP users over the last few weeks,
and although many would like generics, they were almost exclusively
confused when it became clear these types weren't enforced.
It would create another paradigm for PHP users, different from
everywhere else where types are defined they are enforced.
I therefore do not believe this is a way forward, and await what the
result of https://thephp.foundation/blog/2025/08/05/compile-generics/
is
going to turn out to be.
with kind regards,
Derick
--
https://derickrethans.nl | https://xdebug.org | https://dram.io
Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support
mastodon: @derickr@phpc.social @xdebug@phpc.social