1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 04:02:19 +02:00
Files
archived-php-src/ext/date/tests/bug48476.phpt
Nikita Popov 3b2f2ce474 Make uninitialized DateTime an Error
This avoids many spurious false return values.
2019-08-09 14:51:25 +02:00

38 lines
869 B
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->getMessage(), "\n";
}
$x = clone $o;
try {
var_dump($x->format("d"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
clone $o;
try {
var_dump(timezone_location_get(clone new MyDateTimezone));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
The DateTime object has not been correctly initialized by its constructor
The DateTime object has not been correctly initialized by its constructor
The DateTimeZone object has not been correctly initialized by its constructor