Re: [RFC] [Discussion] Bound-Erased Generic Types

From: Date: Wed, 13 May 2026 12:36:04 +0000
Subject: Re: [RFC] [Discussion] Bound-Erased Generic Types
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-130865@lists.php.net to get a copy of this message
Am 10.05.2026, 21:02:32 schrieb Seifeddine Gmati <azjezz@carthage.software>: > 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

« previous php.internals (#130865) next »