php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69565 Fix createFromFormat prototype
Submitted: 2015-05-03 19:58 UTC Modified: 2015-05-03 19:58 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: rasmus@php.net Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: master-Git-2015-05-03 (Git) 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: rasmus@php.net
New email:
PHP Version: OS:

 

 [2015-05-03 19:58 UTC] rasmus@php.net
Description:
------------
There is currently no way to portably write this:

class myTime extends DateTime {
  public static function createFromFormat($format, $time, DateTimeZone $tz = null) { }
}

such that it doesn't generate a warning in PHP 5 and or PHP 7. Without "DateTimeZone $tz" it gives:

Warning: Declaration of myTime::createFromFormat() should be compatible with DateTime::createFromFormat($format, $time, DateTimeZone $object = NULL) in /home/rasmus/cc on line 0

in PHP 7 and with it we get:

Strict Standards: Declaration of myTime::createFromFormat() should be compatible with DateTime::createFromFormat($format, $time, $object = NULL) in /home/rasmus/cc on line 4

in PHP 5.6. We need a sensible upgrade path here which is probably to just simply drop the DateTimeZone restriction from the prototype.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-03 19:58 UTC] rasmus@php.net
-Assigned To: +Assigned To: derick
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC