Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54154 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4024 invoked from network); 23 Jul 2011 13:57:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2011 13:57:23 -0000 Authentication-Results: pb1.pair.com header.from=stefan.marr.de@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stefan.marr.de@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: stefan.marr.de@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:51938] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/C0-32631-243DA2E4 for ; Sat, 23 Jul 2011 09:57:23 -0400 Received: by qwi4 with SMTP id 4so1717576qwi.29 for ; Sat, 23 Jul 2011 06:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=qm9RfMK9hBwe1Df2l6BY3H/VwezhetnC6Dfzr4d3770=; b=L1BRE56aQ5SUR+gr56ukuFocpy8nHjiSD00PdVNokgi+JJRRgwQ5ZWK61jzwoyAVbm 1A7SQWSK4KVUUgmRQPgB3167CkxHY6w2WEyMePWLmAPDPmM418A50DWs7LlXXJN25Ija TBuAkfOqyOMkGFZQpvMtXaUzJ3mj4m8KZ0Clo= MIME-Version: 1.0 Received: by 10.229.226.7 with SMTP id iu7mr2003137qcb.85.1311429440444; Sat, 23 Jul 2011 06:57:20 -0700 (PDT) Reply-To: php@stefan-marr.de Sender: stefan.marr.de@gmail.com Received: by 10.229.89.129 with HTTP; Sat, 23 Jul 2011 06:57:20 -0700 (PDT) In-Reply-To: <4E29B780.1030009@gmail.com> References: <4E29949C.9020209@gmail.com> <004701cc4890$f9d63f80$ed82be80$@com> <4E29B780.1030009@gmail.com> Date: Sat, 23 Jul 2011 15:57:20 +0200 X-Google-Sender-Auth: 5hv3-dVAFAJXE89bRW9jUBWPY9Y Message-ID: To: Alex Howansky Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] 5.4a2 trait attribute name conflict resolution From: php@stefan-marr.de (Stefan Marr) Hi Alex: On Fri, Jul 22, 2011 at 7:46 PM, Alex Howansky wrote: > >> Best practice, always choose trait property names carefully/~unique >> so that you don't run into conflicts. > > 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? > >> 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. If their trait grows that complex, with its own set of invariants, it is a clear sign that it should be a class instead. Traits are supposed to be a very light-weight mechanism for reuse of behavior. Classes already provide you with the necessary means of encapsulation you are asking for here: but traits do not do that. If you want to reuse a trait that is that complex, consider to use it in a separate class, which is then used in a composition in the class were you originally were going to use the trait directly. Traits do not allow to be reused without knowing their internals. The metaphor of a compiler-assisted copy'n'past mechanism hints at that. At least that is my interpretation of the topic. Best regards Stefan