~/talk

Generics (in PHP)

Talkat Dutch PHP Conference 2024 · 2024-03-12..03-15· [php, typescript]
slides:none on file

Claim: generics bring precise typing and IDE support to PHP today via annotations rather than core language changes. Uses @template plus @implements/@extends and class-string to get type-safe factories, collection patterns and deserialization autocompletion, with PhpStorm, VS Code, PHPStan and Psalm enforcing checks and no runtime overhead. Core PHP lacks native generics because of C internals and performance concerns, but Symfony already annotates many components (security, serializer, DI) and annotations reliably catch mismatches at analysis time.

AI-written summary · about

  1. 0:00Introduction
  2. 2:30What are generics
  3. 5:04Main use cases
  4. 9:43Generics in other languages
  5. 15:13PHP generics state
  6. 18:30Workarounds in PHP
  7. 21:33Generics annotations
  8. 28:46Co- and contravariance
  9. 33:29PHP tools support
  10. 36:50Symfony generics
  11. 40:25Conclusion
~/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.