Return Int Not Bool

no-email (Damien Seguy), Damien Seguy
Thu, 19 Dec 2024 00:00:00 +0000

There is a cute deprecation warning, when using a closure to sort an array: ``Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero``.
And if this deprecation is ignored, the boolean is cast automatically to an integer. As PHP turns 0 to false, and everything else, including 1 and -1 to true, this leads to surprising sorting effect.
Just trust the deprecation notice.