Testing Strategy with the Help of a Static Analyzer
summary
Argues that you don’t need 100% coverage because PHPStan plus modern PHP type hints and phpstan‑strict catch many pre‑runtime bugs, so tests concentrate on business rules. Recommends turning on strict types and notices, using scalar and return types, replacing loose arrays and uniony parameter designs with small value objects, and keeping wiring vs business logic separate so wiring is verified by static analysis and business logic gets fast, mock‑free unit tests. Result: fewer brittle tests and clearer, safer code.
AI-written summary · about
chapters (22)
- 0:00Intro
- 2:01Static analyzer
- 3:37Type system
- 4:04function foo(): string
- 7:54Bugs found by...
- 13:14PHP 7.0
- 17:48Stringly-typed code
- 19:46Objects for everything
- 22:05Array as a collection
- 23:12I can process anything
- 24:00I do one thing well
- 24:49Nullable parameters
- 27:06Dynamic code
- 27:49Callables
- 31:35empty()
- 32:04phpstan/phpstan-strict-rules
- 33:00Refactoring tip
- 36:04Business logic
- 36:51Undetectable bugs in wiring?
- 37:28What is a unit test?
- 39:57Repository
- 40:54Facade
related talks
25mTypes & static analysis are good in PHP
44mTuning PHPStan to Maximum Strictness
32mFrom Zero to Static Analysis Hero
57mTuning PHPStan to Maximum Strictness
38mWhy you should be using PHPStan in all your projects
53mStatic Analysis Saved My Code Tonight
55mSquash Bugs with Static Analysis
50mPractical Advanced Static Analysis
