bug48476.phpt 875 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Bug #48476 (cloning extended DateTime class without calling parent::__constr crashed PHP)
  3. --FILE--
  4. <?php
  5. class MyDateTime extends DateTime {
  6. public function __construct() { }
  7. }
  8. class MyDateTimeZone extends DateTimeZone {
  9. public function __construct() { }
  10. }
  11. $o = new MyDateTime;
  12. try {
  13. var_dump($o->format("d"));
  14. } catch (Error $e) {
  15. echo $e->getMessage(), "\n";
  16. }
  17. $x = clone $o;
  18. try {
  19. var_dump($x->format("d"));
  20. } catch (Error $e) {
  21. echo $e->getMessage(), "\n";
  22. }
  23. clone $o;
  24. try {
  25. var_dump(timezone_location_get(clone new MyDateTimezone));
  26. } catch (Error $e) {
  27. echo $e->getMessage(), "\n";
  28. }
  29. ?>
  30. --EXPECT--
  31. The DateTime object has not been correctly initialized by its constructor
  32. The DateTime object has not been correctly initialized by its constructor
  33. The DateTimeZone object has not been correctly initialized by its constructor