Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91270 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57616 invoked from network); 18 Feb 2016 17:42:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2016 17:42:44 -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.192.42 as permitted sender) X-PHP-List-Original-Sender: kgessner@etsy.com X-Host-Fingerprint: 209.85.192.42 mail-qg0-f42.google.com Received: from [209.85.192.42] ([209.85.192.42:35990] helo=mail-qg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/73-32469-39206C65 for ; Thu, 18 Feb 2016 12:42:43 -0500 Received: by mail-qg0-f42.google.com with SMTP id y9so43041500qgd.3 for ; Thu, 18 Feb 2016 09:42:43 -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=x586tqBpWxYQwawrN7Jl3+P/7mCRCrtSRkNFJh0maNM=; b=fPq6C57tzF1xg1sOZQgPHNo05FuAc/EOux2ZquDSf4GLutCgWDYNSxXRTs0BHA4RB8 kc2Ry4xwIJco+NA4xtkumgOtLrJyxQjW5qoyFPQ6AhSoYq6K2ZWiLzfnI/IGvEG0+9Im YM4nIAGbIYCtOye8fVEmGpyzLZgZM+XbguHQQ= 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=x586tqBpWxYQwawrN7Jl3+P/7mCRCrtSRkNFJh0maNM=; b=ZB0REuqntg+8WFVRhszE68rS/yaVPy9fu8agwE8AgZJLgCYBb7ApwQrYNc+QIYdNvP tDTEuZV/ATO0lc/BdJevbB0JfGWLwenmfzoyxl9zsq4X1XaFNTQq48NWFLcuHqeVnsNs Sa/qkRrW9WGxzOkESPYv69vkrNFlrbhNAgU43QPMmEvLAB3cA3wUaBaFyQC1K5K7Rzjt sAYPC2ztfcPP9s+UpdrLukXPs4bcgdL0GUMhXJFeL9L/lvah2VjEELpMbVNYc2AY2j85 5C3NcS3T0nlX/nJpqVvvmabZ5e6LBZfCxv21fEdz7fIM03OcpDit//fjlns/XCXj1PB+ 3kFw== X-Gm-Message-State: AG10YOSBYWXv5/D8maz5aXOrGKUkALG8nEbp7WriOrRXQqvYJIWgsDjcmiHMu6pxPTMV0LAjzw9qQwyQo64BCtwG MIME-Version: 1.0 X-Received: by 10.140.254.9 with SMTP id z9mr10898346qhc.5.1455817360831; Thu, 18 Feb 2016 09:42:40 -0800 (PST) Received: by 10.55.165.198 with HTTP; Thu, 18 Feb 2016 09:42:40 -0800 (PST) In-Reply-To: References: <1455791700.2381299.524770354.2D139723@webmail.messagingengine.com> Date: Thu, 18 Feb 2016 12:42:40 -0500 Message-ID: To: Chase Peeler Cc: Larry Garfield , internals Content-Type: multipart/alternative; boundary=001a113a74f6a68f09052c0ee438 Subject: Re: [PHP-DEV] Re: [RFC] Traits with interfaces From: kgessner@etsy.com (Kevin Gessner) --001a113a74f6a68f09052c0ee438 Content-Type: text/plain; charset=UTF-8 Hi Chase and Larry, On Thu, Feb 18, 2016 at 10:11 AM, Chase Peeler wrote: > On Thu, Feb 18, 2016 at 5:35 AM Larry Garfield > wrote: > 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? > I'm wary of a new keyword, particularly because this situation isn't really that different from what "implements" means. I think if we wanted to go down the route of new syntax, I'd want to expand the `use` statement for traits to include or exclude any interfaces that a trait provides. But I don't think a syntax change is worth it for this feature, for the cognitive and language overhead. > [snip] > > 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. > That makes sense -- I like having the language enforce intent, rather than just comments (which always rot, in my experience). > > > > > --Larry Garfield > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > -- Chase > chasepeeler@gmail.com > --001a113a74f6a68f09052c0ee438--