php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80279 DateTime::format / date_format: Mismatch between signature and "return values"
Submitted: 2020-10-23 20:27 UTC Modified: 2020-10-23 21:27 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: php-bugs at allenjb dot me dot uk Assigned:
Status: Open Package: Date/time related
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
26 + 24 = ?
Subscribe to this entry?

 
 [2020-10-23 20:27 UTC] php-bugs at allenjb dot me dot uk
Description:
------------
---
From manual page: https://php.net/datetime.format
---

The signature says this function always returns string. The documentation also mentions (and I've confirmed) that unrecognized values (eg 'f') are returned 'as-is'.

The Return Values section however says the function may "return FALSE on failure".

I can't think of any circumstances in which this function would fail. I've glanced at the php-src code and think it probably should never return false, but would like someone more familiar with the code to confirm.

If the function may return FALSE, in addition to fixing the signature return type, could the Return Values section be expanded to give an example of when this function may fail.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-23 21:27 UTC] cmb@php.net
-Package: Documentation problem +Package: Date/time related
 [2020-10-23 21:27 UTC] cmb@php.net
The date_format() function and its method aliases return false
only in case of unsupported argument types[1], and only prior to
PHP 8.0.0.  Note that unsupported argument types are documented to
yield *undefined* return values[2], so this may not even something
we want to document explicitly for each function, although that
usually changes with PHP 8, where unsupported argument types by
convention should result in a TypeError.

[1] <<https://3v4l.org/2jto0>>
[2] <https://www.php.net/manual/en/functions.internal.php>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jun 25 03:01:23 2021 UTC