Bug #75232 [ReO->Csd]: print_r of DateTime creating side-effect

From: Date: Thu, 18 Apr 2019 13:52:11 +0000
Subject: Bug #75232 [ReO->Csd]: print_r of DateTime creating side-effect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220519@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75232&edit=1 ID: 75232 Updated by: nikic@php.net Reported by: ben at redsnapper dot net Summary: print_r of DateTime creating side-effect -Status: Re-Opened +Status: Closed Type: Bug Package: Date/time related Operating System: any PHP Version: 7.1.9 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: This is fixed in 7.4. Previous Comments: ------------------------------------------------------------------------ [2018-09-29 12:30:30] nikic@php.net Related To: Bug #69925 ------------------------------------------------------------------------ [2018-07-06 14:41:05] cmb@php.net Still unresolved: <https://3v4l.org/fN6HB>. ------------------------------------------------------------------------ [2017-09-22 17:23:57] jhdxr@php.net @daverandom, bug #49382 was marked as "not a bug" because you believe that's a feature request rather than a bug. I don't think it's a good reason to close issue, but that't fine. but this issue focus on the different behaviors of $d->date before and after print_r. There is no doubt that this inconsistency is a bug. ------------------------------------------------------------------------ [2017-09-22 11:41:46] daverandom@php.net Dupe of https://bugs.php.net/bug.php?id=49382 ------------------------------------------------------------------------ [2017-09-20 09:05:04] gooh@php.net For the sake of completeness, this also happens when var_dump'ing or ReflectionObject::export'ing: php > $dt = new DateTime; php > var_dump($dt); object(DateTime)#3 (3) { ["date"]=> string(26) "2017-09-20 10:57:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } php > echo $dt->date; 2017-09-20 10:57:54.000000 php > $dt = new DateTime; php > ReflectionObject::export($dt); Object of class [ <internal:date> class DateTime implements DateTimeInterface ] { // some lines omitted … - Dynamic properties [3] { Property [ <dynamic> public $date ] Property [ <dynamic> public $timezone_type ] Property [ <dynamic> public $timezone ] } // some lines omitted … } php > echo $dt->date; 2017-09-20 10:57:57.000000 So it adds three public properties. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=75232 -- Edit this bug report at https://bugs.php.net/bug.php?id=75232&edit=1

« previous php.bugs (#220519) next »