Skip to content

Commit fc17bfa

Browse files
committed
Fixed bug #78383
1 parent 720438c commit fc17bfa

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.0beta3
44

5+
- Date:
6+
. Fixed bug #78383 (Casting a DateTime to array no longer returns its
7+
properties). (Nikita)
58

69
08 Aug 2019, PHP 7.4.0beta2
710

ext/date/php_date.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,6 +2293,7 @@ static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose
22932293
case ZEND_PROP_PURPOSE_SERIALIZE:
22942294
case ZEND_PROP_PURPOSE_VAR_EXPORT:
22952295
case ZEND_PROP_PURPOSE_JSON:
2296+
case ZEND_PROP_PURPOSE_ARRAY_CAST:
22962297
break;
22972298
default:
22982299
return zend_std_get_properties_for(object, purpose);
@@ -2414,6 +2415,7 @@ static HashTable *date_object_get_properties_for_timezone(zval *object, zend_pro
24142415
case ZEND_PROP_PURPOSE_SERIALIZE:
24152416
case ZEND_PROP_PURPOSE_VAR_EXPORT:
24162417
case ZEND_PROP_PURPOSE_JSON:
2418+
case ZEND_PROP_PURPOSE_ARRAY_CAST:
24172419
break;
24182420
default:
24192421
return zend_std_get_properties_for(object, purpose);

ext/date/tests/bug78383.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #78383: Casting a DateTime to array no longer returns its properties
3+
--FILE--
4+
<?php
5+
6+
var_dump((array) new DateTime('2000-01-01'));
7+
var_dump((array) new DateTimeZone('Europe/Berlin'));
8+
9+
?>
10+
--EXPECT--
11+
array(3) {
12+
["date"]=>
13+
string(26) "2000-01-01 00:00:00.000000"
14+
["timezone_type"]=>
15+
int(3)
16+
["timezone"]=>
17+
string(3) "UTC"
18+
}
19+
array(2) {
20+
["timezone_type"]=>
21+
int(3)
22+
["timezone"]=>
23+
string(13) "Europe/Berlin"
24+
}

0 commit comments

Comments
 (0)