Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91258 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86019 invoked from network); 17 Feb 2016 19:48:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2016 19:48:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=kgessner@etsy.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kgessner@etsy.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain etsy.com designates 209.85.220.181 as permitted sender) X-PHP-List-Original-Sender: kgessner@etsy.com X-Host-Fingerprint: 209.85.220.181 mail-qk0-f181.google.com Received: from [209.85.220.181] ([209.85.220.181:33639] helo=mail-qk0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/FD-17120-98EC4C65 for ; Wed, 17 Feb 2016 14:48:26 -0500 Received: by mail-qk0-f181.google.com with SMTP id s5so10282151qkd.0 for ; Wed, 17 Feb 2016 11:48:25 -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=o5cv4pARX+RJIOrYnxDD8z0lyf/HFbH6H6x1MVCx2iM=; b=QoGxbY/EjarE976L5B9WLo4DeO1/smDitAldo780vlUUR4DOIFDdOGOuclzbVBU25l xqdfgZV3XVyRCcLSd8RDmb8o1Aq4oCHkqnC+qSEzaB387O+VxEUf0NxoIxSz0KsfF0xV yiRBH7XAWo0z64hxF3rleV88xUEQPfoVT9/Y0= 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=o5cv4pARX+RJIOrYnxDD8z0lyf/HFbH6H6x1MVCx2iM=; b=BE8ADS9kswvY81HUywYvRiAIAQNzS9bsHlDy3+G+E+CBnLmEFM6qK5fqYJUlk9RrUI 6/KyI51l0lS6SksRgO3F7dwKzmYXJZa5Y3TYSQVRPJLwxvz23VSkDrA7VT1I40dFGKCd esNpL0u3MO0cOk86zu9zs7EtH1oYPIt4O8PULJJxL4G/PP84th2o7AspAdvdlhU0gjME DRVfKuLPx7dCs8HUfheO2LOZI+hNO2+tlr6gVkhXoyeJgBoa/0/mXqm7wyuf5ua+Xifo PO7GIsHoO8h8soGhQnLwJcMMUdGKSovEeIDVzlGAuGZwdCVpE+Tql9DGBoWr4N1qC78V QQJg== X-Gm-Message-State: AG10YORXuPaRstoGzMhU71ZFgn/yajv5PjtMTgYY2cDy/f8r0cn25rVEvwXS9QitYJ3e1X5FkHopRAdX+vhzhQkN MIME-Version: 1.0 X-Received: by 10.55.31.160 with SMTP id n32mr4213326qkh.11.1455738502782; Wed, 17 Feb 2016 11:48:22 -0800 (PST) Received: by 10.55.165.198 with HTTP; Wed, 17 Feb 2016 11:48:22 -0800 (PST) In-Reply-To: References: Date: Wed, 17 Feb 2016 14:48:22 -0500 Message-ID: To: Levi Morrison Cc: internals Content-Type: multipart/alternative; boundary=001a1147a8ec5852fa052bfc8864 Subject: Re: [PHP-DEV] [RFC] Traits with interfaces From: kgessner@etsy.com (Kevin Gessner) --001a1147a8ec5852fa052bfc8864 Content-Type: text/plain; charset=UTF-8 On Wed, Feb 17, 2016 at 10:26 AM, Levi Morrison wrote: > I want to add my personal experience with traits: every time I create > a trait it is to implement an interface. Here is a publicly available > [example with OuterIterator]( > https://github.com/morrisonlevi/Ardent/blob/master/src/Collection/OuterIteratorTrait.php > ): > > [snip] > > I can see how it would be nice to allow the trait to officially > declare that it implements some interface (in this case Iterator or > OuterIterator) which would require that the trait has fully > implemented the required methods (or declared them as abstract). This > would be a small improvement but helpful. > > I am less certain about the classes which `use` it automatically > inheriting the interfaces. To clarify: I am neither in favor or > against that part. Or at least at this stage, anyway. > I don't think there is enough benefit from allowing traits to declare interfaces, but not propagating the interface out to classes that insert the trait. It does provide an extra bit of enforcement on the trait's methods, but the real value is in making that contract a part of the classes. In what situation would a class that inserts OuterIterator not want to declare the Iterator class? If every class that inserts the trait would also declare Iterator, it's needless repetition to require that both the class and the interface. I assert that there is no useful case where a class would not want an interface declared by one of its traits, and this RFC proposes the same. --001a1147a8ec5852fa052bfc8864--