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: 2018-08-15 16:33 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: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: master-Git-2015-05-03 (Git) 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:
17 - 15 = ?
Subscribe to this entry?

 
 [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
 [2018-08-15 16:33 UTC] cmb@php.net
-Status: Assigned +Status: Closed -Assigned To: derick +Assigned To: cmb
 [2018-08-15 16:33 UTC] cmb@php.net
This issue has already been fixed commit b148c50[1].

[1] <http://git.php.net/?p=php-src.git;a=commit;h=b148c50>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC