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: 2018-10-26 08:05 UTC
From: fabian dot picone at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fabian dot picone at gmail dot com
New email:
PHP Version: OS:

 

 [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>
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Dec 19 03:01:26 2018 UTC