Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108164 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54089 invoked from network); 16 Jan 2020 06:03:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jan 2020 06:03:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C93FA180505 for ; Wed, 15 Jan 2020 20:10:21 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Jan 2020 20:10:20 -0800 (PST) Received: by mail-qt1-f171.google.com with SMTP id d18so17814542qtj.10 for ; Wed, 15 Jan 2020 20:10:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=4VvzL+Y6hheUdmSycc1HWeTYmHcKEIOLQdxpgNXhGmQ=; b=KCvd1A4LeeZXnCqRkbN/r2GkRWTS2NBcOFvhiPyVBevnjH75LEg1iEUONLSHjTpFoU dWFZnXS/iWncpS6R8uKJTRRKLcGC3dMF0duK93dL3Cn4Hga4D0TyvSwpB+blZ28k6yPr +7OJ7fK9QR+2v6ZbZSHp79FDAPrSTxLTS6571nzM8c73jCdFixD+thr+jSLYwIc7Nus6 9t0IyJoCEQ56y7H5pN86tdDzYEqm5DJWz3GwFH+Su9XKY+uw7HdF4Tu8/Rf/OUjPIzo1 qndqWzB0Uu0nZm4seJeWZS23PQEXpStNdp6QKOqNR6Wq16ub06YX2QfPMDHQNKQOcjFH Aryg== X-Gm-Message-State: APjAAAXI2yUW1Ur7a9K7ws9DoEpHEYQtmun47ryC6vn28Dl0bu+cltBp Lh6CSx0rMlkgoXBN+8eVZGvWkPXwrgm/jnWkzD4= X-Google-Smtp-Source: APXvYqyU7Quj1N0DKAXGsM93OYdoHL9DbKulGggO8qkkHnp3OEu5S1GTD/28ygAuuwvk7w8+V6wHApoZDyVYdrhF98c= X-Received: by 2002:ac8:209:: with SMTP id k9mr581110qtg.290.1579147817724; Wed, 15 Jan 2020 20:10:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: bishop@php.net Date: Wed, 15 Jan 2020 23:09:51 -0500 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b92eda059c3a00c7" Subject: Re: [PHP-DEV] Properly validate abstract methods in traits From: bishop@php.net (Bishop Bettini) --000000000000b92eda059c3a00c7 Content-Type: text/plain; charset="UTF-8" On Thu, Jan 9, 2020 at 10:15 AM Nikita Popov wrote: > Hi internals, > > I've prepared https://github.com/php/php-src/pull/5068 to fix validation > of > abstract methods inside traits for PHP 8. > > To provide some context, the situation is currently pretty weird... when > you add an abstract method in a trait, you obviously do that because the > trait requires that method to exist with the given signature. However, this > is currently enforced only spottily: > > * It is not enforced in the most common case, where the method > implementation is provided by the using class: https://3v4l.org/SeVK3 > * It is enforced if the implementation comes from a parent class: > https://3v4l.org/4VCIp > * It is enforced if the implementation comes from a child class: > https://3v4l.org/q7Bq2 > > I believe that an abstract methods signature coming from a trait should > always be enforced. > > Conversely, we currently have some very weird code lying around that > instead does a bi-directional signature enforcement if there are two traits > specifying the same abstract method: https://3v4l.org/8Ze2C > > I believe this case should be valid instead, as the implementation of the > method provided by the class satisfies both signatures. > > Does anyone see an issue with making these validation changes for PHP 8? I > can also make an RFC for this, but it seems more like an implementation bug > to me (especially seeing how there's about zero test coverage for any of > this). > +1, for improving logical coherence around traits and for simplifying the engine code. Since @nicolas-grekas demonstrated a legitimate BC break, I think we do need an RFC. That would also give some time to discuss merits of private abstract declarations in traits. --000000000000b92eda059c3a00c7--