Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54134 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62346 invoked from network); 22 Jul 2011 16:12:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2011 16:12:30 -0000 Authentication-Results: pb1.pair.com header.from=mikegstowe@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mikegstowe@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.46 as permitted sender) X-PHP-List-Original-Sender: mikegstowe@gmail.com X-Host-Fingerprint: 209.85.161.46 mail-fx0-f46.google.com Received: from [209.85.161.46] ([209.85.161.46:48070] helo=mail-fx0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/61-53734-E61A92E4 for ; Fri, 22 Jul 2011 12:12:30 -0400 Received: by fxh19 with SMTP id 19so5187460fxh.19 for ; Fri, 22 Jul 2011 09:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=8CrAdQCHSFXfNe6j1TPUSXULUJYy0vrsI/kgXJIhzQ0=; b=lGUU9B/9BD0e2r5PoBNKX9TgSWQdYoXja6EEhsXPiclXcYirZLmW0p/fxPKMmXW0x8 7ASoA+AHDNTXPV5iHMH7rOY3ZkmdZrHm5zaME90P+QoYrHtBo7v7kTvz8Dy4MmmhD/0Z mj3ZAooF6wDLBAhXpJ9cFtOb/mFVRdSY5sq2U= Received: by 10.223.1.12 with SMTP id 12mr2256831fad.113.1311351147098; Fri, 22 Jul 2011 09:12:27 -0700 (PDT) MIME-Version: 1.0 Sender: mikegstowe@gmail.com Received: by 10.223.2.7 with HTTP; Fri, 22 Jul 2011 09:12:07 -0700 (PDT) In-Reply-To: References: <4E29949C.9020209@gmail.com> Date: Fri, 22 Jul 2011 11:12:07 -0500 X-Google-Sender-Auth: lCSIOZovdZFb0NwgGrpW9m56sw8 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=000e0ce0ee564c739d04a8aabb99 Subject: Re: [PHP-DEV] 5.4a2 trait attribute name conflict resolution From: me@mikestowe.com (Michael Stowe) --000e0ce0ee564c739d04a8aabb99 Content-Type: text/plain; charset=ISO-8859-1 Didn't send to list the first time, please accept my apologies if you received this twice - Thanks That makes sense if it would overwrite the methods as well, but otherwise it seems like it provides inconsistent functionality. Perhaps I'm wrong as likewise I have a very limited understanding here. - Mike -- Past Conversation --- --------------------------------- In my limited understanding, a trait is sort of composited at compile time (ish). As properties are dynamic (ish), they will overwrite. Just like an inherited class will overwrite public properties in their parent class. Richard --------------------------------- I was under the impression that traits were not supposed to have properties at all: From the RFC: Since Traits do not contain any state/properties, there is a need to describe the requirements a Trait will rely on. In PHP it would be possible to utilize the dynamic language features, but it is a common practice to give this requirements explicitly. This is possible with abstract methods like it is used for abstract classes. Is the support for properties the bug perhaps? Anthony --------------------------------- Hello folks, I've just grabbed 5.4a2 to play with traits. I've found some behaviour which I'm not sure is a bug, an inconsistency, or a design decision. Consider a trait and a class that implements it but also overrides both a trait method and a trait attribute: trait foo { public $zoo = 'foo::zoo'; public function bar() { echo "in foo::bar\n"; } } class baz { use foo; public $zoo = 'baz::zoo'; public function bar() { echo "in baz::bar\n"; } } $obj = new baz(); $obj->bar(); echo $obj->zoo, "\n"; We get: in baz::bar foo::zoo It seems this is not correct and that it should be: in baz::bar baz::zoo The traits RFC pretty clearly states that if a class method conflicts with a trait method then the trait method will be ignored, which is what's happening, but it says nothing about what happens to attributes in that same condition. Is this a bug? Alex --000e0ce0ee564c739d04a8aabb99--