php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77064 Return type is contradictory
Submitted: 2018-10-26 06:22 UTC Modified: 2021-04-07 16:43 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: fabian dot picone at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS:
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 !
Your email address:
MUST BE VALID
Solve the problem:
47 - 4 = ?
Subscribe to this entry?

 
 [2018-10-26 06:22 UTC] fabian dot picone at gmail dot com
Description:
------------
---
From manual page: https://php.net/datetime.format
---

This doc has something that does not match.

The description of the method is "public string DateTimeImmutable::format ( string $format )".

But the return value is documented as "Returns the formatted date string on success or FALSE on failure." .

What is correct now, is the return a string or mixed?

My tests showed up to result in string, could not break it to receive bool.

So is this internally casted to string? Then you should adapt the return documentation.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-26 08:05 UTC] cmb@php.net
-Package: PHP Language Specification +Package: Date/time related
 [2018-10-26 08:05 UTC] cmb@php.net
::format() returns FALSE, if an argument has an incompatible
type[1], or if the DateTimeImmutable instance has not been
properly initialized[2].

Regarding the return type declaration, see
<http://news.php.net/php.doc/969386834>ff.

[1] <https://github.com/php/php-src/blob/php-7.3.0RC4/ext/date/php_date.c#L3170-L3172>
[2] <https://github.com/php/php-src/blob/php-7.3.0RC4/ext/date/php_date.c#L3174>
 [2021-04-07 16:43 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-04-07 16:43 UTC] cmb@php.net
This ticket is obsolete as of PHP 8.0.0, where the method no
longer returns false.  The documentation has already been updated.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC