Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54130 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43969 invoked from network); 22 Jul 2011 15:46:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2011 15:46:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.44 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.210.44 mail-pz0-f44.google.com Received: from [209.85.210.44] ([209.85.210.44:58549] helo=mail-pz0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/64-15078-96B992E4 for ; Fri, 22 Jul 2011 11:46:50 -0400 Received: by pzk5 with SMTP id 5so4347570pzk.31 for ; Fri, 22 Jul 2011 08:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=peuenJjCE3vqIx1L36i4NxJ1FwTgReywOiObc+Tco2Y=; b=eYpmxzVfU12E+a0lVqmJ4gTBg8pTDogpLxA8kJ0gX1oa1uL6tgUmkveQDLwz55N7us tTt/WW5qvE5NjkXFazUaKFFZlyEBm8DQe7DmpGGEBDCeOphGwVZX4BoUpHRyhf8y62k+ iOOsfMEe3lETuFfSzMSgJDrDcMBBAHppe8sdI= MIME-Version: 1.0 Received: by 10.68.40.131 with SMTP id x3mr2630336pbk.128.1311349606902; Fri, 22 Jul 2011 08:46:46 -0700 (PDT) Received: by 10.68.62.2 with HTTP; Fri, 22 Jul 2011 08:46:46 -0700 (PDT) In-Reply-To: <4E29949C.9020209@gmail.com> References: <4E29949C.9020209@gmail.com> Date: Fri, 22 Jul 2011 11:46:46 -0400 Message-ID: To: Alex Howansky Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] 5.4a2 trait attribute name conflict resolution From: ircmaxell@gmail.com (Anthony Ferrara) 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 On Fri, Jul 22, 2011 at 11:17 AM, Alex Howansky w= rote: > > Hello folks, > > I've just grabbed 5.4a2 to play with traits. I've found some behaviour wh= ich > 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 > { > =A0 =A0 public $zoo =3D 'foo::zoo'; > =A0 =A0 public function bar() > =A0 =A0 { > =A0 =A0 =A0 =A0 echo "in foo::bar\n"; > =A0 =A0 } > } > > class baz > { > =A0 =A0 use foo; > =A0 =A0 public $zoo =3D 'baz::zoo'; > =A0 =A0 public function bar() > =A0 =A0 { > =A0 =A0 =A0 =A0 echo "in baz::bar\n"; > =A0 =A0 } > } > > $obj =3D 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 wit= h 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 s= ame > condition. Is this a bug? > > Thanks, > > -- > Alex Howansky > >