1--TEST-- 2Bug GH-11416: Crash with DatePeriod when uninitialised objects are passed in 3--INI-- 4date.timezone=UTC 5--FILE-- 6<?php 7$now = new DateTimeImmutable(); 8 9$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor(); 10try { 11 new DatePeriod($date, new DateInterval('P1D'), 2); 12} catch (Error $e) { 13 echo get_class($e), ': ', $e->getMessage(), "\n"; 14} 15 16$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor(); 17try { 18 new DatePeriod($now, new DateInterval('P1D'), $date); 19} catch (Error $e) { 20 echo get_class($e), ': ', $e->getMessage(), "\n"; 21} 22 23echo "OK\n"; 24?> 25--EXPECT-- 26Error: The DateTimeInterface object has not been correctly initialized by its constructor 27Error: The DateTimeInterface object has not been correctly initialized by its constructor 28OK 29