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: 2021-09-09 10:10 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: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php-bugs at allenjb dot me dot uk
New email:
PHP Version: OS:

 

 [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>
 [2021-09-09 10:10 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-09-09 10:10 UTC] cmb@php.net
This has been fixed in the meantime:
<https://github.com/php/doc-en/commit/34188f8256bdc6f0e6e1965c2be94247997165b6>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC