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: ordering restrictions for mutually-recursive type parameters, intersection type constraints, arity validation (opt-in via turbofish syntax), diamond inheritance checks, the turbofish `::< >` syntax choice over alternatives, `+`/`-` variance markers vs `in`/`out` keywords, and the path toward future reified/runtime generics.

5h 15m read timeFrom externals.io
Post cover image
120 Impressions