budget icon indicating copy to clipboard operation
budget copied to clipboard

Fix usort() in php8

Open flavius-constantin opened this issue 4 years ago • 3 comments
trafficstars

flavius-constantin avatar Oct 04 '21 08:10 flavius-constantin

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?

range-of-motion avatar Feb 28 '22 20:02 range-of-motion

Ah, hold up. I'm seeing a deprecation notice because usort() is returning a boolean and it wants an integer. I see.

range-of-motion avatar Feb 28 '22 20:02 range-of-motion

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;

range-of-motion avatar Feb 28 '22 20:02 range-of-motion