xref: /PHP-8.2/ext/date/tests/bug80047.phpt (revision 001e7dbb)
1--TEST--
2Bug #80047: DatePeriod doesn't support custom DateTimeImmutable
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7class CustomDateTime extends DateTime {}
8class CustomDateTimeImmutable extends DateTimeImmutable {}
9
10$dt = new DateTime('2022-06-24');
11$dti = new DateTimeImmutable('2022-06-24');
12$cdt = new CustomDateTime('2022-06-25');
13$cdti = new CustomDateTimeImmutable('2022-06-25');
14$i = new DateInterval('P1D');
15
16$tests = [
17	[ $dt,   $i, $cdt  ],
18	[ $cdt,  $i, $dt   ],
19	[ $cdt,  $i, $cdt  ],
20	[ $dti,  $i, $cdti ],
21	[ $cdti, $i, $dti  ],
22	[ $cdti, $i, $cdti ],
23	[ $cdt,  $i, $cdti ],
24];
25
26foreach ($tests as $test) {
27	$dp = new DatePeriod(...$test);
28	foreach ($dp as $date) {}
29	echo get_class($date), "\n";
30}
31?>
32--EXPECT--
33DateTime
34DateTime
35DateTime
36DateTimeImmutable
37DateTimeImmutable
38DateTimeImmutable
39DateTimeImmutable
40