php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Thank you for your help! If the status of the bug report you submitted changes, you will be notified. You may return here and check the status or update your report at any time.
The URL for your bug report is: https://bugs.php.net/bug.php?id=61483.
Bug #61483 When overriding DateTime::setTimezone() no type hint can be added.
Submitted: 2012-03-22 22:46 UTC Modified: 2015-07-02 16:26 UTC
Votes:18
Avg. Score:3.7 ± 1.0
Reproduced:15 of 15 (100.0%)
Same Version:11 (73.3%)
Same OS:6 (40.0%)
From: me at rouvenwessling dot de Assigned:
Status: Suspended Package: Date/time related
PHP Version: 5.4.0 OS: OS X 10.7
Private report: No CVE-ID: None
 [2012-03-22 22:46 UTC] me at rouvenwessling dot de
Description:
------------
I'm testing a snapshot of the current Joomla Platform on PHP 5.4 (unsung Zend 
Server CE) and just met an old friend. We're extending DateTime and would like to 
type hint the $timezone argument in setTimezone().

Sample code:
class JDate extends DateTime
{
    public function setTimezone(DateTimeZone $tz)
    {
        return parent::setTimezone($tz);
    }
}

This causes the following E_STRICT error:
Strict Standards: Declaration of JDate::setTimezone() should be compatible with 
DateTime::setTimezone($timezone)

The issue is not limited to PHP 5.4 but also occurs in older versions.

According to the documentation 
(http://php.net/manual/en/datetime.settimezone.php) the only valid value is a 
DateTimeZone object so it should be type hinted.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-10 14:49 UTC] aharvey@php.net
-Package: date_time +Package: Date/time related
 [2015-07-02 16:26 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2015-07-02 16:26 UTC] cmb@php.net
According to the discussion on internals@[1] I'm suspending this
ticket.

[1] <http://markmail.org/thread/usxbhcup2fmqyb2x>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 15:01:56 2024 UTC