Thanks for sharing this research work. Instead of having to choose between fully reified generics and erased type declarations, couldn't we have both? A new option in php.ini could allow to enable the “erased” mode as a performance, production-oriented optimization. In development, and on projects where performance isn't critical, types (including generics) will be enforced at runtime, but users will have the option of opting to disable these checks for production environments.
If this is not possible, the inline caches presented in the article, combined with “worker” runtimes such as FrankenPHP, Swoole, RoadRunner, etc., could make the cost of enforcing generics negligible: technically, types will be computed once and reused for many HTTP requests (because they are handled by the same long-running PHP script under the hood). As working runtimes already provide a significant performance improvement over FPM, we could say that even if non-performance-critical applications (most applications) will be a bit slower because of the new checks, people working on performance-sensitive applications will have the opportunity to reduce the cost of checks to virtually nothing by switching to a performance-oriented runtime. Cheers,