Bug #78195 [NEW]: Datetime object coverts to empty arrays

From: Date: Fri, 21 Jun 2019 20:59:13 +0000
Subject: Bug #78195 [NEW]: Datetime object coverts to empty arrays
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221444@lists.php.net to get a copy of this message
From: v-yitam at microsoft dot com Operating system: Irrelevant PHP version: 7.4.0alpha1 Package: Class/Object related Bug Type: Bug Bug description:Datetime object coverts to empty arrays Description: ------------ This seemingly happens with datetime objects only, not with simple user defined objects. Reproducible with PHP 7.4 Alpha 1 but not with PHP 7.3.6 Test script: --------------- <?php class foo { public $a; public $b; } $bar = new foo; $bar->a = 'A'; $bar->b = 'B'; var_dump($bar); $arr = (array) $bar; var_dump($arr); $date = date_create('2018-12-31 23:59:59.997'); date_default_timezone_set("America/Los_Angeles"); var_dump($date); $darr = (array) $date; var_dump($darr); ?> Expected result: ---------------- object(foo)#1 (2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } array(2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } object(DateTime)#2 (3) { ["date"]=> string(26) "2018-12-31 23:59:59.997000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } array(3) { ["date"]=> string(26) "2018-12-31 23:59:59.997000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } Actual result: -------------- object(foo)#1 (2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } array(2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } object(DateTime)#2 (3) { ["date"]=> string(26) "2018-12-31 23:59:59.997000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } array(0) { } -- Edit bug report at https://bugs.php.net/bug.php?id=78195&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78195&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78195&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78195&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=78195&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78195&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78195&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78195&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78195&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78195&r=support Expected behavior: https://bugs.php.net/fix.php?id=78195&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78195&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78195&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78195&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78195&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=78195&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78195&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78195&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78195&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78195&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78195&r=mysqlcfg

« previous php.bugs (#221444) next »