Suppose you need to change when an order can ship. You open the method and find this:
final class ShipOrders { /** @param list<Order> $orders */ public function ship ( array $orders ) : void { foreach ( $orders as $order ) { if ( $order -> isPaid ( ) ) { if ( $order -> isReady ( ) ) { if ( $order -> hasAddress ( ) ) { $order -> ship ( ) ; } } } } } }
Enter fullscreen mode
Exit fullscreen mode
Assume the three questions return bool and ship() returns void . The types are consistent. Every call exists. PHPStan accepts this code, including at its highest built-in rule level.
Now add another requirement: orders on hold must wait.
You have to find the right place inside that staircase, understand which conditions have already run, and preserve what happens when one fails. None of this is particularly difficult.…