Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61901 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4943 invoked from network); 31 Jul 2012 23:24:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2012 23:24:09 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 209.85.212.182 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:62022] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/65-00342-81968105 for ; Tue, 31 Jul 2012 19:24:09 -0400 Received: by wibhq12 with SMTP id hq12so2818275wib.11 for ; Tue, 31 Jul 2012 16:24:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:from:to:subject:date:mime-version:content-type :x-priority:x-msmail-priority:x-mailer:x-mimeole:x-gm-message-state; bh=edebBxHnZZRh3pAA39rnhU8BBmVemtP0Sxe0kmuga8s=; b=Fxix2S81/BRyTOKo+Qb6cDB/N/TVGrY9IUR6DLgUN0TCforvSiihLSMshzYQzOzpu+ FlEPpZ37u12mauTz2NQ0bGrIwgEgHd3LWhJx+wvycAdk2JlCELccyAGmNQUUkjKrMXHT GZIiM6ojg79gvELQzUYhNLFhD8RwfRztJRhQj16EYenI2scospi9IolLx50o6zD3asJK JflXE501+dryda+/6iu2wmxP1YJkoMpYpogxJdpGei/cwFfV9sq6gOdEN02gCINJRcHn 2I9a74tBVNZC96nG+wFsh6s5rgdZ8WL/EJVeSVnfoHOJ3P/7+PgJYr49sR4Ll+DulnmW dAAg== Received: by 10.180.106.97 with SMTP id gt1mr6949799wib.5.1343777046029; Tue, 31 Jul 2012 16:24:06 -0700 (PDT) Received: from pc (79-100-60-213.btc-net.bg. [79.100.60.213]) by mx.google.com with ESMTPS id fr4sm3898819wib.8.2012.07.31.16.24.03 (version=SSLv3 cipher=OTHER); Tue, 31 Jul 2012 16:24:05 -0700 (PDT) Message-ID: <232501B15F7F4B3197123F219370E36D@pc> To: Date: Wed, 1 Aug 2012 02:23:57 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0018_01CD6F8C.B411C360" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Gm-Message-State: ALoCoQk8PTivFFj8eLDfww3yvDh8Ud7qBti/Rbm7o0JdphjlYuEL8UnqSOZLZHKSyui0qCeFl6xH Subject: Traits behavior still up in the air in 5.4 From: sv_forums@fmethod.com ("Stan Vass") ------=_NextPart_000_0018_01CD6F8C.B411C360 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable I'd like to point out some puzzling behaviors in Traits as they exist in = the production releases of PHP 5.4. -------------------------------------------------------------------------= --- 1. Name collisions between a trait method and a class method using the = trait go unreported, the class silently shadowing the trait method: -------------------------------------------------------------------------= --- trait T { function foo() { $this->bar; } function bar() { echo 'trait'; } } class C { use T; function bar() { echo 'class'; } } $c =3D new C; $c->foo(); // "class" Proposed behavior: Fatal error on collision, unless the method is = imported with a unique name using the { ... as ... } syntax. -------------------------------------------------------------------------= --- 2. Using "as" syntax when importing a trait does NOT rename a method, = but creates an alias CLONE, the original method still callable. -------------------------------------------------------------------------= --- trait T { function bar() { echo 'trait'; } } class C { use T { bar as foo; } } $c =3D new C; $c->bar(); // "trait" Proposed behavior: the original name should be only accessible within = the trait and its methods, not from the class methods or by calling the = class instance's methods from outside. -------------------------------------------------------------------------= --- 3. Properties silently collide in traits and classes. -------------------------------------------------------------------------= --- trait T1 { private $foo; trait T2 { private $foo; } class C { use T1, T2; } // No error. Proposed behavior: An error is produced only when the properties differ = in visibility or a default value, which is clearly insufficient to = determine they're used for the same purpose, and hold the same data. = Instead they should use the same logic as method conflicts: fatal error = on name collision. Alternatively, each trait property whould be = accessible within the trait that defines it, not from other traits used = in the same class, or the class itself. -------------------------------------------------------------------------= --- 4. The documentation says static propeties can't be defined by traits. = Yet they can. -------------------------------------------------------------------------= --- I don't know what's the bug here: a doc bug, or a code bug. For = consistency, static properties should work, if instance properties work. = Nothing is gained supporting it half-way. Not many use 5.4 yet, so the sooner all this is clarified, the better, = before it becomes completely unfixable due to BC. Feedback? Stan ------=_NextPart_000_0018_01CD6F8C.B411C360--