/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/date/tests/DatePeriod_uninitialised_exceptions.phpt
45 строк
1 KB
Derick Rethans
Implement More Appropriate Date/Time Exceptions RFC
08 фев 2023, 13:27
08 фев 2023, 13:27
b7860cd
Код
Авторство
О чём код?
--TEST-- DateTime uninitialised exceptions --INI-- date.timezone=Europe/London --FILE-- <?php class MyDatePeriod extends DatePeriod { function __construct() { } } function check(callable $c) { try { var_dump($c()); } catch (\DateObjectError $e) { echo $e::class, ': ', $e->getMessage(), "\n"; } } $mdp = new MyDatePeriod(); check(fn() => serialize($mdp)); check(fn() => $mdp->getStartDate()); check(fn() => $mdp->getDateInterval()); check(function() use ($mdp) { foreach($mdp as $foo) { } }); /* Allowed to be empty */ check(fn() => $mdp->getEndDate()); check(fn() => $mdp->getRecurrences()); ?> --EXPECTF-- DateObjectError: Object of type MyDatePeriod (inheriting DatePeriod) has not been correctly initialized by calling parent::__construct() in its constructor DateObjectError: Object of type MyDatePeriod (inheriting DatePeriod) has not been correctly initialized by calling parent::__construct() in its constructor DateObjectError: Object of type MyDatePeriod (inheriting DatePeriod) has not been correctly initialized by calling parent::__construct() in its constructor DateObjectError: Object of type DatePeriod has not been correctly initialized by calling parent::__construct() in its constructor NULL NULL