Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101952 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20047 invoked from network); 2 Mar 2018 01:39:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Mar 2018 01:39:10 -0000 Authentication-Results: pb1.pair.com header.from=mail@pmmaga.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mail@pmmaga.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain pmmaga.net designates 149.210.149.69 as permitted sender) X-PHP-List-Original-Sender: mail@pmmaga.net X-Host-Fingerprint: 149.210.149.69 outbound0.mail.transip.nl Received: from [149.210.149.69] ([149.210.149.69:36472] helo=outbound0.mail.transip.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/56-16517-A3BA89A5 for ; Thu, 01 Mar 2018 20:39:07 -0500 Received: from submission4.mail.transip.nl (submission4.mail.transip.nl [149.210.149.124]) by outbound0.mail.transip.nl (Postfix) with ESMTP id 3zssQv10SYzynNR for ; Fri, 2 Mar 2018 02:39:03 +0100 (CET) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by submission4.mail.transip.nl (Postfix) with ESMTPA id 3zssQq1PFqznTX1 for ; Fri, 2 Mar 2018 02:38:58 +0100 (CET) Received: by mail-wm0-f52.google.com with SMTP id w128so347464wmw.0 for ; Thu, 01 Mar 2018 17:38:58 -0800 (PST) X-Gm-Message-State: AElRT7F2WeaYKf/HuvhSxACYJ5bowpvsyi2K54rYAu7NO3JuvVqvQZuv o5BeJEl89imFnJT9YwCXDLr8SMMz2wDsGfRBJig= X-Google-Smtp-Source: AG47ELtWW44J0N5hXniEykHEfNGtMToRiNyswuPsZ+SHwKn1IWVFubLETuxofDYjn3RpsEqeGRL5DT33y6b00GpSsbY= X-Received: by 10.28.164.196 with SMTP id n187mr159483wme.141.1519954738149; Thu, 01 Mar 2018 17:38:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.145.166 with HTTP; Thu, 1 Mar 2018 17:38:37 -0800 (PST) In-Reply-To: <71120afe-503a-c83b-debd-a7913192d80f@gmail.com> References: <71120afe-503a-c83b-debd-a7913192d80f@gmail.com> Date: Fri, 2 Mar 2018 01:38:37 +0000 X-Gmail-Original-Message-ID: Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="94eb2c074e463e00a50566640a23" X-Scanned-By: ClueGetter at submission4.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=pmmaga.net; t=1519954740; h=from:reply-to:subject:to: cc:references:in-reply-to:date:mime-version:content-type; bh=5tYrFtkogixd7RBwn5abChShsM/CQZV4f8Mn9w4NluA=; b=SNRlEsEMa0S03lZbB7Y/qYx4lqseaNtii1mqvngZD+BRpa8JNJ42B2icQWwlzaA/PooX7p GMXjfg9ihGmtaLrF/BVcbYWgOBxROHR5NgYVI/7sXqXrNReN9LwNvVpURgY48n+XBSlyDU MY5VeYDCi4Hjw3W7pl3dxz+PyifTclEp8/PKXDq3xmuQtJHLrZmPN9PbHwMuS5Z02FC1ey 9NRIZp0WywFJpn72zPNPO+VBoF+Ym0imm09RFBXFxQGiOYqBGwq1fjeozmcYCKbv0Q+SW1 i4RulWvm8BXS3E7v3gLVSG1yc3Dao1OkA7DFMjMPcYj0xLWfVzt0O+EE3cKvYg== X-Report-Abuse-To: abuse@transip.nl Subject: Re: [PHP-DEV] Traits with interfaces From: mail@pmmaga.net (=?UTF-8?Q?Pedro_Magalh=C3=A3es?=) --94eb2c074e463e00a50566640a23 Content-Type: text/plain; charset="UTF-8" On Thu, Mar 1, 2018 at 11:04 PM, Rowan Collins wrote: > > What *can* break an interface's contract is changing the *visibility* of > the pasted method using "as protected" or "as private". This would need to > be captured somehow while composing the class, probably producing a > compile-time error, just as an explicit "implements" declaration would. To add to that, the receiving class can simply replace the trait method. So picking up from the same example: bob(); $b->bib(); Bibble is no longer Bobbable. Currently, not even an abstract method on a trait enforces anything on the receiving class. See: https://bugs.php.net/bug.php?id=75449 With that said, I have started some work on "Implicit Interfaces". It allows a trait to implement an interface in the sense that as long as any class actually implements a given interface, that class passes the type check (and instance_of() and ReflectionClass::implementsInterface(), is_a(), ...). Basically allowing duck typing. It has some similarities to https://wiki.php.net/rfc/protocol_type_hinting, you can check the current implementation on https://github.com/pmmaga/php-src/compare/implicit-interfaces Regards, Pedro --94eb2c074e463e00a50566640a23--