Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91325 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52107 invoked from network); 19 Feb 2016 19:13:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2016 19:13:41 -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.170 as permitted sender) X-PHP-List-Original-Sender: kgessner@etsy.com X-Host-Fingerprint: 209.85.220.170 mail-qk0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:36215] helo=mail-qk0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/F0-36948-36967C65 for ; Fri, 19 Feb 2016 14:13:39 -0500 Received: by mail-qk0-f170.google.com with SMTP id s68so34510477qkh.3 for ; Fri, 19 Feb 2016 11:13:39 -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=fvtHCvFCcPSS1FV+pB8iEQe/fyVK/+YoQdwQE7C1Cy0=; b=X2tdJNxgHu8u5ea1/1nX4+Q7/bL98nERJ0kXHEo+YdEd6IUKUBgjrZKLe7jIt0ItlF Cm1D7cMcwaTLsrRG435Kuwzv8XQVVyLN+11NEo6RzvHgOdq8dw57hHRMEcZNuNN0rwbD 5v7SkFqSJo1ZpbVB+8V89GdXgB42G+aOnpJMQ= 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=fvtHCvFCcPSS1FV+pB8iEQe/fyVK/+YoQdwQE7C1Cy0=; b=Qj3KQv/XXn+Pz/4m2hdvTfgWwD+coHQasc22bTtgpXO+eLV7Hg+rSWXfQ2SKScxgpC 48M6I1fMOmxvMl8ZvgV3k8d3B8d9j9K0TY2zWi4BhhXy6PsBjrdOJEBMK7zP4L61EcAg I1Z2f85vC09+uqrpuMQ/F9vT8MdbdkDq7obpGB/7QUwLM+IS3d07kkExRZ7vnDwUCQkO 9hRXCSSjXPJq3QBka8Ep9/uC19smky8xkq2ROo6T+fSuzG6yj5tz92AUQierP4MH/re3 GL1LTDa5nZrFnQ0MJn51i585fIxppW8tyeGVqvKoxwOKSwAkggUQ2uzARhSekbj7YqW8 YU5g== X-Gm-Message-State: AG10YORJp1gvwFejKRSgwpVViAQgUiAF0umEoHnT62UtIgyBIKHAYaWA3ppE67I65AR8yjUzIrcApqATliQM95W9 MIME-Version: 1.0 X-Received: by 10.55.82.137 with SMTP id g131mr17869527qkb.66.1455909214107; Fri, 19 Feb 2016 11:13:34 -0800 (PST) Received: by 10.55.165.198 with HTTP; Fri, 19 Feb 2016 11:13:33 -0800 (PST) In-Reply-To: References: Date: Fri, 19 Feb 2016 14:13:33 -0500 Message-ID: To: Chase Peeler Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=001a114a87d4886fcf052c24475d Subject: Re: [PHP-DEV] [RFC] Traits with interfaces From: kgessner@etsy.com (Kevin Gessner) --001a114a87d4886fcf052c24475d Content-Type: text/plain; charset=UTF-8 On Thu, Feb 18, 2016 at 2:16 PM, Chase Peeler wrote: > > > On Thu, Feb 18, 2016 at 1:29 PM Nikita Popov wrote: > >> HHVM already supports "trait Foo implements Iface" with the semantics that >> the interface is also implemented by the using class. >> >> Additionally HHVM supports a notion of "require implements Iface" which >> means that the using class must implement this interface. >> > This was mentioned in the original traits RFC, but never got voted or implemented: https://wiki.php.net/rfc/horizontalreuse#requiring_composing_class_to_implement_interface It's orthogonal to this RFC. > >> Why should it matter if the class using the trait actually implements the > interface? If the person just wants the functionality, but, for whatever > reason, doesn't want to actually implement the interface, why should it > matter? > > I think the trait should HELP the person implementing an interface. The > trait should be able to say (whether via comments or an engine enforceable > construct) "Hey, I've done everything needed for you to implement this > interface" but, at no time, should the trait force the class utilizing it > to interact (via extend or implement or use) a 3rd artifact. > > trait foo implements myinterface {} > class bar { use foo;} > class baz implements myinterface { use foo;} > > Both of the above should be legal, and $myBar instanceof myinterface > should return false; > This is Proposal 1 in the new draft of my RFC: https://wiki.php.net/rfc/traits-with-interfaces Does that proposal sound like what you'd want? Cheers -- Kevin > --001a114a87d4886fcf052c24475d--