Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50850 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81018 invoked from network); 5 Dec 2010 16:18:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Dec 2010 16:18:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=hermanradtke@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hermanradtke@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.45 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hermanradtke@gmail.com X-Host-Fingerprint: 209.85.215.45 mail-ew0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:58103] helo=mail-ew0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/C7-19822-A6BBBFC4 for ; Sun, 05 Dec 2010 11:18:51 -0500 Received: by ewy10 with SMTP id 10so6089299ewy.32 for ; Sun, 05 Dec 2010 08:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=sUwANhiL56ppatx0KL875RYYjiqFShKceJrH0B5PFHY=; b=Pbx6N6JIGmf1DhZKkb+YpifNPUj128x5O5HT2DYucEbu2mRM/ZaLCiC4YcAeRaZtbr fz+8ORAeIWlcJUTyCaLgSZDIw2eMRAbkjCu1rNf3NIv2Ab4TfRxeS0NUXx6j+1GZDWyf J2n5bC8DQMRy0kOZf7xFArmTxSU5Adns1OWxU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=bvdFVv14hGYXkNmhmgifvY9T/bcnz7jLf86ceTv2nkZICPNo2s1jkwgRfgeSmD8cQ0 TuSCen5cp1pbCpAL31vDO3ko+fv4byaT4WA6s3Ljkk2ismjSJm2hL+XbGj0Kg2e3SpYb I9EQbh81XoZiHsIoQSvufkV1NsH6/PWUt8hpg= MIME-Version: 1.0 Received: by 10.14.48.5 with SMTP id u5mr887246eeb.2.1291565926320; Sun, 05 Dec 2010 08:18:46 -0800 (PST) Received: by 10.14.47.143 with HTTP; Sun, 5 Dec 2010 08:18:46 -0800 (PST) In-Reply-To: <20101205104251.3e0310d5@benny-pc> References: <201012050255.54059.larry@garfieldtech.com> <20101205104251.3e0310d5@benny-pc> Date: Sun, 5 Dec 2010 08:18:46 -0800 Message-ID: To: Benjamin Eberlei Cc: Larry Garfield , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable From: hermanradtke@gmail.com (Herman Radtke) > You don't need to know if the instance is immutable or not, since the current DateTime instances also return themselves for method chaining. So any code that looks like: > > $d = $d->modify("+1 hour"); > > would work no matter mutable/immutable. This is still a bit strange though. But still any DateTimeValue would extend DateTime. So when you typehint > for a "DateTime", you still don't know if you get the one or the other and you would have to resort to the previous code example anyways. I do need to know if the instance is immutable. I have plenty of class methods that modify the DateTime instance and some don't return the DateTime instance back. If you want to make sure the object is immutable, you typehint for a DateTimeValue object. From an OO perspective, it makes much more sense to extend the class and add this functionality than to change the inner workings of the existing class. -- Herman Radtke hermanradtke@gmail.com | http://hermanradtke.com