Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50694 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43407 invoked from network); 29 Nov 2010 14:55:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2010 14:55:56 -0000 X-Host-Fingerprint: 65.19.76.48 unknown Date: Mon, 29 Nov 2010 09:55:56 -0500 Received: from [65.19.76.48] ([65.19.76.48:10383] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/20-42097-BFEB3FC4 for ; Mon, 29 Nov 2010 09:55:56 -0500 Message-ID: <42.20.42097.BFEB3FC4@pb1.pair.com> To: internals@lists.php.net References: <003601cb8fd0$f6494e80$e2dbeb80$@com> <4CF3B855.5010406@sugarcrm.com> User-Agent: slrn/pre1.0.0-18 (Linux) X-Posted-By: 65.19.76.48 Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: weierophinney@php.net (Matthew Weier O'Phinney) On 2010-11-29, Stas Malyshev wrote: > > Nice RFC, just an idea for an alternative syntax (added to the RFC as #2): > > > > property Hours { > > get { return $this->seconds / 3600; } > > set { $this->seconds = $value * 3600; } // The variable $value holds > > the incoming value to be "set" > > } > > > > class TimePeriod > > { > > private $seconds; > > > > public [Hours] $hours1; > > public {use Hours;} $hours2; > > } > > If you change "property" to "class" or "trait" and "get" to "__get" you > need almost no new syntax :) Not really. With __get() and __set(), it's entirely likely that the class into which the trait is mixed in might override this already -- and not take into account the properties. That would be quite a brittle solution. -- Matthew Weier O'Phinney Project Lead | matthew@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc