Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50686 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3439 invoked from network); 29 Nov 2010 10:54:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2010 10:54:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:46553] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/80-31905-C4683FC4 for ; Mon, 29 Nov 2010 05:54:05 -0500 Received: by qwh6 with SMTP id 6so2034876qwh.29 for ; Mon, 29 Nov 2010 02:54:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type; bh=BOCV6lLKRsN+LOfF3StexziwLOzIXCk/bH5/qi0fzeY=; b=kcQs6M1aXgkjg4ZiNfr5W4AoOmsvuT0f17re5MuU71nNgtd4HKFYGOHHzzfWuLoBGP iSmUW9CfeJn8EALg/9Hh9V6VxU05DYeF+kLBSpVZfNRRsi/LRJeO79suvRQ0ULra+Po+ Lvrf2S0ufgd18iw0u5xmHy/S0IVZ7ViZEEDbE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; b=aR9KD7KFgVF0DEB3Ifmfr3i2qxyrprSTIjpxLIPQIfKmwo7kQJMJdh33qun+plSr3q K4BZDG0eVZkjXiH4DoRQm2M6r5UdY9V+B9COUtO9uqvgqLEmPjg2Ge4KE25HU4S0C/Nw dIY4QbsG2tu2YQLmB6uKktuZJoTfOe5TWWuoM= Received: by 10.229.184.13 with SMTP id ci13mr4702438qcb.253.1291028041752; Mon, 29 Nov 2010 02:54:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Mon, 29 Nov 2010 02:53:40 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: References: Date: Mon, 29 Nov 2010 10:53:40 +0000 Message-ID: To: president@basnetworks.net Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: rquadling@gmail.com (Richard Quadling) On 28 November 2010 23:18, wrote: > Link to the RFC: > http://wiki.php.net/rfc/propertygetsetsyntax > > Thanks, > Dennis Robinson I'd really like this feature to be part of PHP. I don't particularly like the use of what looks like a closure for the set/get. I used to code in Delphi and I always like the way in which their properties were defined. Essentially, the setter and getter are normal methods which are cherry picked for a property [1]. seconds / 3600; } protected function setHours() { $this->seconds = $value * 3600; } // This property is read-only public property Minutes read getMinutes; protected function getMinutes() { return $this->seconds / 60; } public property Milliseconds read getMilliseconds write setMilliseconds; public function getMilliseconds() { // This method is public return $this->seconds * 60; } protected function setMilliseconds() { // This method is protected $this->seconds = $value * 3600; } } For me, the advantage here is that I can independently the methods from the property. If I want to force a subclass to implement a setter/getter, then I can abstract the function in the base class. Sure, some may say that I should be using an interface. I disagree as I probably don't want the methods to be public. Protected or even private and/or final. The classic example is one of shapes. Every shape has a public $area property, but the value would be provided by an abstract protected TShape::getArea(); method. I can also finalise them, so, for example, a triangle shape could have a final protected getArea() method and all sub classes of triangles (scalene, isosceles, equilateral) would not implement their own getArea() method. The downside is certainly that the code is more verbose than I would guess many people would like. Regards, Richard. [1] http://www.delphibasics.co.uk/RTL.asp?Name=Property -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY