Doc #75083 [NEW]: Undocumented: IntlDateFormatter->format also accepts DateTimeInterface

From: Date: Thu, 17 Aug 2017 09:01:45 +0000
Subject: Doc #75083 [NEW]: Undocumented: IntlDateFormatter->format also accepts DateTimeInterface
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14896@lists.php.net to get a copy of this message
From: zimzat at zimzat dot com Operating system: PHP version: 7.1.8 Package: Documentation problem Bug Type: Documentation Problem Bug description:Undocumented: IntlDateFormatter->format also accepts DateTimeInterface Description: ------------ --- From manual page: http://www.php.net/intldateformatter.format --- As of PHP 7.1.5 IntlDateFormatter->format() accepts any DateTimeInterface object, not just DateTime. Test script: --------------- <?php $datetime = new DateTimeImmutable('2017-07-13'); $prettyDateFormatter = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Chicago', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd'); $prettyDateFormatter->setPattern('MMM d yyyy'); echo 'Timestamp: ', $prettyDateFormatter->format($datetime->getTimestamp()) ?: $prettyDateFormatter->getErrorMessage(), "\n"; echo 'DateTime: ', $prettyDateFormatter->format(new DateTime('2017-07-13')) ?: $prettyDateFormatter->getErrorMessage(), "\n"; echo 'DateTimeImmutable: ', $prettyDateFormatter->format($datetime) ?: $prettyDateFormatter->getErrorMessage(), "\n"; Expected result: ---------------- PHP >= 7.1.5: Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: Jul 12 2017 PHP < 7.1.5: Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR PHP >= 7.1.5 has changed signature to: datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR Actual result: -------------- https://3v4l.org/0ErGG Output for hhvm-3.18.4 - 3.21.0, 7.1.5 - 7.2.0beta2 Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: Jul 12 2017 Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.4 Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR -- Edit bug report at https://bugs.php.net/bug.php?id=75083&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75083&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75083&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75083&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75083&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75083&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75083&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75083&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75083&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75083&r=support Expected behavior: https://bugs.php.net/fix.php?id=75083&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75083&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75083&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75083&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75083&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75083&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75083&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75083&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75083&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75083&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75083&r=mysqlcfg

« previous php.doc.bugs (#14896) next »