Am 10.05.2026, 21:02:32 schrieb Seifeddine Gmati <[email protected]>:

> 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.
>


Hi Seifeddine,

I like this proposal very much, I personally don’t think its a problem that
some types are erased and some are not.

However, I do understand the arguments of others. As a compromise, we could
introduce a declare:

declare(erased_types=generic_only);

If this is not specified, then using generic syntax will throw an exception.

And it could give the option in the future to add two modes:

declare(erased_types=all);
declare(erased_types=none);

I’d prefer to land with a version without declare’s, but in this instance I
fear we need a temporary solution to get this off the ground until all the
pieces are in place.

greetings
Benjamin

Reply via email to