A property hook written by me, against a rule written by me, fourteen months later.
// what I wrote
public ?Invoice $invoice {
get => $this->invoices->findForOrder($this->id);
}
// and the loop somebody wrote in March
foreach ($orders as $order) {
if ($order->invoice !== null) { /* ... */ }
}
// 412 queries, and nothing at the call site suggests it
The rule from December 2024 was pure, cheap and total, and the first violation was mine within a quarter. A hook makes work invisible and invisible work in a loop is the oldest performance bug there is — it went back to invoice(), which is uglier and honest about being a call.