Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63708 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52120 invoked from network); 29 Oct 2012 22:17:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Oct 2012 22:17:49 -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.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:56982] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/02-31721-C800F805 for ; Mon, 29 Oct 2012 17:17:49 -0500 Received: by mail-lb0-f170.google.com with SMTP id gm13so3724360lbb.29 for ; Mon, 29 Oct 2012 15:17:45 -0700 (PDT) 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=wQbXp4a1pTPepa+MhPYo8Uz2iCvatYxTULrwryHm40Q=; b=ydcqEy9ncAmdPU472VMlEUFVKGHqdytD7lAS7/JaYfjyxOcSlhffqTnPeFcPt0Zxc2 2hFYDAjfdNPmoKkYr6dXIEoXd5sfo1IleyJytHOd/qZveATofPy1kMzKNxBSn1Z5RSua iu+9mLdYoXP7MLm2JLflXo73dg+ryBZ7tqV3CwfZA9JTg+yVToAlsb8ZpV6fDL7HariX TEQWmhMIMa5e6rMWDQZfpeu+MdfhYAAONbMqfc8Jfnp0m5wfdrZttkK+J4VPumcaidLQ 63e7ITBKKO423OJOK8Gi/yKcwp8z1wNZIB+Xt4OmwTbRIM5kuwwMpADOHjL6EZPaiY5z UaXg== MIME-Version: 1.0 Received: by 10.112.100.40 with SMTP id ev8mr12521442lbb.43.1351549065058; Mon, 29 Oct 2012 15:17:45 -0700 (PDT) Received: by 10.112.83.100 with HTTP; Mon, 29 Oct 2012 15:17:44 -0700 (PDT) In-Reply-To: <508EFB76.4080604@sugarcrm.com> References: <508A67E6.2000405@zerocue.com> <508A9AC9.50200@sugarcrm.com> <508AF3E7.7020004@sugarcrm.com> <508B1EA2.8060203@sugarcrm.com> <508C249D.1000309@zerocue.com> <508C43ED.9000209@sugarcrm.com> <508C80C6.9000008@zerocue.com> <508CD916.1070509@sugarcrm.com> <508D5462.4070503@zerocue.com> <508EFB76.4080604@sugarcrm.com> Date: Mon, 29 Oct 2012 23:17:44 +0100 Message-ID: To: Stas Malyshev Cc: Clint Priest , PHP Developers Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Property Accessors v1.2 : Internal Accessor Method Visibility / Callability From: nikita.ppv@gmail.com (Nikita Popov) On Mon, Oct 29, 2012 at 10:56 PM, Stas Malyshev wrote: > Hi! > >> If I got it right now, what Stas wants is that we introduce __getFoo >> and __setFoo methods that will be called whenever an undefined ->foo >> property is accessed and that the "normal" property accessors syntax >> is made nothing more than a fancy notation for this. > > Yes, pretty much, though "undefined" bit is not required I think. Not > 100% convinced on this, but from user reqs it sounds like they want to > drop the undefined bit. > >> A) Inheritance: >> ========== >> >> class A { >> public $foo; >> } >> >> class B extends A { >> public $foo { get() { ... } set($value) { ... } } >> } >> >> => With the accessors syntax there is an expectation that the accessor >> declaration will override the previous plain property. At least that's >> what I would expect and that's what the code looks like > > That's why I'm not liking the "undefined" bit. > >> => With the magic syntax there is the expectation that the $foo >> property will not be overridden. Rather the magic functions are >> expected to do nothing, because the property already exists. > > Err, I'm not sure why that would be the expectation. __get is for > undefined properties, since, well, it doesn't have any property name > attached, so it can't really be for defined properties :) However, > __getFoo (with whatever variations the bikeshedding committee will end > up with :) has property name attached to it, so requiring property be > undefined is not, well, required. Here we need to think which way is > better, and I currently tend to think accessor priority is better. Stas, you seem to have missed the point behind my mail. This wasn't about what the exact details of the implementation will be, the message was that the semantics of a dedicated accessors syntax and the semantics of a magic implementation can not match. E.g. assuming that magic accessors take priority over properties as you want it this time I can just turn the examples around: class A { public $foo { get() { ... } set($value) { ... } } } class B extends A { public $foo; } => Here I would expect that public $foo from class B overrides public $foo from class A. With __ magic on the other hand: class A { public function __getFoo() { ... } public function __setFoo($value) { ... } } class B extends A { public $foo; } => Here (according to your new overriding priority) the property in class B would not override, rather the magic from A stays intact. Basically any kind of interaction between properties and accessor properties will be broken and inherently so, simply because magic methods are not real properties (quite obviously...). Nikita