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 restrictions with unbounded generics, arity validation being opt-in via turbofish syntax, diamond inheritance checks, the use of turbofish (::< >) syntax for explicit type arguments, and +/- markers for covariance/contravariance. The RFC author and Bob Weinand debate tradeoffs around strictness vs. PHP's optional typing philosophy, with general agreement that the RFC is solid and extensible toward runtime generics in the future.

4h 33m read timeFrom externals.io
Post cover image
261 Impressions