> > On Sun, May 10, 2026 at 1:05 PM Seifeddine Gmati > <[email protected]> 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, > > This is a very interesting RFC, thank you! > > I have a technical request: can we lower the limit from 255 to a 7-bit > max? I've done tons of optimization work in the last 8-10 years of my > life, and having a spare bit on things for the future has often been > rewarded. And for me, I can't imagine a use-case for having 128-255 > type arguments in practice. Do you have any evidence that a 7-bit > maximum would be insufficient for real-world code? > > Thanks, Levi Morrison
Hi Levi, Good catch, lowered. The cap is now 127 (u7), with the high bit reserved for future per-site metadata. RFC updated: https://wiki.php.net/rfc/bound_erased_generic_types#the_127-argument_cap Honestly, there is no real-world evidence either way, no PHP codebase approaches either 127 or 255 type parameters, so this is purely about reserving headroom. Thanks, Seifeddine.
