Use Generics in PHP. Today.
Developers in other languages like Java, C#, or TypeScript, have been enjoying the benefits of generics for a long time. They allow us to describe precise types of values included in a collection object or to work around type system limitations without the need for unsafe type casting.
PHP does not support generics natively but with the help of PHPDocs, we’re able to simulate them. Static analysers like PHPStan or Psalm are able to interpret generics and take advantage of them to find more bugs thanks to strongly-typed code.
In this talk I’ll introduce the concept of generics, show several useful use cases to the audience, and even dive into how they’re implemented in PHPStan and what had to be considered during the development.
* What are generics and how they enhance function and method signatures.
* What practical use cases can be solved with generics.
* What’s covariance and contravariance and how do they relate to generics.
* How are generics implemented in PHPStan.
Session info:
Speaker: Ondrej Mirtes
PHPStan at PHPStan
Date: 13 March 2026
Time: 13:30 - 14:15
Relevant tags:
Generics
PHP











