Bug #78181 [Opn->Nab]: DateInterval can no longer be comparable according to its public properties
| From: | nikic@php.net | Date: | Wed, 19 Jun 2019 11:03:59 +0000 |
| Subject: | Bug #78181 [Opn->Nab]: DateInterval can no longer be comparable according to its public properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-221386@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78181&edit=1
ID: 78181
Updated by: nikic@php.net
Reported by: nyamsprod at gmail dot com
Summary: DateInterval can no longer be comparable according
to its public properties
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: No relevant
PHP Version: 7.4.0alpha1
Block user comment: N
Private report: N
New Comment:
DateInterval objects never compared according to their public properties -- they always compared
equal.
We may introduce comparable intervals (https://github.com/php/php-src/pull/4063), but they currently
do not exist and have never existed.
Previous Comments:
------------------------------------------------------------------------
[2019-06-19 11:00:26] nyamsprod at gmail dot com
Description:
------------
The DateInterval object exposes public properties. We should be able to compare two instances based
on their public properties like it is possible for any other object. It is the case currently in
PHP7.3-
Test script:
---------------
$interval1 = new DateInterval('PT3H');
$interval2 = new DateInterval('PT3H');
var_dump($interval1 == $interval2);
var_dump($interval1 === $interval2);
$obj1 = new stdClass();
$obj1->foo = 'bar';
$obj2 = new stdClass();
$obj2->foo = 'bar';
var_dump($obj1 == $obj2);
var_dump($obj1 === $obj2);
Expected result:
----------------
bool(true)
bool(false)
bool(true)
bool(false)
Actual result:
--------------
Warning: Cannot compare DateInterval objects in /in/G7jM0 on line 6
bool(false)
bool(false)
bool(true)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78181&edit=1