Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63730 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29064 invoked from network); 31 Oct 2012 12:29:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Oct 2012 12:29:51 -0000 Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=brianofish@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: brianofish@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ea0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:37625] helo=mail-ea0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/B0-24645-BB911905 for ; Wed, 31 Oct 2012 07:29:50 -0500 Received: by mail-ea0-f170.google.com with SMTP id a13so572304eaa.29 for ; Wed, 31 Oct 2012 05:29:44 -0700 (PDT) Received: by 10.14.200.194 with SMTP id z42mr76726856een.13.1351686584210; Wed, 31 Oct 2012 05:29:44 -0700 (PDT) Received: from rofl.localnet ([213.135.15.139]) by mx.google.com with ESMTPS id e7sm7677914eep.1.2012.10.31.05.29.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 05:29:43 -0700 (PDT) To: internals@lists.php.net Cc: Nikita Popov , Stas Malyshev , Clint Priest Date: Wed, 31 Oct 2012 13:29:15 +0100 Message-ID: <7818029.ra9XhW6Vax@rofl> User-Agent: KMail/4.9.2 (Linux/3.6.3-k10-bof; KDE/4.9.2; x86_64; ; ) In-Reply-To: References: <508A67E6.2000405@zerocue.com> <508EFB76.4080604@sugarcrm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [PHP-DEV] [RFC] Property Accessors v1.2 : Internal Accessor Method Visibility / Callability From: php@bof.de (Patrick Schaaf) Nikita, your examples convinced me that a strict "accessor methods as specialized __get/__set semantics" approach is undesirable. To recapitulate your two examples: Example 1: class A { public $foo; } class B extends A { public $foo { get() { ...} } } Example 2: class A { public $foo { get() { ...} } } class B extends A { public $foo; } One would expect that in both cases, instances of 'class B' would have a $foo acting as declared in class B, shadowing the declaration from class A. I think that the issue might be solved by an additional, not-yet-discussed and very general extension, which is something I missed being able to do from time to time: the possibility to declare a method (or property) in some class to be explicitly NOT inherited. Syntactically, something like class C { public $bar; public function twiddle(); } class D extends C { no public $bar; no public function twiddle(); # might be followed by a different twiddle(), or $bar, implementation } The use case I have in mind, coming from the method side, is a subclass that wants to use __call() for delegation AND needs to delegate to one or more methods that are ordinarily plainly implemented in the base class. What this feature would bring to the current discussion, is this possible solution to your dilemma: 1) when a class declares a plain property "public $foo", automatically apply "no function __getfoo(); no function setfoo();" (leaving out isset/unset for clarity) 2) conversely, when a class declares "public $foo { get() {...}}", or even just declares one of the magic methods directly like "public function __getfoo() {}" - automatically prepend / pretend a "no public $foo;" cancelling a superclass property. best regards Patrick