Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91513 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19306 invoked from network); 5 Mar 2016 23:16:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2016 23:16:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@daveyshafik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@daveyshafik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain daveyshafik.com from 74.125.82.45 cause and error) X-PHP-List-Original-Sender: me@daveyshafik.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:34042] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/34-08669-2B86BD65 for ; Sat, 05 Mar 2016 18:16:03 -0500 Received: by mail-wm0-f45.google.com with SMTP id p65so63729885wmp.1 for ; Sat, 05 Mar 2016 15:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daveyshafik-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=JTRLezpJYxsCi59AYr1oys+zEC3gHDwGWZwGclHVqKw=; b=YDGm2Oz5hMtG/2XE7b2BV/OEVlJTXZe48Q8H1uOHRIc6ceYMBB3T4Hxk9iQDM2/Lio wVS1f9cnH6I45dvLOHFta7TWL2jeTpq+lhTW5g8OUenC+PD/A8Fi4MB9EYWhYC/HgXL4 0HS08vFA3VweNMCnpbARU6O7hce30RqDgj0t4rs2RLw0YvA9Wcm4P0q6Asp2hysiZyb7 2TqCVMNQP/cgthyO0wqP/s56e6KmgUBWVXeTg3IR92508q5pwL7sigohY/6XO6m5ar9W PxbVWAwEGHPluY6vxjzABal/L5/gBeO/DCkyNC2RjB+EEDYEX23AXUrzY0+zKriLKD2W t10A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=JTRLezpJYxsCi59AYr1oys+zEC3gHDwGWZwGclHVqKw=; b=fTQUrGH7rssF+H+xsfT1BVv4ex9uZYiqHK6NbCkU8NZV197IIQj6NNGTDXPhJNvRl3 JIqN5dHlo0nDpUH1OMa5qkVCDRO1RPiu+fkFMqfPFQd+ByFIh5Y75QHKnguHfloyiBVA j2JgCXSv/2b2KQdGcRmigKmz8xKFSUMPoxKXdSkbbNlv0UA8FKeT0HYadgVXIC3JMn/a 8KaQfjJA3MRwev+69Qhcf7I6DhoPMji2LhuqqadPuYxWaIFR4sNrgBMbzfctBqwQ8PwL 2zQXF7XUCnRPlObXTRlKtLZMuMk9ntVe/cSeQ1LGn2dNqABvERebiXzIMuRhoiQirXLh e9ZQ== X-Gm-Message-State: AD7BkJJGJiRpgttnouAFluWl3uy+n2QD4IVTLhhSqhbPtascdk9aC0GElqN2YTeP/ZAQ4EUaKlzNI7VwuGXe6gpx MIME-Version: 1.0 X-Received: by 10.28.22.74 with SMTP id 71mr5288725wmw.47.1457219758593; Sat, 05 Mar 2016 15:15:58 -0800 (PST) Sender: me@daveyshafik.com Received: by 10.194.138.197 with HTTP; Sat, 5 Mar 2016 15:15:58 -0800 (PST) In-Reply-To: <56D95E18.9020007@gmail.com> References: <94.96.08749.188B8D65@pb1.pair.com> <56D95E18.9020007@gmail.com> Date: Sat, 5 Mar 2016 15:15:58 -0800 X-Google-Sender-Auth: OxXbNz7RCckcnXbBHuhQDE7G9lU Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1146762c123543052d556a19 Subject: Re: [PHP-DEV] Re: [RFC] Traits with interfaces From: davey@php.net (Davey Shafik) --001a1146762c123543052d556a19 Content-Type: text/plain; charset=UTF-8 On Fri, Mar 4, 2016 at 2:06 AM, Rowan Collins wrote: > Davey Shafik wrote on 04/03/2016 07:17: > >> 1. If you simply alias (use foo { bar as bat; }) then you end up with an >> *additional* method with the new name, the trait method as defined is >> still >> brought in, and_will_ override inherited methods of the same name. >> > > Here's a clearer example of this: https://3v4l.org/RKHPt > > Unfortunately, you can't even use "insteadof" to directly bring the parent > method back in [https://3v4l.org/qOS5T], but you can stub it out with a > direct call to parent:: [https://3v4l.org/s9i4N]. > > 3. Doing this (visibility + name)_only_ gives you the new method, which is >> _different_ behavior to #1 >> > > I can't reproduce this: if I say "bar as private bat", the trait's bar > still shows up, and is public, just as in the previous example: > https://3v4l.org/1jH6o > > Your examples are rather confusing because they are effectively applying > the same trait twice, at different levels of the hierarchy; I'm not sure > this is a particularly likely scenario, or relevant to how interfaces > should behave. > > Regards, Rowan, You are mid-reading, none of the classes in my examples extend the others, they are all just using the same trait in different ways. - Class a: use the trait with no aliases. Result: as expected - Class b: use the trait with a simple alias, no visibility change. Result: both methods - Class c: use the trait with and alias both name, and change visibility. Result: ONLY the aliased method - Class d: use the trait and "alias" to the same name, ONLY changing visibility. Result: causes a Fatal error, clashing with itself o.O For the one you can't re-produce, it's class 'c', which is stand-alone here: https://3v4l.org/K9o6Y - Davey --001a1146762c123543052d556a19--