1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/date/tests/bug48476.phpt
2023-02-08 10:27:33 +00:00

38 lines
1.1 KiB
PHP

--TEST--
Bug #48476 (cloning extended DateTime class without calling parent::__constr crashed PHP)
--FILE--
<?php
class MyDateTime extends DateTime {
public function __construct() { }
}
class MyDateTimeZone extends DateTimeZone {
public function __construct() { }
}
$o = new MyDateTime;
try {
var_dump($o->format("d"));
} catch (Error $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$x = clone $o;
try {
var_dump($x->format("d"));
} catch (Error $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
clone $o;
try {
var_dump(timezone_location_get(clone new MyDateTimezone));
} catch (Error $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
DateObjectError: Object of type MyDateTime (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor
DateObjectError: Object of type MyDateTime (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor
DateObjectError: Object of type MyDateTimeZone (inheriting DateTimeZone) has not been correctly initialized by calling parent::__construct() in its constructor