From: poinsot dot julien at gmail dot com Operating system: PHP version: 5.5.3 Package: Date/time related Bug Type: Bug Bug description:Incomplete support of DateTimeImmutable as DateTime(Interface)
Description: ------------ Actually, DateTimeImmutable is not usable everywhere DateTime is. Missing support I have found is: * DatePeriod::__construct where end parameter does not allow a DateTimeImmutable objet as date_ce_date is used instead of date_ce_interface * intl extension (see grep -rn php_date_get_date_ce ext/intl for complete list) which use the function php_date_get_date_ce (so date_ce_date) Test script: --------------- var_dump(datefmt_create('fr_FR')->format(date_create_immutable('1970-01-01'))); $start = new DateTimeImmutable('last monday'); var_dump(new DatePeriod($start, DateInterval::createFromDateString('1 day'), $start->add(DateInterval::createFromDateString('5 days')))); Expected result: ---------------- string(39) "jeudi 1 janvier 1970 00:00:00 UTC+01:00" object(DatePeriod)#3 (6) { ... } Actual result: -------------- Warning: IntlDateFormatter::format(): datefmt_format: object must be an instance of DateTime in %s on %d Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments.' in %s:%d -- Edit bug report at https://bugs.php.net/bug.php?id=65683&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65683&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65683&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65683&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65683&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65683&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65683&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65683&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65683&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65683&r=support Expected behavior: https://bugs.php.net/fix.php?id=65683&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65683&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65683&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65683&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65683&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65683&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65683&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65683&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65683&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65683&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65683&r=mysqlcfg