Skip to content

Commit e490eba

Browse files
committed
Added draft upgrading and news additions
1 parent 20a1efc commit e490eba

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PHP NEWS
1414
. Fixed bug #76439 (Changed behaviour in unclosed HereDoc). (Nikita, tpunt)
1515
. Added syslog.facility and syslog.ident INI entries for customizing syslog
1616
logging. (Philip Prindeville)
17+
. Added user-defined object comparison (https://wiki.php.net/rfc/object-comparison). (Rudi)
1718

1819
- DOM:
1920
. Fixed bug #76285 (DOMDocument::formatOutput attribute sometimes ignored).

UPGRADING

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

245269
Date:
246270
. Added the DateTime::createFromImmutable() method, which mirrors

0 commit comments

Comments
 (0)