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. Key discussion points include: ordering restrictions for mutually-recursive type bounds, intersection type restrictions with unbounded type parameters, arity validation behavior (opt-in via turbofish syntax), diamond inheritance checks, the turbofish `::< >` syntax choice, and `+`/`-` variance markers. The RFC author clarifies that arity validation is opt-in at call sites using turbofish, existing code remains unaffected, and the design is intentionally extensible toward reified runtime generics in the future.

5h 2m read timeFrom externals.io
Post cover image
144 Impressions