Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56762 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59576 invoked from network); 4 Dec 2011 14:46:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2011 14:46:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=christian.kaps@mohiva.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=christian.kaps@mohiva.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mohiva.com from 80.67.31.95 cause and error) X-PHP-List-Original-Sender: christian.kaps@mohiva.com X-Host-Fingerprint: 80.67.31.95 smtprelay06.ispgateway.de Linux 2.6 Received: from [80.67.31.95] ([80.67.31.95:55747] helo=smtprelay06.ispgateway.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/58-13454-9D78BDE4 for ; Sun, 04 Dec 2011 09:46:50 -0500 Received: from [87.181.62.25] (helo=[192.168.0.3]) by smtprelay06.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1RXDL4-0004GG-NI for internals@lists.php.net; Sun, 04 Dec 2011 15:46:47 +0100 Message-ID: <4EDB87D6.1080402@mohiva.com> Date: Sun, 04 Dec 2011 15:46:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111120 Thunderbird/8.0 MIME-Version: 1.0 To: internals@lists.php.net References: <9570D903A3BECE4092E924C2985CE485399460CA@MBX201.domain.local> <9570D903A3BECE4092E924C2985CE48539946A34@MBX201.domain.local> In-Reply-To: <9570D903A3BECE4092E924C2985CE48539946A34@MBX201.domain.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Df-Sender: Y2hyaXN0aWFuLmthcHNAbW9oaXZhLmNvbQ== Subject: Re: [PHP-DEV] Patch: getters/setters syntax Implementation From: christian.kaps@mohiva.com (Christian Kaps) Hi, why not creating a more function like syntax for this feature. In my opinion it looks more cleaner particularly when using more than one line in a setter or getter. The other thing is that you can use type hints with this syntax. As example: class Foo { private $bar; public set bar(Bar $bar) { $this->bar = $bar; } public get bar() { return $this->bar; } } Christian On 04.12.2011 15:09, Clint M Priest wrote: > Updated patch w/o white-space: http://www.clintpriest.com/patches/accessors_v1.patch > > In the end it is a relatively simple patch. The new syntax effectively creates internal functions on the object and the system looks for those functions and calls them at the appropriate time. > > Example: > class z { > public $Hours { > public get { return $this->_Hours; } > protected set { $this->_Hours = $value; } > } > } > > Defines: > $o->__getHours(); > $o->__setHours($value); > > Standard __get()/__set() functionality checks for the more specifically defined function name and calls them. I thought this would make the most sense since it would allow us to leverage the existing inheritance functionality. This comes out with respect to interfaces and traits in that only errors had to be changed (for clarity) on interfaces and no changes to traits were necessary to support the new functionality. > > For the automatic get/set functionality, I essentially built the function body myself within zend_do_end_accessor_declaration(). One point of contention here is that internally it defines a __$Hours property which would be accessible from various points. I believe the standard C# get/set does not allow any access to the underlying data storage. In order to accomplish that there would need to be some non-standard storage or a super-private level or something. I did not explore that possibility as of yet. > > I did add a couple of convenience functions that may already be available in some other form I was not aware of, such as strcatalloc or MAKE_ZNODE(). > > --Clint > > -----Original Message----- > From: Pierre Joye [mailto:pierre.php@gmail.com] > Sent: Sunday, December 04, 2011 4:50 AM > To: Clint M Priest > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] Patch: getters/setters syntax Implementation > > hi Clint! > > > Thanks for your work so far! > > On Sun, Dec 4, 2011 at 1:33 AM, Clint M Priest wrote: > >> What are the next steps to get this added to some future release? > Let discuss the implementation and how it works, then you can move to the voting phase. There is no need to hurry as the next release where this patch could go in is next year. > > Cheers, > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org >