xref: /php-src/ext/date/tests/gh11455.phpt (revision 93becab5)
1--TEST--
2Bug GH-11455 (PHP 8.2 Segmentation fault on nesbot/carbon)
3--FILE--
4<?php
5class MyDateTimeImmutable extends DateTimeImmutable {
6    public function __construct(
7        string $datetime = "now",
8        ?DateTimeZone $timezone = null,
9        public ?stdClass $myProperty = null,
10    ) {
11        parent::__construct($datetime, $timezone);
12    }
13}
14
15$datetime = new MyDateTimeImmutable('2022-12-22T11:26:00Z', myProperty: new stdClass);
16$datetime->myProperty->field = str_repeat("hello", 3);
17$serialized = serialize($datetime);
18var_dump($datetime->myProperty);
19$unserialized = unserialize($serialized);
20var_dump($unserialized);
21?>
22--EXPECT--
23object(stdClass)#2 (1) {
24  ["field"]=>
25  string(15) "hellohellohello"
26}
27object(MyDateTimeImmutable)#3 (4) {
28  ["myProperty"]=>
29  object(stdClass)#4 (1) {
30    ["field"]=>
31    string(15) "hellohellohello"
32  }
33  ["date"]=>
34  string(26) "2022-12-22 11:26:00.000000"
35  ["timezone_type"]=>
36  int(2)
37  ["timezone"]=>
38  string(1) "Z"
39}
40