~/talk

Watch the clock

Talkat phpday 2024 · 2024-05-16..05-17· [testing]
slides:none on file

Explains a concrete design and the code pattern that makes time testable: a PSR-20 clock interface with a production SystemClock and a test FrozenClock, returning DateTimeImmutable from now(), injected as an interface and created by a small factory. Shows the exact constructor and test setup, how to avoid repeated time() calls, why time zones belong to values not the interface, and that the PSR is published and interoperable in real projects.

AI-written summary · about

  1. 0:00Introduction
  2. 0:57Why clocks matter
  3. 1:40Code quality best practices
  4. 2:23Filtering future items
  5. 3:49Testing pure functions
  6. 5:36Constructor injection
  7. 7:01First test case
  8. 8:05Fixing non-deterministic time
  9. 8:48Type safety with DateTimeImmutable
  10. 10:36Testing real time challenges
  11. 11:41Factory pattern for time
  12. 13:48Testing with fixed dates
  13. 15:15Clock interface
  14. 16:40System and test clocks
  15. 18:05Clock interface summary
  16. 19:11Why PHP-FIG matters
  17. 21:23Journey to PSR-20
  18. 23:29Interface design debate
  19. 24:11Time zones and Now
  20. 26:18Time zone value objects
  21. 27:22Clock implementations
  22. 28:47PSR-20 approval delays
  23. 29:30Q&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.