Re: [RFC] [Discussion] Bound-Erased Generic Types
| From: | Barel | Date: | Tue, 12 May 2026 17:03:42 +0000 |
| Subject: | Re: [RFC] [Discussion] Bound-Erased Generic Types | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130854@lists.php.net to get a copy of this message | ||
On Sun, 10 May 2026 at 21:04, Seifeddine Gmati <azjezz@carthage.software>
wrote:
> Hello Internals,
>
> 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
>
> Thanks,
> Seifeddine.
>
Seifeddine,
Many thanks for such a detailed and interesting proposal. A couple of
suggestions for the RFC:
- It would be great to have some mention of the performance cost of this
feature, both for code which does not use generics and for code that does
use them
- It would be great to be able to see how the userland samples from
Laravel, Doctrine, etc... would look when using this new syntax, maybe you
could add a new section with this
Cheers
Carlos