Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112302 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57205 invoked from network); 26 Nov 2020 17:27:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Nov 2020 17:27:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E94181804DB for ; Thu, 26 Nov 2020 08:53: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=0.4 required=5.0 tests=BAYES_20,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from processus.org (ns366368.ip-94-23-14.eu [94.23.14.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 26 Nov 2020 08:53:17 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by processus.org (Postfix) with ESMTPA id C1D395101324; Thu, 26 Nov 2020 16:53:15 +0000 (UTC) To: David Rodrigues , PHP Internals References: Message-ID: <265e9893-f82c-39f2-3323-2854b246658d@processus.org> Date: Thu, 26 Nov 2020 17:53:15 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: processus.org; auth=pass smtp.auth=pierre-php@processus.org smtp.mailfrom=pierre-php@processus.org X-Spamd-Bar: / Subject: Re: [PHP-DEV] Traits "implements" support From: pierre-php@processus.org ("Pierre R.") Le 26/11/2020 à 17:50, David Rodrigues a écrit : > Hello! > > Now with PHP 8, traits supports abstract functions that should be > implemented by the class that uses this trait. > > So is it now possible that traits could have support to implements too? So > when class uses this trait, it will be an implementation of X interface and > will have to implement methods based on it. > > interface A { > public function x(); > } > > trait B implements A { > public function y() { $this->x(); } > // public function x() still not implemented. > } > > class Z { // impliticy implements A interface due to B trait. > use B; > public function x() {} // required! > } > > > Atenciosamente, > David Rodrigues > Hello, I'd love this too, but I'm not sure what would be the static code validation behavior, knowing that you can rename methods of traits when using them in a class: should the trait method not be validated ? Should the final class be validated after the trait has been used, meaning that if a method name change, the final class must re-implement it ? -- Pierre