PHP’s sorts were unstable before 8.0, so two elements the comparator called equal came out in an order that could differ between runs and between array sizes.
// unstable on 7.4: two orders with the same date may swap
usort($orders, fn($a, $b) => $a->placedAt <=> $b->placedAt);
// deterministic, because nothing is ever equal
usort($orders, fn($a, $b) =>
[$a->placedAt, $a->id] <=> [$b->placedAt, $b->id]);
The array comparison with the spaceship operator is the neatest way to express a tiebreaker and reads better than a nested conditional. The symptom of the instability is a test that passes locally and fails in CI on a differently sized fixture, which is a confusing morning. 8.0 makes all sorts stable, which fixes it going forward and does nothing for code that has to run on 7.4 as well.