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
 [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

Pull Requests

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: Sun Dec 01 17:01:32 2024 UTC