> On May 12, 2026, at 3:07 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.

I think this is a good proposal and mirrors the various Python PEPs that added 
erased type hints in Python 3.

Unlike TypeScript or Hack, Python has no official typechecker — though MyPy is 
a de facto standard, but it doesn’t ship alongside Python.

Those PEPs have spawned a healthy ecosystem of typecheckers (MyPy, Pyright, 
Pyre/Pyrefly, Pytype, ty, Zuban). Those typecheckers sometimes take different 
approaches to the same code (e.g. 
https://pyrefly.org/blog/container-inference-comparison/) but that seems 
healthy to me.

I’ve been writing Hack for almost five years, and while it’s true that Hack 
ships with its own typechecker, I’ve also been able to build a new typechecker 
for Hack (only reusing the parser) in the span of about 6 months. When you 
don’t have to worry about docblock parsing a lot of things become quite a bit 
easier.

This proposal would target a future version of PHP and would realistically only 
start to seep into code in 2027. I’m very confident that the average person 
writing PHP code in 2030 will prefer this proposal to using docblock types.

Best wishes,

Matt

Reply via email to