Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91259 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87922 invoked from network); 17 Feb 2016 20:01:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2016 20:01:36 -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.41 as permitted sender) X-PHP-List-Original-Sender: kgessner@etsy.com X-Host-Fingerprint: 209.85.192.41 mail-qg0-f41.google.com Received: from [209.85.192.41] ([209.85.192.41:36497] helo=mail-qg0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/5E-17120-F91D4C65 for ; Wed, 17 Feb 2016 15:01:36 -0500 Received: by mail-qg0-f41.google.com with SMTP id y9so21005772qgd.3 for ; Wed, 17 Feb 2016 12:01:35 -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 :content-type; bh=1zN0qlgtElGLJj/K4HeD2/G49oCFV9tpOpAbG4QsY2c=; b=XHT65ykkxQcGgdcGuM00oS36wRjTqyqsr28M1hGA4a2umA8zQYgTuKCYJtd6ATIBHV 5CSqBDBOXHLe/X+y+HMJCOI05Vz1zhi6FXybKisa3WFnLy4DRT/scSl1veVh7O8bPQMB l6BFKH9Rk2uGTZFAYloZSnraWQDDX1tReSNso= 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:content-type; bh=1zN0qlgtElGLJj/K4HeD2/G49oCFV9tpOpAbG4QsY2c=; b=eBmeSilz0jHjQWSIn31o3vkU6CPxYiPiF7SSPSOGSrnbF2hzZEJiS3l+QqxIr3m6sd fsiLj17ka2bU3s3ob8tPuy2lAiYyZ5a83RJLU26Q9sDTOCEWhYNNYHc5Ipfoqq4AP8+t 9IgiYzxB0GeAQAfAAHf5Cg4pYJwKR/5jMFQ9YnJP39kQuTIctJcn4LIFWA19Gaxv3mmO vuGpHBXC/GX7/nCeookHWLmS96MQGpggy34PlIImss9UgrflJK0I24IYbnfPOfvS6Kw+ CAPKe1f8+UAMLDf74FudBPFGLonkacU8Lkd51S0ed4PsshwPhbQX2aokPM15jcEOkJor 0AxA== X-Gm-Message-State: AG10YOREjz6CqRD5iLQYZKsh6Mr8CCHM1S7Ah1AtNfQWY35Na6rQS/m39CcXYqNYjGJ1UzobTJpSP6o5i1ZuU54M MIME-Version: 1.0 X-Received: by 10.140.254.9 with SMTP id z9mr4504420qhc.5.1455739291628; Wed, 17 Feb 2016 12:01:31 -0800 (PST) Received: by 10.55.165.198 with HTTP; Wed, 17 Feb 2016 12:01:31 -0800 (PST) In-Reply-To: <56C4B92E.9020306@fleshgrinder.com> References: <56C4B92E.9020306@fleshgrinder.com> Date: Wed, 17 Feb 2016 15:01:31 -0500 Message-ID: To: internals Content-Type: multipart/alternative; boundary=001a113a74f65d11c6052bfcb79a Subject: Re: [PHP-DEV] [RFC] Traits with interfaces From: kgessner@etsy.com (Kevin Gessner) --001a113a74f65d11c6052bfcb79a Content-Type: text/plain; charset=UTF-8 On Wed, Feb 17, 2016 at 1:17 PM, Fleshgrinder wrote: > I agree with the others having a class implementing the interface > automatically just because a trait implements it is not a good idea. > The class should always decide on its own if it wants to implement an > interface or not. > I'm not clear on the motivation for this principle. Is there anything I could read up about explicit vs implicit in PHP design? > > Note that the situation with true inheritance (extends) is very > different compared to the usage of a trait. When one extends a class > it automatically agrees to the "is a" contract. In other words, it > MUST implement all interfaces that any of the parents implements, > otherwise it cannot fulfill the "is a" contract. > > Another thing that is important to note is that a class might want to > use a particular trait but does not want to implement the interface in > the first place. > What cases are you thinking of here? I'm trying to come up with an example where a class that wouldn't want an interface provided by a trait it uses. > > That being said, the actual thing one wants is that the IDE helps us > to not overlook a method that we might forgot about while implementing > that default trait for an interface. This is something where PHPDoc > shines and should be used for. Actually I proposed this already for > the upcoming PSR-5 that covers PHPDoc. However, that feature might be > out of scope for the PSR. > > TL;DR Create feature requests for PHPDoc software (IDEs etc.) to > support "@implements InterfaceName" (and maybe "@extends ClassName") > in order to fulfill this use case and do not change the language. > I don't use a PHPDoc-aware IDE (I'm old fashioned), so I'd want any change to be part of the language itself, where enforcement is guaranteed. > > - -- > Richard "Fleshgrinder" Fussenegger > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2 > > iQIcBAEBCAAGBQJWxLkuAAoJEOKkKcqFPVVrJe4P/1Qz43ey6g7aEQUegOyfuoIQ > GokTsUS42pedbGr3mYdf2/qatFp+/CyMv4FovLX4+m2wRn10AFmeYENi4RcFItb+ > ILiiTynMPrQqV3IGgujHYwNDA/J4Qo3mn8FnNcLWl6nz3bFaxPTu2ygEgPYWz9Yu > Y9qBcPqdQn1o/ipUf9D+thFzDKtCqCAEoPmBcCQWwCIK3yiUfqbkOzNBqynlE/qK > 9lhCrF3+5XSrTkxl+gwzm9YUEA/EO7BUO6i8bXex9ZPDBSfRQet29DYUR9pGu8/p > VMyHd9w1H60QCequreW4kZwixO010jKAO9EUwXMU/+yYV5C2Iy/5eRcKVERgLT75 > BtKC0eNRW6kw58ZnRRYiVLfqlCZDQYU2kQ0S7R4Nym04agOZ2tdneKFgEYn3uo/k > qNzaTLLYRbPNnfyYcZ4DRtsI82OIHrw2x8U9KrOU48fnvtLeW3+nShwXFK1oLU40 > hsB+jU28OvsSohBngwAQn2z7nIJVqLiyVCnWj48omtzBJ7GesfIUt2Cu1cG9yK+/ > EeCVIXhI9m1W5Wf2k8oEaB8Amy5rZwW6b1PA+JHJ+aYQjvG3CY6ipSka/RhRqAgf > ABTLX8k1a7Hdd8kXheC1vIhhjLgIWijW59Bzg/oxN4RiRe2c90s4e857VN+fEBfK > 6xVA5XfwMQ2N4tn+P2Zq > =7rF9 > -----END PGP SIGNATURE----- > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113a74f65d11c6052bfcb79a--