Generics in PHP: Today Already
summary
The talk explains how to model generics in PHP today using PHPDoc annotations so static analyzers like PHPStan and Psalm can understand and check parametrized types. It covers the concept of generics, practical use cases for typing collections and avoiding unsafe casts, and how generics are implemented and considered within PHPStan.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:35What is PHPStan
- 4:31PHP type problems
- 4:51What are generics
- 6:59How templates work
- 10:54Covariance and contravariance
- 14:43PHP 7.4 changes
- 16:52Solving generic problems
- 18:20PHPStan limitations
- 19:01Live demo
- 23:19Interface binding
- 25:30Reflection usage
- 27:20PHPDocs and stubs
- 28:47PHPStan Pro support








