Book: Decoupled PHP — Clean and Hexagonal Architecture for Applications That Outlive the Framework
Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go
My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools
Me: xgabriel.com | GitHub
You write a Money value object. You write a test. The test does this:
public function testAddTwoEuros(): void
{
$a = Money::of(100, 'EUR');
$b = Money::of(200, 'EUR');
self::assertSame(300, $a->add($b)->amount());
}
It passes. You ship it. Six months later, a colleague refactors add() to short-circuit when one side is zero, and the test still passes. Then production starts producing receipts where 0 EUR + 50 EUR = 0 EUR, because the early-return path returns $this without copying the other side's amount.
The test wasn't wrong. It was insufficient. You checked the one pair of numbers you happened to type
Discussion
Be the first to comment
Add your perspective to get the discussion started.