Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65124 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31322 invoked from network); 23 Jan 2013 21:08:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2013 21:08:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=cpriest@zerocue.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cpriest@zerocue.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zerocue.com designates 67.200.53.250 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 67.200.53.250 mail.zerocue.com Received: from [67.200.53.250] ([67.200.53.250:46382] helo=mail.zerocue.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/C3-30997-A3150015 for ; Wed, 23 Jan 2013 16:08:11 -0500 Received: from [172.17.0.122] (unknown [70.112.216.188]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.zerocue.com (Postfix) with ESMTPSA id BE9BF1203A3; Wed, 23 Jan 2013 21:08:07 +0000 (UTC) Message-ID: <5100512F.2080707@zerocue.com> Date: Wed, 23 Jan 2013 15:07:59 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: Marco Pivetta CC: Sherif Ramadan , Anthony Ferrara , PHP Developers Mailing List References: <50F840F4.7080704@zerocue.com> <50FE7579.1010409@zerocue.com> <5100172C.8040903@zerocue.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [VOTE] Property Accessors for 5.5 From: cpriest@zerocue.com (Clint Priest) 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. -- -Clint