xref: /PHP-8.0/ext/date/tests/bug48476.phpt (revision f8d79582)
1--TEST--
2Bug #48476 (cloning extended DateTime class without calling parent::__constr crashed PHP)
3--FILE--
4<?php
5class MyDateTime extends DateTime {
6    public function __construct() { }
7}
8class MyDateTimeZone extends DateTimeZone {
9    public function __construct() { }
10}
11
12$o = new MyDateTime;
13try {
14    var_dump($o->format("d"));
15} catch (Error $e) {
16    echo $e->getMessage(), "\n";
17}
18$x = clone $o;
19
20try {
21    var_dump($x->format("d"));
22} catch (Error $e) {
23    echo $e->getMessage(), "\n";
24}
25
26clone $o;
27
28try {
29    var_dump(timezone_location_get(clone new MyDateTimezone));
30} catch (Error $e) {
31    echo $e->getMessage(), "\n";
32}
33?>
34--EXPECT--
35The DateTime object has not been correctly initialized by its constructor
36The DateTime object has not been correctly initialized by its constructor
37The DateTimeZone object has not been correctly initialized by its constructor
38