A PHP internals mailing list discussion about a proposed RFC for bound-erased generic types in PHP. The RFC proposes adding generic type parameters to classes, interfaces, traits, functions, methods, closures, and arrow functions, with bounds, defaults, and variance markers. Type parameters erase to their bound at runtime, while the pre-erasure form is preserved for Reflection and static analyzers. The discussion covers key design decisions including: type parameter ordering restrictions, intersection type constraints, arity validation (opt-in via turbofish syntax), diamond inheritance checks, the turbofish `::< >` syntax for explicit type arguments, and `+`/`-` variance markers. The RFC author and a reviewer debate trade-offs around backward compatibility, parser conflicts, and future extensibility toward reified runtime generics.

5h 8m read timeFrom externals.io
Post cover image
307 Impressions