1--TEST--
2DateTime uninitialised exceptions
3--INI--
4date.timezone=Europe/London
5--FILE--
6<?php
7class MyDateTimeImmutable extends DateTimeImmutable
8{
9	function __construct()
10	{
11	}
12}
13
14function check(callable $c)
15{
16	try {
17		var_dump($c());
18	} catch (\DateObjectError $e) {
19		echo $e::class, ': ', $e->getMessage(), "\n";
20	}
21}
22
23$mdti = new MyDateTimeImmutable();
24$dt = new DateTimeImmutable();
25$di = DateInterval::createFromDateString("tomorrow");
26$dtz = new DateTimeZone("Europe/Kyiv");
27
28check(fn() => DateTimeImmutable::createFromInterface($mdti));
29check(fn() => DateTime::createFromImmutable($mdti));
30check(fn() => serialize($mdti));
31check(fn() => date_format($mdti, DateTime::ISO8601));
32check(fn() => $mdti->format(DateTime::ISO8601));
33check(fn() => $mdti->modify("+1 day"));
34check(fn() => $mdti->add($di));
35check(fn() => $mdti->sub($di));
36check(fn() => date_timezone_get($mdti));
37check(fn() => $mdti->getTimeZone());
38check(fn() => $mdti->setTimeZone($dtz));
39check(fn() => date_offset_get($mdti));
40check(fn() => $mdti->getOffset());
41check(fn() => $mdti->setTime(17, 59, 53));
42check(fn() => $mdti->setDate(2023, 1, 16));
43check(fn() => $mdti->setISODate(2023, 3, 1));
44check(fn() => $mdti->setTimestamp(time()));
45check(fn() => date_timestamp_get($mdti));
46check(fn() => $mdti->getTimestamp());
47check(fn() => date_diff($dt, $mdti));
48check(fn() => date_diff($mdti, $dt));
49check(fn() => date_diff($mdti, $mdti));
50check(fn() => $dt->diff($mdti));
51check(fn() => $mdti->diff($dt));
52check(fn() => $mdti->diff($mdti));
53?>
54--EXPECTF--
55DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
56DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
57DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
58DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
59DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
60DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
61DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
62DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
63DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
64DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
65DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
66DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
67DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
68DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
69DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
70DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
71DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
72DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
73DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
74DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
75DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
76DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
77DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
78DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
79DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor
80