php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55407 Impossible to prototype DateTime::createFromFormat
Submitted: 2011-08-11 20:10 UTC Modified: 2017-01-17 15:36 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: landeholm at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.6 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: landeholm at gmail dot com
New email:
PHP Version: OS:

 

 [2011-08-11 20:10 UTC] landeholm at gmail dot com
Description:
------------
Hello,

I'm creating an extended DateTime for my framework. The test script below gives "E_STRICT: Declaration of melt\core\DateTime::createFromFormat() should be compatible with that of DateTime::createFromFormat()" even though it's declared exactly as documented.

Also removing all the arguments what so ever doesn't make this problem go away so it's impossible to prototype DateTime::createFromFormat without getting this error.


Test script:
---------------
<?php namespace melt\core;

class DateTime extends \DateTime {
    public static function createFromFormat($format, $time, DateTimeZone $timezone = null) {
        return new DateTime(parent::createFromFormat($format, $time, $timezone));
    }
}


Expected result:
----------------
The class being declared as it should.

Actual result:
--------------
E_STRICT: Declaration of melt\core\DateTime::createFromFormat() should be compatible with that of DateTime::createFromFormat()

Patches

fix (last revision 2011-08-11 23:36 UTC by felipe@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-11 20:52 UTC] landeholm at gmail dot com
Here is the related commit (adding the class above):

https://github.com/melt/melt/commit/4c08b7e65ad9a3dbf165768b0fa55a99862cf910

Here is my temporary workaround:

https://github.com/melt/melt/commit/25c295fd86a52f84f18777814d7efaa8cf372fd6
 [2011-08-11 23:14 UTC] pierrick@php.net
-Package: Scripting Engine problem +Package: Date/time related -Assigned To: +Assigned To: derick
 [2011-08-11 23:14 UTC] pierrick@php.net
The method signature is in fact :

createFromFormat($format, $time, $timezone = null);

Assign this to derick to confirm that we need to change the documentation to 
reflect the real method signature (or the opposit ?)
 [2011-08-11 23:36 UTC] felipe@php.net
The following patch has been added/updated:

Patch Name: fix
Revision:   1313105776
URL:        https://bugs.php.net/patch-display.php?bug=55407&patch=fix&revision=1313105776
 [2015-01-20 21:44 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8e19705a93d785cd1ff8ba3a69699b00169fea47
Log: Fixed bug #55407 (Impossible to prototype DateTime::createFromFormat)
 [2015-01-20 21:44 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2015-02-04 16:41 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f51b73c833ef88761780487da610d7e94e68ad47
Log: Revert &quot;Fixed bug #55407 (Impossible to prototype DateTime::createFromFormat)&quot;
 [2015-02-04 16:41 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f51b73c833ef88761780487da610d7e94e68ad47
Log: Revert &quot;Fixed bug #55407 (Impossible to prototype DateTime::createFromFormat)&quot;
 [2015-02-04 16:42 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f51b73c833ef88761780487da610d7e94e68ad47
Log: Revert &quot;Fixed bug #55407 (Impossible to prototype DateTime::createFromFormat)&quot;
 [2015-02-04 16:50 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f51b73c833ef88761780487da610d7e94e68ad47
Log: Revert &quot;Fixed bug #55407 (Impossible to prototype DateTime::createFromFormat)&quot;
 [2015-02-05 09:02 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f457487e163502480f74a70bf9272fd003fc1919
Log: Revert &quot;Fixed bug #55407 (Impossible to prototype DateTime::createFromFormat)&quot;
 [2015-06-12 16:00 UTC] ab@php.net
-Status: Closed +Status: Re-Opened
 [2015-06-12 16:00 UTC] ab@php.net
Reopening as the patch was reverted in PHP 7.0 because of massive user code breach. See discussion on https://github.com/php/php-src/commit/8e19705a93d785cd1ff8ba3a69699b00169fea47 .

Thanks.
 [2017-01-17 15:36 UTC] heiglandreas@php.net
-Status: Re-Opened +Status: Not a bug
 [2017-01-17 15:36 UTC] heiglandreas@php.net
Perhaps I'm not really getting what the issue is about: But it was possible since 5.3 to extend createFromFormat() without issue[1]. So prototyping DateTime::createFromFormat is possible without getting the error.

I'm therefore closing this

[1] https://3v4l.org/v5kXX
 [2017-06-02 22:11 UTC] nikic@php.net
Automatic comment on behalf of me@kelunik.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f2e7cdb8b7a68315c902e9346f476e72370e30e1
Log: Fix bug #55407
 [2017-06-02 22:11 UTC] nikic@php.net
-Status: Not a bug +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 30 11:01:30 2025 UTC