A PHP internals mailing list thread discussing a new RFC proposing bound-erased generic types for PHP. The RFC proposes generic type parameters on classes, interfaces, traits, functions, methods, closures, and arrow functions with bounds, defaults, and variance markers. Type parameters erase to their bound at runtime, with pre-erasure form 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 being opt-in via turbofish syntax, diamond inheritance checks, turbofish syntax vs alternatives, +/- variance markers vs in/out keywords, and the path toward future reified/runtime generics.

4h 40m read timeFrom externals.io
Post cover image
461 Impressions