? Failure

User tests: Successful: Unsuccessful:

avatar izharaazmi
izharaazmi
22 Oct 2015

Override add() and sub() functions to provide appropriate chaining that currently breaks due to return type of the parent class DateTime.

avatar izharaazmi izharaazmi - open - 22 Oct 2015
avatar izharaazmi izharaazmi - change - 22 Oct 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 22 Oct 2015
Labels Added: ?
avatar izharaazmi
izharaazmi - comment - 22 Oct 2015

Test Instructions:

$date = new JDate;
$di   = new DateInterval('P2D');
echo $date->add($di)->toSql();

This would fail without this patch, because toSql function is not a member of DateTime class, it is defined in JDate.

avatar mbabker
mbabker - comment - 22 Oct 2015

I'm confused though. If DateTime::add() is returning an instance of $this (which http://php.net/manual/en/datetime.add.php implies is happening) then it should be fine, just the IDE hinting would be a bit messed up. If it's returning a clone of the object or some other mutation, then that needs to be accounted for in the method overrides and not just extend the method to change the doc blocks for IDE convenience.

avatar izharaazmi
izharaazmi - comment - 22 Oct 2015

Ok, I understand. Can you please suggest something better for this case,
the IDE hinting trouble?

avatar izharaazmi
izharaazmi - comment - 23 Oct 2015

Since this issue is concerned with IDE hinting only, I came up with other way around (doc block hints) which does not require an override.
This now resides at #8128

avatar izharaazmi izharaazmi - change - 23 Oct 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-10-23 06:58:56
Closed_By izharaazmi
avatar izharaazmi izharaazmi - close - 23 Oct 2015

Add a Comment

Login with GitHub to post a comment