budget
budget copied to clipboard
Fix usort() in php8
trafficstars
Sorry, what's the point of this? I'm reading the following in the PHP docs.
If two members compare as equal, they retain their original order. Prior to PHP 8.0.0, their relative order in the sorted array was undefined.
I'm not sure what this change is about, do you want to elaborate?
Ah, hold up. I'm seeing a deprecation notice because usort() is returning a boolean and it wants an integer. I see.
Shouldn't we swap $a and $b then, to keep the logic the same?
- return $a->happened_on <=> $b->happened_on;
+ return $b->happened_on <=> $a->happened_on;