Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64422 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26568 invoked from network); 24 Dec 2012 11:51:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Dec 2012 11:51:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:40146] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/D8-32426-4D148D05 for ; Mon, 24 Dec 2012 06:51:50 -0500 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id 67B23DE13D; Mon, 24 Dec 2012 11:51:45 +0000 (GMT) Date: Mon, 24 Dec 2012 11:51:45 +0000 (GMT) X-X-Sender: derick@whisky.home.derickrethans.nl To: Adam Harvey cc: Lars Strojny , "internals@lists.php.net" In-Reply-To: Message-ID: References: <50C63A7C.8090705@gmail.com> <4DBD0EA5-C45B-4C12-BFE9-E263B255B2C3@strojny.net> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] DateTime improvement From: derick@php.net (Derick Rethans) On Tue, 18 Dec 2012, Adam Harvey wrote: > On 18 December 2012 04:52, Lars Strojny 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