Bug #74940 [Opn]: DateTimeZone loose comparison always true until properties are initialized.
| From: | heiglandreas@php.net | Date: | Sat, 22 Jul 2017 05:53:04 +0000 |
| Subject: | Bug #74940 [Opn]: DateTimeZone loose comparison always true until properties are initialized. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210181@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74940&edit=1
ID: 74940
Updated by: heiglandreas@php.net
Reported by: arjen at parse dot nl
Summary: DateTimeZone loose comparison always true until
properties are initialized.
Status: Open
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 7.1.7
Block user comment: N
Private report: N
New Comment:
That seems to be related to the issue with setting internal variables on var_Dump. But from my POV
it should definitely evaluate to false in ALL cases when the timezones mismatch.
Previous Comments:
------------------------------------------------------------------------
[2017-07-17 12:52:17] arjen at parse dot nl
Description:
------------
When using the loose equal comparision, the result is always true when the internal DateTimeZone
properties have not been initialized yet.
Properties have to be 'initialized' by var_dump'ing the objects.
See https://3v4l.org/EQ1AG#v720alpha3
Test script:
---------------
<?php
$tz = new DateTimeZone('Europe/Amsterdam');
$utc = new DateTimeZone('UTC');
var_dump($tz == $utc);
var_dump($tz === $utc);
var_dump($tz, $utc);
var_dump($tz == $utc);
var_dump($tz === $utc);
Expected result:
----------------
bool(false)
bool(false)
object(DateTimeZone)#1 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
object(DateTimeZone)#2 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(false)
object(DateTimeZone)#1 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
object(DateTimeZone)#2 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74940&edit=1