Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91248 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59079 invoked from network); 17 Feb 2016 15:01:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2016 15:01:30 -0000 Authentication-Results: pb1.pair.com header.from=kgessner@etsy.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kgessner@etsy.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain etsy.com designates 209.85.192.43 as permitted sender) X-PHP-List-Original-Sender: kgessner@etsy.com X-Host-Fingerprint: 209.85.192.43 mail-qg0-f43.google.com Received: from [209.85.192.43] ([209.85.192.43:35792] helo=mail-qg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/A9-17120-84B84C65 for ; Wed, 17 Feb 2016 10:01:28 -0500 Received: by mail-qg0-f43.google.com with SMTP id y89so13372910qge.2 for ; Wed, 17 Feb 2016 07:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsy.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=mer8fkQXba8/CJpfJW3LaNIk2Mty3pmONs1UW27dcsk=; b=jUOM0DWgG2qUPSwkt8UewBNnjb1exXGAOz8r5+o7G2tgPWv/7cuHBzslFhGgftg6rJ VPURE+sRlGn72/6oCzpJWj34ViLaDLgVuaEEROx1kC447bGSZkxih46ygE1H7Y5UVkl2 oWbgUFeoy0iBG5sNwjz0qADJJeF/BTALw27qQ= 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:cc:content-type; bh=mer8fkQXba8/CJpfJW3LaNIk2Mty3pmONs1UW27dcsk=; b=TJO2Q2U1umjW2P2VPU/stnpts+NfX/cHlQ2oyOXs7mqoz6rIjugKcfWzK7QC6GIdb1 LJbnOIlIZATy+7h3eYhkIfZTHuuv361zR0l4WfiKFMiOU5azWTOpyZt/kaajEVWFfR0N EZYgVK0Qsirlnx6J6+5M2fFX422DnCI1/Qc9N5+HEyOixDBPbEa5VCRws4KqqHZ9Qw9X /qt4vWVajbzWKAVUrGkSxW/42WnvIfAAEWpOSYIpJlvAB6VbhEh9ZmhOD7g0G8kkVGzi N/CCTh6nGhHmGAzI5tC51rKB4m4Cg2j0ngOAmTRXAjToqdShmpPzNxS15RLMZw3gzkMy rQ3g== X-Gm-Message-State: AG10YORe58dFlaRuutJtMa02wTKkuWiCKpoPQ4ATsqKHKnzWRpczveIEU+CFhdEl9NjxHRWSsr59/e46eqx7l9zu MIME-Version: 1.0 X-Received: by 10.140.105.198 with SMTP id c64mr2457192qgf.94.1455721285769; Wed, 17 Feb 2016 07:01:25 -0800 (PST) Received: by 10.55.165.198 with HTTP; Wed, 17 Feb 2016 07:01:25 -0800 (PST) In-Reply-To: <56C484DB.3000608@php.net> References: <56C484DB.3000608@php.net> Date: Wed, 17 Feb 2016 10:01:25 -0500 Message-ID: To: Sebastian Bergmann Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a113984a4217e4e052bf88655 Subject: Re: [PHP-DEV] [RFC] Traits with interfaces From: kgessner@etsy.com (Kevin Gessner) --001a113984a4217e4e052bf88655 Content-Type: text/plain; charset=UTF-8 On Wed, Feb 17, 2016 at 9:34 AM, Sebastian Bergmann wrote: > Am 17.02.2016 um 15:25 schrieb Kevin Gessner: > > Hello internals team! I'd like to propose an RFC to allow traits to > > implement interfaces. > > I think that would violate "The Flattening Property" [1], meaning > that the fact that a class uses a trait must not be noticable by a > user of that class. > I don't believe that it will violate that property. Take this code for example, which would be valid with the proposed change: I] // ) Given only class C, an outside caller would not be able to distinguish it from a class that implements I directly, or from a class that implements I via inheritance. Is there an additional wrinkle here that I've not considered? > Also bear in mind that explicit is better than implicit. Two > explicit declarations, "implements " and "uses ", > makes it obvious from looking at the code of a class that is > provides a specific API and uses a trait for its implementation. > I consider this sort of implicit declaration a benefit, in the spirit of DRY. It's in the same vein that an interface can be implicitly implemented by way of a class's superclass, which reduces code duplication and extra declarations in subclasses. And in fact it makes the trait itself more explicit: if the intention of the code is that a trait provides an implementation of a particular interface (I've found several in-the-wild examples of this, such as [1][2]), all the better that the trait explicitly declares that interface. 1: https://github.com/symfony/symfony/blob/582f4753a343f230fbe18b4e9a0747d48351ddfb/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php 2: https://github.com/symfony/symfony/blob/582f4753a343f230fbe18b4e9a0747d48351ddfb/src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php > > -- > [1] https://wiki.php.net/rfc/horizontalreuse > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113984a4217e4e052bf88655--