@@ -241,6 +241,30 @@ Core:
241241 are available under Linux, FreeBSD, Windows, Mac, SunOS, AIX and their
242242 derivatives. If no required timers are provided by a corresponding
243243 platform, the function returns false.
244+ . Added two new magic methods: __compareTo and __equals. Classes may choose to
245+ implement these to define relative natural ordering and equality, which
246+ affects functions like in_array() and sort(), and comparison operators:
247+ <, >, <=, >=, <=>, ==, !=. The behaviour of === and !== has not changed.
248+ Classes that do not implement these methods will continue to be compared
249+ according to the rules that were introduced in PHP 5.
250+ (RFC: https://wiki.php.net/rfc/object-comparison)
251+
252+
253+ +Changes to object comparison behaviour
254+ +--------------------------------------
255+ +
256+ +* Classes may now implement a Comparable interface to override how objects are
257+ + compared to other values. If implemented, the class must implement a public
258+ + compareTo() method with the signature:
259+ +
260+ + public function compareTo($other)
261+ +
262+ + This method must return a negative integer to signal that the object is less
263+ + than $other, zero to signal that the object is equal to $other, or a positive
264+ + integer to signal that the object is greater than $other.
265+ +
266+ + Objects that don't implement Comparable will continue to be compared
267+ + according to the rules used in PHP 5.
244268
245269Date:
246270 . Added the DateTime::createFromImmutable() method, which mirrors
0 commit comments