Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54151 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3205 invoked from network); 22 Jul 2011 18:41:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2011 18:41:49 -0000 Authentication-Results: pb1.pair.com header.from=jbondc@openmv.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jbondc@openmv.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain openmv.com from 64.15.152.204 cause and error) X-PHP-List-Original-Sender: jbondc@openmv.com X-Host-Fingerprint: 64.15.152.204 mail.ca.gdesolutions.com Received: from [64.15.152.204] ([64.15.152.204:56327] helo=mail.ca.gdesolutions.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/F5-03772-C64C92E4 for ; Fri, 22 Jul 2011 14:41:49 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 3C4655CFD; Fri, 22 Jul 2011 14:41:46 -0400 (EDT) X-Virus-Scanned: amavisd-new at gdesolutions.com Received: from mail.ca.gdesolutions.com ([127.0.0.1]) by localhost (mail.ca.gdesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x+83qJ9rnemM; Fri, 22 Jul 2011 14:41:45 -0400 (EDT) Received: from djbondc (modemcable053.81-59-74.mc.videotron.ca [74.59.81.53]) by mail.ca.gdesolutions.com (Postfix) with ESMTPSA id 574EB5C4B; Fri, 22 Jul 2011 14:41:45 -0400 (EDT) To: "'Alex Howansky'" Cc: References: <4E29949C.9020209@gmail.com> <004701cc4890$f9d63f80$ed82be80$@com> <4E29B780.1030009@gmail.com> In-Reply-To: <4E29B780.1030009@gmail.com> Date: Fri, 22 Jul 2011 14:41:44 -0400 Message-ID: <007901cc489f$01d02580$05707080$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcxIl3LJiJpqQb0WReOaFtRCiw1LQgAAYjUA Content-Language: en-ca Subject: RE: [PHP-DEV] 5.4a2 trait attribute name conflict resolution From: jbondc@openmv.com ("Jonathan Bond-Caron") On Fri Jul 22 01:46 PM, Alex Howansky wrote: > > Sure, but in this case, I created the conflict intentionally because I > *want* to override it, and I'm not allowed to like I am with methods. > Don't you think that's inconsistent? > Agree > > The short answer is it's not a bug but maybe an implementation > > issue... should it be an E_WARNING instead of E_STRICT? > > At least. Consider the situation where I'm using classes/traits from > somebody else's library that I may not be intimately familiar with. > I'll have to know what every one of their properties is named so I can > plan my code accordingly -- else I'll silently start getting their > values in what I think are my variables. Part of the problem is if you have something like: trait foo { private $zoo = 'important_do_not_modify'; public function showZoo(){ echo $this->zoo; } public function doSomething(){ if($this->zoo !== 'important_do_not_modify') die('bad'); } } class baz { use foo; private $zoo = 'modified'; } $obj = new baz(); $obj->bar(); echo $obj->showZoo(); // modified echo $obj->doSomething(); You can essentially 'break' the trait. So if you think of using someone else's library/trait, it's not fun either when you break something without knowing it. But even then, I'm with you on allowing to change the default property value in the composing class (I'm in favor of it). What traits would likely need is: trait foo { trait $zoo = 'important_do_not_modify'; public function doSomething(){ if(trait::$zoo !== 'important_do_not_modify') die('bad'); } } So that traits can keep their own private state (Ben Schmidt's idea)