Bug #70810 [Com]: DateInterval equals every other DateInterval
Edit report at https://bugs.php.net/bug.php?id=70810&edit=1
ID: 70810
Comment by: php dot net at anthonychambers dot co dot uk
Reported by: f dot bosch at genkgo dot nl
Summary: DateInterval equals every other DateInterval
Status: Open
Type: Bug
Package: Date/time related
Operating System: linux
PHP Version: 5.6.14
Block user comment: N
Private report: N
New Comment:
I've found a similar issue: https://3v4l.org/TrPvp
What I found was that if I compared two DateInterval objects, they would always return false.
That is, until I actually get some data from one of the objects (in my case I just
var_export($interval, true) and discard the output) at which time everything starts to return true.
Also weird.
If I inspect both intervals first however, suddenly it all evaluates correctly! I've tested
this in PHP 7.0.0 and PHP 7.0.6. 3v4l.org suggests that it will work back to 5.5.8 though
Previous Comments:
------------------------------------------------------------------------
[2015-10-29 09:52:41] f dot bosch at genkgo dot nl
Actual and expected result are switched (sorry for that).
------------------------------------------------------------------------
[2015-10-29 09:50:59] f dot bosch at genkgo dot nl
Description:
------------
DateInterval always equals another DateInterval object while their inner values are different. This
is not expected behaviour. Looks like this is the case for all PHP versions: https://3v4l.org/bQnf0. If you ask me, this bug is different then
#70381 (Support comparing DateInterval objects).
Test script:
---------------
<?php
var_dump(new DateInterval('PT1H') == new DateInterval('P1D'));
var_dump(new DateInterval('PT1H') === new DateInterval('P1D'));
var_dump(new DateInterval('PT1H') , new DateInterval('P1D'));
Expected result:
----------------
bool(true)
bool(false)
object(DateInterval)#3 (0) { }
object(DateInterval)#4 (0) { }
Actual result:
--------------
bool(false)
bool(false)
object(DateInterval)#3 (0) { }
object(DateInterval)#4 (0) { }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70810&edit=1
Thread (6 messages)