Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51075 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74432 invoked from network); 18 Dec 2010 17:14:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2010 17:14:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=jbondc@openmv.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jbondc@openmv.com; 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:56245] helo=mail.ca.gdesolutions.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/B0-05093-CEBEC0D4 for ; Sat, 18 Dec 2010 12:14:21 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 091905D34; Sat, 18 Dec 2010 12:14:17 -0500 (EST) 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 UtnfzjRNkFLj; Sat, 18 Dec 2010 12:14:16 -0500 (EST) Received: from djbondc (modemcable083.208-56-74.mc.videotron.ca [74.56.208.83]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 91A925D1A; Sat, 18 Dec 2010 12:14:16 -0500 (EST) To: "'Stefan Marr'" , "'Larry Garfield'" Cc: References: <89C52156-CF92-4DDB-8BA4-4ABF6883512C@stefan-marr.de> <201012132027.59678.larry@garfieldtech.com> <76C593EE-BCCA-4BBD-B625-B6AE9340B20C@stefan-marr.de> In-Reply-To: <76C593EE-BCCA-4BBD-B625-B6AE9340B20C@stefan-marr.de> Date: Sat, 18 Dec 2010 12:14:15 -0500 Message-ID: <001501cb9ed7$001bcbd0$00536370$@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: AcueyH23Y66vNzlFR/GOH0/jZZNyvAABWMew Content-Language: en-ca Subject: RE: [PHP-DEV] Traits and Properties From: jbondc@openmv.com ("Jonathan Bond-Caron") On Sat Dec 18 10:29 AM, Stefan Marr wrote: > At least I do not find an argument for either way that completely > convinces me. > At the moment, the main reason is that 'public' can be considered to > be the default visibility modifier. > Based on the semantics of 'var' and dynamic properties. > Thus, private tends to imply that an additional constraint was > consciously applied to the property, which should be preserved. > Well, but as I said, thats kind of arbitrary and if you look at the > inheritance rules and try to reason from the view of clients with > respect to the external interface, then going with public as the > chosen modifier also starts to sound reasonable... > Does the order of the declaration matter? trait THello1 { public $foo; } trait THello2 { private $foo; } trait THello3 { protected $foo; } class TraitsTest { use THello1; use THello2; // E_NOTICE: TraitTest conflict, THello2(private $foo) ignored, already declared THello1(public $foo) use THello3; // E_NOTICE: TraitTest conflict, THello3(protected $foo) ignored, already declared THello1(public $foo) } class TraitsTest2 { use THello3; use THello2; // E_NOTICE: .. use THello1; // E_NOTICE: .. } It could be that the first property 'wins' and an E_NOTICE is raised about the property conflict. Result: class TraitsTest { public $foo; } class TraitsTest2 { protected $foo; } It would seem to fit php, though I'd be happy with simply E_FATAL until people start using traits The same for: trait THelloA { public $foo = 'a'; } trait THelloB { public $foo = 'b'; } class TraitsTest3 { use THelloA; use THelloB; // E_NOTICE: TraitTest3 conflict, THelloB(public $foo) ignored, already declared THelloA(public $foo) } class TraitsTest4 { use THelloB; use THelloA; // E_NOTICE: TraitTest3 conflict, THelloA(public $foo) ignored, already declared THelloB(public $foo) } class TraitsTest5 { public $foo = 'c'; use THelloB; // E_NOTICE: TraitTest3 conflict, THelloB(public $foo) ignored, already declared TraitsTest5(public $foo) use THelloA; // E_NOTICE: TraitTest3 conflict, THelloA(public $foo) ignored, already declared THelloB(public $foo) }