Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65884 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62178 invoked from network); 15 Feb 2013 20:49:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2013 20:49:39 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.54 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.54 mail-oa0-f54.google.com Received: from [209.85.219.54] ([209.85.219.54:50940] helo=mail-oa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/58-06160-36F9E115 for ; Fri, 15 Feb 2013 15:49:39 -0500 Received: by mail-oa0-f54.google.com with SMTP id n12so4164423oag.41 for ; Fri, 15 Feb 2013 12:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=Gtl7w6JUDso0OK5gzfX2rHEeW/91WqVI+keWP0pPzyI=; b=hlTllfieWiVIl4MC23v4BjxY7kWVdnIZTacW1a+vyoihrLkf5boeJRoY2n3k3fEx+v lqhSbsGYXrIVImylaP2P370NpIKIqWHBuxJ0nrANAsIRdAk1wbHuMGaS01SYdXii7puO MJ4Ew9n8eqNNK0ks/2FQj5obsA9G/bzvYyswK4+6NzTVEOIFKqFP/vMQcwBz893pJBfe saOCuUj/T7suVhqVR1UP9fZvPUTRwxVU93zFq7gAAx3WL0TxF5gcFBKN2NRuSDXnftb0 MjeIjH3yYF8nq80+66N4gzQkt42+uHMcfICDyMgqRfj1DdjHqwYvqnZR4vhTvIbmXLxz 4Rvw== MIME-Version: 1.0 X-Received: by 10.60.172.40 with SMTP id az8mr2745031oec.5.1360961376931; Fri, 15 Feb 2013 12:49:36 -0800 (PST) Received: by 10.182.49.136 with HTTP; Fri, 15 Feb 2013 12:49:36 -0800 (PST) Date: Fri, 15 Feb 2013 21:49:36 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=bcaec55242b26ccf5204d5c98384 Subject: Questions regarding DateTimeImmutable From: nikita.ppv@gmail.com (Nikita Popov) --bcaec55242b26ccf5204d5c98384 Content-Type: text/plain; charset=ISO-8859-1 Hi internals, for PHP 5.5 a new DateTimeImmutable class was introduced, which is a variant of DateTime, which has methods working on a clone of the original object. There was no RFC on this and some of the design decisions are a bit uncleared to me, so I figured I'd write a mail: a) The DateTimeImmutable class extends the DateTime class. Why was this done this way? Both classes are incompatible (as in the inheritance violates LSP). E.g. if you hint against DateTime, then passing in DateTimeImmutable will not work (as the behavior is different). The same also applies the other way around (DateTime extending DateTimeImmutable). Imho a mutable and an immutable variant of a class can't reasonably extend from one another, so I'm not sure why this was done. b) The DateTimeImmutable class is (method-wise) an exact copy of DateTime. This makes for some rather weird method names for an immutable object. E.g. there is DateTimeImmutable::modify, which to me seems quite contradictory. There are also a lot of methods of the DateTimeImmutable::setTime form, which also seems rather odd and confusing (how can I set something on an immutable object?) The DateTimeImmutable class was added to fix design issues with DateTime, but the way it was implemented I think it just replaced one evil with another one. Could we maybe reconsider this? Nikita --bcaec55242b26ccf5204d5c98384--