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
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 15:01:34 2020 UTC