Re: Equality and relative ordering of objects
| From: | Rowan Collins | Date: | Sun, 24 Jun 2018 20:56:32 +0000 |
| Subject: | Re: Equality and relative ordering of objects | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102403@lists.php.net to get a copy of this message | ||
On 24/06/2018 21:31, Rudi Theunissen wrote:
So with that in mind, maybe it's okay to take "NULL falls back to default behaviour" idea out, and do a normalisation on whatever the user returns. If it's NULL, then that'll be 0, and the value will be equal. The only thing I don't like about that is that the user didn't specify "equal" with a 0, they returned the absence of a direction, and we should therefore either throw an exception internally, or fall back to the current comparison behaviour (comparing properties).Since this is a method, and not just a callback passed somewhere, could we simply mandate that the signature has an "int" return type? That way, if the class is written with strict_types=1, it will throw a TypeError for null, and the user will have a big hint that that's going to happen when they write ": int". Regards, -- Rowan Collins [IMSoP]