From 3d9dad29c75a70e7985ed595dfa2a836e61418da Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 23 May 2022 11:31:55 +0200 Subject: [PATCH] Fix bug #67034: Unable to compare DateInterval instances with == operator Closes GH-1590. --- language/operators.xml | 14 ++++++++++++-- reference/datetime/dateinterval.xml | 12 ++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/language/operators.xml b/language/operators.xml index b8409dc3a5..33f5dd8097 100644 --- a/language/operators.xml +++ b/language/operators.xml @@ -1685,7 +1685,7 @@ echo $a <=> $b; // 1 object object Built-in classes can define its own comparison, different classes - are uncomparable, same class see Object Comparison @@ -1698,7 +1698,7 @@ echo $a <=> $b; // 1 array array Array with fewer members is smaller, if key from operand 1 is not - found in operand 2 then arrays are uncomparable, otherwise - compare + found in operand 2 then arrays are incomparable, otherwise - compare value by value (see following example) @@ -1786,6 +1786,16 @@ function standard_array_compare($op1, $op2) + + Incomparable Values + + While identity comparison (=== and !==) + can be applied to arbitrary values, the other comparison operators should only be + applied to comparable values. The result of comparing incomparable values is + undefined, and should not be relied upon. + + + &reftitle.seealso; diff --git a/reference/datetime/dateinterval.xml b/reference/datetime/dateinterval.xml index 9f8e9a0a02..fc5a85f944 100644 --- a/reference/datetime/dateinterval.xml +++ b/reference/datetime/dateinterval.xml @@ -28,6 +28,11 @@ is by calculating the difference between two date/time objects through DateTimeInterface::diff. + + Since there is no well defined way to compare date intervals, + DateInterval instances are + incomparable. + @@ -201,6 +206,13 @@ + + 7.4.0 + + DateInterval instances are incomparable now; + previously, all DateInterval instances were considered equal. + + 7.1.0 The f property was added.