Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116832 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81425 invoked from network); 6 Jan 2022 15:17:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jan 2022 15:17:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DE3881804B1 for ; Thu, 6 Jan 2022 08:25:17 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46]) (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 ; Thu, 6 Jan 2022 08:25:17 -0800 (PST) Received: by mail-ua1-f46.google.com with SMTP id x33so3907963uad.12 for ; Thu, 06 Jan 2022 08:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1sr9wfP3aIn0E6YyociHA2JELNRIHTHMxyZdJQsFam8=; b=D24nCGrSVG8jK1YatA0BFAuMDbH6GQjVIga0mUYxYnZaZldK//cmgZejx3wLcW5/yC eL8wBNYeRIwpPe4Ef1O/+wNvOdNEeOPXsMNogYFt+gbVCm3uJhdv9EE3PuACOvGUS+rd 9JfmIe28s27dwoEEgRPhP7xvDl+M5OM8ItS81rg1M4kg6yreZEYCywtlrxIuwlCG95ZJ LSMpwkZAkLWakUwxfhYjF2dJayHMevvyuPMKaPv3Xje2zNMWt0nL2lXojH5MlpFfD36B 08yfaV+xYZBJ3pZXeaTYUMezs14r6hyycGObBS6Yy6tg2hIyDYhbJX3qbZfa0hPk7sRW 8etQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1sr9wfP3aIn0E6YyociHA2JELNRIHTHMxyZdJQsFam8=; b=yw6PkoAs9bCTzk8sFoSvXyEWvW1ysr00/0JYgoZyqY5+CLPhfqOovTVv6L64fCGJ9W uP6iBmgUCondtEHH9PqcqN7GffKuktq/5LXR/bYev2BHvBqOxPaN/Rft/BtBsVw+up9i IqpFOYWptp140ko6l5ocZ6MwlZvE8PHF8RyXFW+x603QjkqbsdL3zqZzBEY7ZlknhNUj R+0rGy9dgg11Rf+bKogTZJCqOWVKXeCuWG034Jev9HKA07KtAooag68gxYnnT+gOsxtN RX6+uUsf7xM3hnr7WvfHEfyC54dz59KoZilwWO0vGa/XP32fvLxkCYyYU83hiEQwzvzs wCzQ== X-Gm-Message-State: AOAM533Q0OcEvO81BMfO8jLfSgqDpp61WlpndL5tpNU5VhnR9P2y6vIS l+CMC2Y9WxSVNspGCCmxXSwQeLApYh5iNfU+0eJfSLXA3nU= X-Google-Smtp-Source: ABdhPJy7PIfDqraWr6N/Rho/B4WOb5J6vrQqOBPjK14pLjop9L5RWScLSog1vHs9Ct5P8SCOyU5kWcA5TtKpVTVEZQw= X-Received: by 2002:a67:bb01:: with SMTP id m1mr20489764vsn.48.1641486316664; Thu, 06 Jan 2022 08:25:16 -0800 (PST) MIME-Version: 1.0 References: <1641335738.195767637@f174.i.mail.ru> <5a4aebf8-e592-4517-8930-d18b112ef1fd@www.fastmail.com> <5a99809d-afda-546c-5a11-a4f0f821aa37@korulczyk.pl> In-Reply-To: Date: Thu, 6 Jan 2022 11:25:04 -0500 Message-ID: To: Rowan Tommins Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000cf057f05d4ec5078" Subject: Re: [PHP-DEV] RFC: Trait expects interface From: chasepeeler@gmail.com (Chase Peeler) --000000000000cf057f05d4ec5078 Content-Type: text/plain; charset="UTF-8" On Thu, Jan 6, 2022 at 11:20 AM Rowan Tommins wrote: > On 6 January 2022 15:21:28 GMT, Robert Korulczyk > wrote: > > It should also make it easier for SCA tools to understand > >the code since they no longer need to know the whole project to > understand that method from trait is implementation of method from > interface (which is > >really tricky right now since it depends on context - trait can at the > same implement and not implement the interface, because it depends on class > >where it is used). > > Your other points make sense, but I don't think this one does - there are > no implicit interfaces in PHP*, so all any tool cares about is: > > 1) Does the class declaration say that it implements an interface? > 2) Does it actually contain the methods needed to do so, through any > combination of direct implementation, inheritance, and trait usage? > > Knowing that a particular trait *could be* used to implement a particular > interface without further code doesn't really tell the tool anything - it > still has to resolve the list of methods on the class itself, and test > those against the "implements" clause. This is particularly true if the > class uses the "as" and "insteadOf" clauses when including the trait, which > nullify any promises the trait could make. > > > I think the advantage would come within the trait. If I say the trait expects an interface with two methods, then the tool can act as if the interfaces methods exist in the trait even if they aren't explicitly defined. As others have pointed out, though, you can get the same behavior from declaring the methods not implemented in the trait as abstract. > * other than "Stringable", whose purpose and implementation continue to > baffle me > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > -- Chase Peeler chasepeeler@gmail.com --000000000000cf057f05d4ec5078--