On Tue, 18 Dec 2012, Adam Harvey wrote:
> On 18 December 2012 04:52, Lars Strojny <[email protected]> wrote:
> > I would go with DateTimeValue or DateTimeImmutable as well.
>
> +1. I'd prefer DateTimeImmutable personally because it describes what
> it is better than the other options.
That's what I have changed it to now[1]. I've also modified
DatePeriod[2] to allow for immutable objects to be returned. Right now, it will return
DateTimeImmutable objects if the start date object is also
DateTimeImmutable. In case it is a DateTime object, or an ISO8601
date-string, the returned objects are of the DateTime class[3].
Sebastian had responded off-list that he'd rather have DateTime inherit
from DateTimeImmutable, instead of the current variant where
DateTimeImmutable inherits DateTime. While this OO-design principle wise
makes perfect sense, practically it is not as handy. I've played with a
patch to implement it and it works, but lots of messages are now "blah
blah wants a DateTimeImmutable class" instead of "blah blah wants a
DateTime class". Although I think having a DateTimeImmutable is a good
thing, I don't want to confuse too many people (novices!) with weird OO
terms. And in most cases, people don't care whether DateTime is
immutable or not. Besides that, it also made the change and the code
more complex and duplicated. Because of this, I didn't pursue this patch
any further.
[1] http://git.php.net/?p=php-src.git;a=commit;h=6b48ae4580a0e97f7df4f1733eca345755110b96
[2] http://git.php.net/?p=php-src.git;a=commit;h=042ddf371e84fbb7ba1326e7bd45888e63fb30ef
[3] http://git.php.net/?p=php-src.git;a=blob;f=ext/date/tests/date_period-immutable.phpt;h=0ec4b4a13025b9494833aa90fa64be7d95f8a261;hb=042ddf371e84fbb7ba1326e7bd45888e63fb30ef
cheers,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine