Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64433 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53900 invoked from network); 26 Dec 2012 00:12:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Dec 2012 00:12:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.143 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.143 smtp143.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.143] ([67.192.241.143:45876] helo=smtp143.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/A0-47159-CE04AD05 for ; Tue, 25 Dec 2012 19:12:28 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp4.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id A53CB3A0235; Tue, 25 Dec 2012 19:12:25 -0500 (EST) X-Virus-Scanned: OK Received: by smtp4.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 19FB43A0228; Tue, 25 Dec 2012 19:12:24 -0500 (EST) Message-ID: <50DA40E8.9010702@sugarcrm.com> Date: Tue, 25 Dec 2012 16:12:24 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Derick Rethans CC: "internals@lists.php.net" References: <50C63A7C.8090705@gmail.com> <4DBD0EA5-C45B-4C12-BFE9-E263B255B2C3@strojny.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] DateTime improvement From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > 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 Actually, I would claim it doesn't make "perfect sense", since it would mean DateTime would violate DateTimeImmutable's contract of being, well, immutable. Strictly speaking, they can not either extend from other one, since they have APIs which are not subset of each other. However, doing it strictly OO would mean getting into Java-esque web of interfaces, abstract classes and implementation classes, which would suck. As for established practice, everybody expects DateTime, so IMHO we should leave DateTime as base class even though it's not strictly OO-pure. Speaking of derived classes, though, I wonder how hard it would be to make DateTime factory methods - such as createFromFormat - to be able to produce instance of child class? Now if you want to extend DateTime and use those, you need to implement some weird things like: $dt = DateTime::createFromFormat($format, $time); $mydt = new MyDateTime("@".$dt->getTimestamp()); Maybe there's a better way but I'm not sure what it is. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227