Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64832 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45899 invoked from network); 10 Jan 2013 23:15:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2013 23:15:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.173 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.217.173 mail-lb0-f173.google.com Received: from [209.85.217.173] ([209.85.217.173:59039] helo=mail-lb0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/90-02684-89B4FE05 for ; Thu, 10 Jan 2013 18:15:37 -0500 Received: by mail-lb0-f173.google.com with SMTP id c1so897238lbg.18 for ; Thu, 10 Jan 2013 15:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=BCWbzXN3ssPj9ojhZkjhSjksFZRhA4NuIPI6iWypbWo=; b=yQzlH9T7pu31ii8btgOurAuziKu7jHhC3+T8D5iATlDTMV2B9c71ww+dP2lX8OJyg7 wstoweqYlccFQO74qgwvraaynh6xEWY2FUx8MnsW9CNN9UCOS8Lh0wnIzv2/O6+cBye4 bwrhDxcy0PpnySVAg1x90Ude99KWdp1nCLOPh2KSGYI6pCZozAfG37UZVjW330GgYwrB THHhDjnyEe6z06hhzeqNZBqV57z2yvJn4kDuobKlb+ni4jXYIl6FVLO8PJHpswb0wgKx PgtdCS0sB6hli5A60+d4GcqQcCHLf8ferYyM1EcUFI5GhrJMqT4dq7RnVDXFIyfyL5Br 7i2A== MIME-Version: 1.0 Received: by 10.152.147.103 with SMTP id tj7mr71669055lab.54.1357859733205; Thu, 10 Jan 2013 15:15:33 -0800 (PST) Received: by 10.112.4.168 with HTTP; Thu, 10 Jan 2013 15:15:33 -0800 (PST) In-Reply-To: <50E79D16.1090905@zerocue.com> References: <50E41BB6.4030901@zerocue.com> <50E648BE.2060005@zerocue.com> <50E6822D.9060807@sugarcrm.com> <71B3F435-4289-473B-B4D7-EB2DB5F888A9@zerocue.com> <7213E637-26A2-4F44-82DE-297E751726CD@zerocue.com> <50E6F501.4090806@zerocue.com> <50E75658.6050006@sugarcrm.com> <50E79D16.1090905@zerocue.com> Date: Fri, 11 Jan 2013 00:15:33 +0100 Message-ID: To: Clint Priest Cc: Stas Malyshev , PHP Developers Mailing List Content-Type: multipart/alternative; boundary=e89a8f234d2b0d72e604d2f75b34 Subject: Re: [PHP-DEV] [PHP-RFC] Property Accessors 1.2 : parent::$foo Issue From: nikita.ppv@gmail.com (Nikita Popov) --e89a8f234d2b0d72e604d2f75b34 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jan 5, 2013 at 4:25 AM, Clint Priest wrote: > Agreed. Some people may actually be using $parent as a variable name, not > difficult to imagine. > > So far parent->foo seems to be the answer. > > -Clint > My thoughts on the parent situations, as I'm not yet satisfied with the current solution. 1) I tried to understand how the engine currently compiles and executes object property fetches. I found it to be incredibly complex and I certainly don't have the abilities to port this for statics. As such the "parent::$foo" syntax is dead unless someone else is going to do the necessary engine changes. 2) I think the "parent->foo" syntax is nice in concept, but I think that it's an absolute no-go as it doesn't fit in with the rest of PHP (and would still require some engine changes those complexity I can't really estimate). The parent->foo syntax is some off mix between parent::$foo (which makes sense) and $parent->foo (which also makes sense). parent->foo combines it in an odd way that doesn't look like PHP and adds yet another new syntax for something that's going to be a rare case anyway. 3) My suggestion is to avoid the engine and syntax related issues of parent property access by putting this as a function in the standard library instead. What I'm thinking about is a function like get_parent_property() which returns the ReflectionProperty for it. Then you could do something like this: public $foo { get { return 'parent is: ' . get_parent_property('foo')->getValue(); } set($val) { get_parent_property('foo')->setValue($val . ' something'); } } I know that this is not an optimal solution, but I would much prefer this over some new syntax like "parent->foo". Once (if) static properties have better engine support we can switch to the cleaner parent::$foo way. But until then I think that this is a good compromise, especially considering that accessing the parent property shouldn't be a very common operation, so it's okay if it's a bit more verbose. This is just a rough idea of what I'd do. The exact way this would work still needs further discussion. E.g. one could make passing the property name optional and assume the current property as default. Or one could not return a ReflectionProperty and instead provide two functions get_parent_property and set_parent_property (what about isset and unset in that case though?) So, what do you think about this? Nikita --e89a8f234d2b0d72e604d2f75b34--