~/talk

Use Generics in PHP Today

Talkat International PHP Conference Berlin 2026 · 2026-06-08..06-12· [php]
slides:none on file

Shows how to get true generics in PHP today using PHPDoc generics and static analyzers like PHPStan and Psalm, not language changes. Demonstrates concrete patterns: function and class templates, making ReflectionClass and builtins generic with stop files, typing collections and inferring return types, coupling original→derivative types, and newer call-site variance and star projection features that lift common limitations so static analysis reports correct errors instead of silencing real bugs.

AI-written summary · about

  1. 0:00Introduction
  2. 0:43PHPStan and generics
  3. 1:51Understanding generics
  4. 3:39Generics in static analysis
  5. 5:05PHP lacks native generics
  6. 6:08Type variables syntax
  7. 7:14Generics for functions
  8. 8:18Real-world array_map
  9. 10:25Generic classes
  10. 12:55Extending generic classes
  11. 14:45PHPStan errors with generics
  12. 15:32ReflectionClass type issues
  13. 18:06Generic interfaces
  14. 19:57PHPStan stub files
  15. 21:44Type safety with generics
  16. 25:17Coupling classes
  17. 27:05Debugging PHPStan
  18. 29:17Generics limitations
  19. 30:19Covariance contravariance
  20. 33:20Collection type issues
  21. 36:16Call-site variance
  22. 39:10Contravariant declarations
  23. 40:14Star projection
  24. 41:45Learning resources
  25. 43:07Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.