Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91353 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43317 invoked from network); 23 Feb 2016 09:48:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2016 09:48:44 -0000 Authentication-Results: pb1.pair.com header.from=t.carnage@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=t.carnage@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: t.carnage@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:34763] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/40-38634-9FA2CC65 for ; Tue, 23 Feb 2016 04:48:43 -0500 Received: by mail-wm0-f52.google.com with SMTP id b205so191538229wmb.1 for ; Tue, 23 Feb 2016 01:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=0ZtOXbIW9Fr85Lfzhp4yHaBx5B+2uxZdgke+biwzxv8=; b=pbKmsw9pOxi09ulv4w4lpccV7MPmbxbQAa6P6NN4lvRFTwBiw2NJr1K1RskTjojoIK +CRu+I+yi9EpX29WqMpIsU8kcMd8X0j/jA2bXLqZTUBQ7W1P6uBg6hlhEoSTsNktNmVF vigOC2/fMA4z0pS0iY6ACI2wb6XLEOC/MdFBJ9edKeCeBV6qRkqpGEsrJ1ChUtpN65e1 HJfpiNhUOLt+IVtCbSibvcZ685ksL4wlKn0/TfRxcrG/ZHQdpNHhF7RsMqB5oaB2wn0O 8poY2M9pqDJA7rUhN6U+PBUuTg4nP3j9QKVbx+FUI5kuzBzWNlX6wHljaozuJmYbyveP ijkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=0ZtOXbIW9Fr85Lfzhp4yHaBx5B+2uxZdgke+biwzxv8=; b=Wl354xDjBCRp3clGhw3UEnwTSJa+xVOay7hDqQgV3rqgtnDaSSsrxO+iogIddfNtE+ Hw1XKksMdVQ1pmM5WyKjRItNX7JYcA89r29Da+YSuOtiZXpNsqbMmhWyEAFLk+npSB5e JUzlP5kc7f7d4wgjGJV5ZMHaqWSpwmyURQUNIAFemZgBcJzmWxIHfla6Li6qQfrLJRKH Ry/pVJSv0d8wbEs0mWvk/MmS50OIFjoM8GOZ9OTYxHBHdF/hLi7jfdaFfX1TlGX58JZ1 JtrLIQliIcFfdMUOfmk+Yyq/AbqECePF22AnNcdb3AT4oc0dk6VNJ5oI7GcA+FX6Dcle mbrg== X-Gm-Message-State: AG10YORD4LhZxrCaTnNr2i+rGT5tL64KcDI4d8gx3bsvilXU+4HjWv56z8IPKI600vMoqwrf80Zx7dkP275KsQ== MIME-Version: 1.0 X-Received: by 10.194.3.110 with SMTP id b14mr32958283wjb.116.1456220918644; Tue, 23 Feb 2016 01:48:38 -0800 (PST) Received: by 10.194.122.201 with HTTP; Tue, 23 Feb 2016 01:48:38 -0800 (PST) In-Reply-To: References: Date: Tue, 23 Feb 2016 09:48:38 +0000 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=047d7b33dc5092057b052c6cda8c Subject: Re: [PHP-DEV] Re: [RFC] Traits with interfaces From: t.carnage@gmail.com (Chris Riley) --047d7b33dc5092057b052c6cda8c Content-Type: text/plain; charset=UTF-8 On 23 February 2016 at 00:37, Alex Bowers wrote: > Would a fair solution to this be having the using class define whether to > inherit the implementations? Perhaps a new keyword akin to 'propagated', so > the code will read > > Class Foo { > Use propagated TraitName; > } > > Only then will the implementations from that trait bubble through. If it > isn't declared then the implementations are not visible. This should keep > all backwards compatibility and keep code readable since now we can > immediately tell which traits being used do we want the implementations for > in the main class. > On 22 Feb 2016 20:19, "Kevin Gessner" wrote: > > > On Thu, Feb 18, 2016 at 4:13 PM, Kevin Gessner > wrote: > > > > > On Wed, Feb 17, 2016 at 2:05 PM, Kevin Gessner > > wrote: > > > > > >> I've created a proper RFC wiki page here with the draft: > > >> https://wiki.php.net/rfc/traits-with-interfaces > > >> > > >> It includes more detail and several example code snippets. Thanks all > > >> for your feedback so far. > > >> > > > > > > I've just updated the RFC to v0.2, presenting two proposals to be voted > > > separately: one to allow traits to declare and implement interfaces, > and > > a > > > second (dependent on the first) to propagate interface declarations > from > > > traits to classes. > > > > > > > I've created a php-src pull request for Proposal 1 of the RFC, allowing > > traits to declare and implement interfaces: > > https://github.com/php/php-src/pull/1773 > > > > Reviews and feedback welcome! > > > > I haven't yet started on an implementation for Proposal 2. > > > > Cheers > > -- Kevin > > > 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. 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. ~C --047d7b33dc5092057b052c6cda8c--