Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63032 invoked from network); 7 Dec 2011 17:50:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2011 17:50:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.161.170 mail-gx0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:41021] helo=mail-gx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/61-54298-957AFDE4 for ; Wed, 07 Dec 2011 12:50:17 -0500 Received: by ggnv1 with SMTP id v1so990542ggn.29 for ; Wed, 07 Dec 2011 09:50:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.124.42 with SMTP id mf10mr3860273obb.5.1323280214111; Wed, 07 Dec 2011 09:50:14 -0800 (PST) Received: by 10.182.44.130 with HTTP; Wed, 7 Dec 2011 09:50:14 -0800 (PST) In-Reply-To: <34B6F836-CC50-4470-AD5F-C6F8C471FC65@gmail.com> References: <9570D903A3BECE4092E924C2985CE4853994C39F@MBX202.domain.local> <34B6F836-CC50-4470-AD5F-C6F8C471FC65@gmail.com> Date: Wed, 7 Dec 2011 12:50:14 -0500 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d0444eda119b52204b3842ffe Subject: Re: [PHP-DEV] Patch: getters/setters syntax Implementation From: rasmus@mindplay.dk (Rasmus Schultz) --f46d0444eda119b52204b3842ffe Content-Type: text/plain; charset=ISO-8859-1 > if we're attempting to get around __set/get, let's not replace them with more method implementations I don't understand this argument. Accessors are methods - making them look like something else won't change that fact. In C#, type-hinted properties with automatic getters/setters actually compile down to two method implementations, while implemented getters/settings do the same, substituting "value" for whatever is required to access the auto-implemented backing field. On Tue, Dec 6, 2011 at 9:26 AM, Will Fitch wrote: > > On Dec 6, 2011, at 8:58 AM, Rasmus Schultz wrote: > > > I agree with all of those points - the extra indentation looks messy, and > > yes, type hints are important. It does fit better with PHP in general. > > > > It would be nice to also have support for automatic backing fields in > > addition though - so something simple like this: > > > > class BlogPost > > { > > private $_author; > > > > public get author() > > { > > return $this->_author; > > } > > > > public set author(Person $value) > > { > > $this->_author = $value; > > } > > } > > I don't like this approach. All efforts (which I'm currently part of) to > implement type hinting return values will be compromised. If you want to > implement accessors, keep them within a syntax that makes sense. > Personally, I support the C# style as much as possible. Methods are > already overused for purposes they shouldn't be, so if we're attempting to > get around __set/get, let's not replace them with more method > implementations. > > --f46d0444eda119b52204b3842ffe--