1--TEST-- 2DateTimeImmutable::createFromInterface exception 3--INI-- 4date.timezone=Europe/London 5--FILE-- 6<?php 7class MyDateTime extends DateTime 8{ 9 function __construct() 10 { 11 } 12} 13 14class MyDateTimeImmutable extends DateTimeImmutable 15{ 16 function __construct() 17 { 18 } 19} 20 21$i = new MyDateTime(); 22try { 23 $m = DateTimeImmutable::createFromInterface( $i ); 24} catch (\DateObjectError $e) { 25 echo $e::class, ': ', $e->getMessage(), "\n"; 26} 27 28$i = new MyDateTimeImmutable(); 29try { 30 $m = DateTimeImmutable::createFromInterface( $i ); 31} catch (\DateObjectError $e) { 32 echo $e::class, ': ', $e->getMessage(), "\n"; 33} 34?> 35--EXPECTF-- 36DateObjectError: Object of type MyDateTime (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor 37DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor 38