Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91382 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7320 invoked from network); 24 Feb 2016 22:04:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2016 22:04:34 -0000 Authentication-Results: pb1.pair.com header.from=chasepeeler@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=chasepeeler@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.54 as permitted sender) X-PHP-List-Original-Sender: chasepeeler@gmail.com X-Host-Fingerprint: 209.85.218.54 mail-oi0-f54.google.com Received: from [209.85.218.54] ([209.85.218.54:35677] helo=mail-oi0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/A1-27730-0F82EC65 for ; Wed, 24 Feb 2016 17:04:33 -0500 Received: by mail-oi0-f54.google.com with SMTP id x21so27072473oix.2 for ; Wed, 24 Feb 2016 14:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=zTU2Rf0m4LBDwpyp5qAXwXo+7k6v8dDZvoLBtjZccMk=; b=Tm1rAgDWScXLacDVdoLCkynlnM9XYy3kLsInZ/HK1gZ/V5XHmM7QfebVM+9on9sJLv QG3JlU5fb5X7V2lshyVvNsTe5Hz9M8C+U/0C72UkXqlzUzpGdyjGOFI+hoq2qzFcGlQZ 8yUfgQzF4eDJBdJKEFm9fqRM4A+SYCbJZ4+fJSqe6QJOOgHq0Q+lp4CiF1o/85NXaFA9 bDk+bLKEcGb8FSkVoNuMSO79fWb6eu5BOlgYoufk/NfrlBij9oM/wvPMyNmH7OBl9K/r aCPp8zxzHEh3hpQnxX7tq5Lg+E+eyHrvUcXY4DRbhN6KoYpu61h8Aixp4nukzzW/9OZo NmgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; bh=zTU2Rf0m4LBDwpyp5qAXwXo+7k6v8dDZvoLBtjZccMk=; b=QVpj4fDEruv5rb5VxutOtsnAE/aySoefqd+PYmb8gZT787X5KLari5srPcgrDw0kwT vu6xUNzIvyuXoVD5XGMaCy6sF5w7QWPHHHOrpWWZK5Ft+7QcJc9AI7zhNFQjZPSQx748 b6FyNwBZ51WUY+1nzlac2R56nyc8EfL+uyXIHRg0AnmELS9L0j+nPV9q7Jw4liicO36/ VJl6sVhcsFmbISMWea33YE99MP5+ewCMFCIP8ZTUrf9+PXBKRqYiSPXs+L5k3RCihlzN nkTTWibwN6ISMtPubfStkuiBR4kPIEJo4M8NpCt+vRpaXqV7iK9hctrlfW4LMbapeKxY 0BUg== X-Gm-Message-State: AG10YOQ6EgV56JOWzc6SwwFCdJP/5PcpeaOdiGn4DyE5Tufw/+E4kbze/Bywv5b4+g68aGNr/Tr71GkKzuUUPw== X-Received: by 10.202.97.135 with SMTP id v129mr32537955oib.45.1456351469920; Wed, 24 Feb 2016 14:04:29 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 24 Feb 2016 22:04:20 +0000 Message-ID: To: Kevin Gessner , Chris Riley Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a113db77808680c052c8b4009 Subject: Re: [PHP-DEV] Re: [RFC] Traits with interfaces From: chasepeeler@gmail.com (Chase Peeler) --001a113db77808680c052c8b4009 Content-Type: text/plain; charset=UTF-8 On Wed, Feb 24, 2016 at 4:46 PM Kevin Gessner wrote: > On Tue, Feb 23, 2016 at 4:48 AM, Chris Riley wrote: > > > This isn't such a great idea as it will cause some of traits > functionality > > to be broken: I can currently use a trait and alias its methods and > change > > their visibility. If a trait implements an interface which is copied onto > > my class I can no longer do this as the compiler will throw a fatal error > > for the class not correctly implementing the interface that got copied > from > > the trait. > > > > This is only true under Proposal 2 of the RFC, and this is listed as an > open issue: https://wiki.php.net/rfc/traits-with-interfaces#proposal_2 > > Proposal 1, where the engine enforces interface declarations on traits, > doesn't affect how traits are inserted and still allows aliasing. > > > > If you decide to continue pursuing this RFC, I'd like to see some thought > > given to the above; perhaps it could be as simple as not copying the > > interface if aliases/visibility changes are made in the use or perhaps > > something more complex which allows specifying which interfaces should be > > copied into the class from the trait. > > > > I agree that there are several reasonable solutions here, but I'm not sure > which is the best. It does feel too aggressive to have it be a fatal error > if aliasing undoes the interface implementation. At the same time, > introducing new syntax to enable aliasing to work with interface > propagation defeats the purpose, which is to make it easier and simpler to > implement an interface via a trait. > > I'd be interested to hear if you have any ideas about how this should > look. I'm mostly unfamiliar with aliasing traits in practice, so I'd be > curious to see how this RFC would affect your code. > > Since the class doesn't know you are using the trait to implement the interface, if you alias the trait method, then the class no longer implements the interface unless it defines the method that is now missing itself. Remember, the contents of the trait are just getting copy/pasted into the class. If you alias a method, then the method gets pasted in using the alias, not the original name. That being said, it should be rare that you would alias a method and then not implement the method yourself - as the need to redefine/expand on its functionality is the reason you usually alias a trait method. > Cheers > -- Kevin > -- -- Chase chasepeeler@gmail.com --001a113db77808680c052c8b4009--