bug67118.phpt 814 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Bug #67118 crashes in DateTime when this used after failed __construct
  3. --INI--
  4. date.timezone=Europe/Berlin
  5. --FILE--
  6. <?php
  7. class mydt extends datetime
  8. {
  9. public function __construct($time = 'now', $tz = NULL, $format = NULL)
  10. {
  11. if (!empty($tz) && !is_object($tz)) {
  12. $tz = new DateTimeZone($tz);
  13. }
  14. try {
  15. @parent::__construct($time, $tz);
  16. } catch (Exception $e) {
  17. echo "Bad date" . $this->format("Y") . "\n";
  18. }
  19. }
  20. };
  21. new mydt("Funktionsansvarig rådgivning och juridik", "UTC");
  22. ?>
  23. --EXPECTF--
  24. Fatal error: Uncaught Error: The DateTime object has not been correctly initialized by its constructor in %s:%d
  25. Stack trace:
  26. #0 %s(%d): DateTime->format('Y')
  27. #1 %s(%d): mydt->__construct(%s)
  28. #2 {main}
  29. thrown in %s on line %d