Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91269 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50702 invoked from network); 18 Feb 2016 15:12:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2016 15:12:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=chasepeeler@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=chasepeeler@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.182 as permitted sender) X-PHP-List-Original-Sender: chasepeeler@gmail.com X-Host-Fingerprint: 209.85.214.182 mail-ob0-f182.google.com Received: from [209.85.214.182] ([209.85.214.182:33971] helo=mail-ob0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/E2-32469-24FD5C65 for ; Thu, 18 Feb 2016 10:12:02 -0500 Received: by mail-ob0-f182.google.com with SMTP id wb13so71656047obb.1 for ; Thu, 18 Feb 2016 07:12:02 -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 :content-type; bh=JmfsGfUvenGPAIj4EvIgdRH6VnJeyUutxbbnvF4foKw=; b=VaGsHUYl9MI7wjosaLs/Bnp70IcRAzvaDA+S3+wS9lmSCB2LGWhKM7Resszy2i9pyt DWi2SvqKZt5oORWJRDdL0622eU99HLMl48hBQDhO6zx1X9mcM9wBgte5LHcDdVAyhprE J2X5gQpatXZg4/FHH+eOYktY5GHWeZ9jS/uSDEHVjECfRtFnxybvq2jIgWKRBb6ECGAO SiDqRy3BWTL70kpMZIjzJuP3HrBqzN8/KrnF9S9xRsxYbDZ+5bLLGuScXyLvxSS2H2wg zOTXP9qU6Cgq4yropRVNQztVSNxommRd4PTunEY5gUZ1Jhj/SZxqVh0KpnHOqFuaQnk0 YBPw== 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:content-type; bh=JmfsGfUvenGPAIj4EvIgdRH6VnJeyUutxbbnvF4foKw=; b=m9sXoOdOjfju46TDUsn/P3D8tSuX3aFr8skvUIrRId+iB/kplFb0T9QDme2EYI/6OC t+eXXsCZUtS4/sNBkhKwZXwqMAWvWCUFRCwVutLDxU8xx4EJRfNy5LT8wfsy7tKr9sJB uZJaHTEPjDgwphTTU2rpnAOg+qTsxchwXU2+xrLCFU6MktFgeVvVYtG4XbUGNYduC+gu jmKgerbrWDicB0UARfo9vSaE2/RFbLLPXxLDx5ccI2TuJ7rbagZosCsQEEZ/Ks6ZiDXu wj1TAPNGv3GU+mET5Dt4GlO7BqXilkY+mI5+gfMz1CiKRs4mrtrTtG/n+F7NQUhQCC1e UfAw== X-Gm-Message-State: AG10YOS/YaXA1aOZdF2E2lDYfjMkuJGzQXq2xq5hF7IOcyDh6rZRpZxxnR6NkEhaQ9okGS6PYzELg4MaJGMpxQ== X-Received: by 10.202.219.7 with SMTP id s7mr6531152oig.46.1455808309324; Thu, 18 Feb 2016 07:11:49 -0800 (PST) MIME-Version: 1.0 References: <1455791700.2381299.524770354.2D139723@webmail.messagingengine.com> In-Reply-To: <1455791700.2381299.524770354.2D139723@webmail.messagingengine.com> Date: Thu, 18 Feb 2016 15:11:39 +0000 Message-ID: To: Larry Garfield , internals@lists.php.net Content-Type: multipart/alternative; boundary=001a113d550823704f052c0cc99c Subject: Re: [PHP-DEV] Re: [RFC] Traits with interfaces From: chasepeeler@gmail.com (Chase Peeler) --001a113d550823704f052c0cc99c Content-Type: text/plain; charset=UTF-8 On Thu, Feb 18, 2016 at 5:35 AM Larry Garfield wrote: > On Wed, Feb 17, 2016, at 01:05 PM, Kevin Gessner wrote: > > On Wed, Feb 17, 2016 at 9:25 AM, Kevin Gessner > wrote: > > > > > Hello internals team! I'd like to propose an RFC to allow traits to > > > implement interfaces. > > > > > > > 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. > > Thanks, Kevin. > > At the risk of a "me too" post, I would also be in favor of allowing > traits to declare an interface but NOT in favor of a use-ing class > implicitly implementing the interface as a result. I'd rather the class > still need to self-declare the interface; that it uses a trait to > fulfill that contract is irrelevant to the outside world. > I agree, in theory, but I also think we introduce confusion. Every other OO rule says you get "everything*" from what you are using (extending a subclass gets you all the parent classes, implementing an interface that extends an interface gets you the parent interface, using a trait that uses a trait gets you both traits, etc). Perhaps we need a different keyword? trait foo providesfor myInterface { } I'm not sold on that keyword, it's just the first thing that came to mind. *I know you don't get private methods and properties in subclasses, but that's something dictated by the class itself. The class says "you can't have these if you extend me" instead of the engine saying "you aren't implementing that when you use the trait because it's a trait" At that point, the benefit becomes two-fold: > > 1) Communicate to users of the trait what the intent of the trait is: To > provide the boilerplate for some interface, or portion thereof. This > could be covered by PHPDoc, potentially, and I've suggested the same for > PSR-5 before. > > Agreed > 2) Ask the engine to do a syntax check on the class to make sure I did > not forget something or screwed up in some way. That is, not fulfilling > the interface on the trait would cause a parse error (or an error in my > IDE), forcing me to fix my bug before I even try running it. PHPDoc > would NOT have this benefit. > > Thus I feel this addition does have value that a PHPDoc alternative > would not. > > Good point. I was of the opinion "we can just use comments to declare intent," but hadn't really thought of using the engine in this way. It makes sense. > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- -- Chase chasepeeler@gmail.com --001a113d550823704f052c0cc99c--