PHP Compile-Time Generics: A Pragmatic Compromise
2025-08-11

Generics have long been a sought-after feature for PHP, but runtime implementation has proven incredibly difficult. The PHP Foundation team proposes a different approach: compile-time generics limited to interfaces and abstract classes. This offers most of the benefits of generics while avoiding many pitfalls. By performing type checking at compile time, it significantly improves efficiency and reduces errors. While runtime generics remain impossible with this approach, it represents a substantial improvement, warranting serious community consideration.
Development
Compile-Time