~/talk

PHP Generics Today

Talkat Laravel Live Denmark 2026 · 2026-08-20..08-21· [php]
slides:none on file

Explains that PHP already supports generics via docblock @template annotations consumed by static analyzers like Psalm and PHPStan, showing concrete examples: typed arrays/collections, a generic Queue (add/getNext), a mirror function that preserves T, and Laravel’s app(Class::class) using class-string<T> to return T. Runtime checks are absent, so CI must include static analysis. A recent RFC for partial language support fails, but the docblock approach is used successfully in production.

AI-written summary · about

  1. 0:00Introduction of speaker
  2. 1:18Why types matter in PHP
  3. 5:10Limitations of PHP type system
  4. 6:23Type hints vs type declarations
  5. 9:50Introducing generics concept
  6. 13:23Generics in functions
  7. 15:17Generics with interfaces
  8. 19:56Real-world generics example
  9. 23:06Benefits of generics in PHP
  10. 25:04Language support for generics
  11. 28:21Summary and future outlook
  12. 28:44Q&A session
~/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.