Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65128 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37319 invoked from network); 23 Jan 2013 21:20:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2013 21:20:20 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.46 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.219.46 mail-oa0-f46.google.com Received: from [209.85.219.46] ([209.85.219.46:56068] helo=mail-oa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/15-30997-41450015 for ; Wed, 23 Jan 2013 16:20:20 -0500 Received: by mail-oa0-f46.google.com with SMTP id h16so8981197oag.19 for ; Wed, 23 Jan 2013 13:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=/KA5sIgWMTAy2fyjOTth3aLb5DlyfWSknvG6bC7VMP0=; b=k1PpQvF63nVm0FQYB957qsoNhHDrucUlWE17EDcWslkEIdvwUjbu2Zsj9LnKlUxotg H0DCxYYizGB9iOwDRGClJZePl9SDy67eyjA/tTe7+Gy1532nli7dIR5aqAqCEvKK16tn lRCpSJ8Km0QiJAxE/210mZn1l9hJVwgpY6uGSWagdlRMJyNsFBhZgMHrpV4nZlA525z+ BsT+ZhE/sTTofb9KbvgAgQMMOoSPtP6MLAFWNxKmZw0V3G/tFeZGp4DmwvK97K9S5Up5 FJrCKhO4wd9pMvmkB3E2CV7hUgz1RvpLdxXvBsChqRxJ2cOmBbERAPs2UHW/vXEQ3Rcx ic5Q== MIME-Version: 1.0 X-Received: by 10.182.192.68 with SMTP id he4mr2140413obc.99.1358976017829; Wed, 23 Jan 2013 13:20:17 -0800 (PST) Received: by 10.76.82.234 with HTTP; Wed, 23 Jan 2013 13:20:17 -0800 (PST) In-Reply-To: <5100512F.2080707@zerocue.com> References: <50F840F4.7080704@zerocue.com> <50FE7579.1010409@zerocue.com> <5100172C.8040903@zerocue.com> <5100512F.2080707@zerocue.com> Date: Wed, 23 Jan 2013 14:20:17 -0700 Message-ID: To: Clint Priest Cc: Marco Pivetta , Sherif Ramadan , Anthony Ferrara , PHP Developers Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [VOTE] Property Accessors for 5.5 From: morrison.levi@gmail.com (Levi Morrison) On Wed, Jan 23, 2013 at 2:07 PM, Clint Priest wrote: > > On 1/23/2013 1:00 PM, Marco Pivetta wrote: >> >> >> Actually, having the properties shown even if virtual allows us to access >> them in a reflection-ish manner without doing dangerous assumptions like >> "does the setter/getter exist"? >> >> The fact that the property is virtual is very useful, even though in >> dumping it doesn't show any value. I don't see any radical difference in >> debugging or ease of use in general. >> Actually, doing the same things with magic getters/setters would probably >> imply having to think more about the trace we want to follow when analyzing >> our bugs. It is just a matter of being aware of new setter/getters (that are >> anyway in our trace). >> > > If you stop and think about it, the current accessors are identical in > functionality to defining a private variable for every __get(). > > So these two sets of code work and act identically: > > class Foo { > private $bar; > public __get($name) { > if($name == 'bar') > return $this->bar; > } > public __set($name, $value) { > if($name == 'bar') > $this->bar = $value; > } > public __isset($name) { > if($name == 'bar') > return isset($this->bar); > } > public __unset($name) { > if($name == 'bar') > unset($this->bar); > } > } > > -- OR -- > > class Foo { > public $bar { get; set; } > } > > Except in the first case, you have to look at four sections of code to find > "everything that applies to bar" and if you add 5 or 6 more dynamic > properties, you have 4 huge switch statements, again with all the code split > up everywhere. > > With Property Accessors, it's all right there. This of course is a very > simple case, if you actually USE the dynamic nature of __get(), etc then > you've got a ton more code. Let's not forget that all __get and __set would have save visibility unless you manually controlled that which means more coding. Yay!