Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116817 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70818 invoked from network); 5 Jan 2022 15:14:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jan 2022 15:14:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 151351804C3 for ; Wed, 5 Jan 2022 08:21:33 -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.7 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, NICE_REPLY_A,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-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.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 ; Wed, 5 Jan 2022 08:21:32 -0800 (PST) Received: by mail-wm1-f46.google.com with SMTP id m14-20020a7bcb8e000000b00346da381d59so840085wmi.5 for ; Wed, 05 Jan 2022 08:21:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=mWQJZhN8MVv734+5tcezKW5WiFvbNCB0Okp7kAZi+uw=; b=nFPa4RRXlocjs50yZDwaZk7Y+1bHItXiUldARqglvv0UaqLUxeFogF7BdFoMF9bfwW JqFM0uclLbmqdIvwRwz0VXFR9vfA0TmzOk2uApoPwz+TgD+En8RbycYOy4Uz24MNXBiw 7+O734XXI1mGQZvBoZEfQstbcQfrRqv+Ter9BfgPSZluqfyeBdDl8Ax1oQYzClOlhA6u Vfy6RDXXwSqOX5Up024tDHt/jRZm35+fBl39I536VYe7lXcGrHTvowdbMqxzc6xkIlem Cd7EZoAysiFk/FeqDHE4KC+PvsKI4IxGM3wNLUt8vs/gJYlRXMpQiIkcApgXmjQ2Ob62 xIbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=mWQJZhN8MVv734+5tcezKW5WiFvbNCB0Okp7kAZi+uw=; b=HR54/37okTDaG06Haq4Ijn6TokC/ueMpRsfT1DuUQ9N+tM/7OXomeAUulni2cLcaSG dHcW4fId30wNg/ncNcftF6cBSRxgLu2Gq4iyubH8Rur7n1PwJmCiaCKWeCa99dXawf4D 2IG6gjUxw9ZgF4ZlrHJUeuSF8wgcBeQMZfphEoO4lVnOCjV9pN2mwL4oNA8Kzx1j+yPX OM/GZfjDIxgpt5jTll5QxR7iuArEJLxSElU5+ro+IyzoWbrn3gdQsaEtSf7ckqr5LrvY m+nMK0O1SIDJGfljRXWnssN0YUq2dm99G5G575JDX/jkfHRXT+GI9Kj39yvWeOkG53f+ GUPA== X-Gm-Message-State: AOAM531gGGcidPaA4jVbEpeX1dN8u/VXvqceb0my5S2bBnDeB2Ozk1GO dRJ0//RZutivrNZauAre7pzIqyd1PPU= X-Google-Smtp-Source: ABdhPJz2UBZs6jFxkDSDvxiDLduXBOkAHRQ1NMvp+34AYE5xnTZ3l8NLYv9v3E4IZrpJidbc5pqu+Q== X-Received: by 2002:a1c:1fca:: with SMTP id f193mr3025610wmf.56.1641399691244; Wed, 05 Jan 2022 08:21:31 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id 14sm44958319wry.23.2022.01.05.08.21.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jan 2022 08:21:30 -0800 (PST) Message-ID: Date: Wed, 5 Jan 2022 16:21:29 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-GB To: internals@lists.php.net References: <1641335738.195767637@f174.i.mail.ru> In-Reply-To: <1641335738.195767637@f174.i.mail.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] RFC: Trait expects interface From: rowan.collins@gmail.com (Rowan Tommins) On 04/01/2022 22:35, Kirill Nesmeyanov wrote: > Since «traits» are often an indicator of not very good code and many may not use them quite correctly, for example, as helpers, I suggest adding support for the `expects` keyword to indicate that the trait is part of the code decomposition taking into account ISP. Hi Kirill, I'm a little confused what problem this is trying to solve - in what way does using a trait in the "wrong" inheritance hierarchy constitute "abuse"? On 04/01/2022 23:10, Bruce Weirdan wrote: > Prior art: @psalm-require-extends and @psalm-require-implements Psalm > annotations:https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-require-extends ... and on 05/01/2022 12:36, Saif Eddin Gmati wrote: > ref:https://docs.hhvm.com/hack/traits-and-interfaces/trait-and-interface-requirements The examples in both of these cases appear to be using the requirements primarily as short-hand for listing abstract methods in the trait. For instance: interface FooInterface {      public function doFoo(); } trait SillyFooTrait {     require implements FooInterface;     public function doFooTwice() {         $this->doFoo();         $this->doFoo();    } } Is essentially equivalent to: trait SillyFooTrait {     abstract public function doFoo();     public function doFooTwice() {         $this->doFoo();         $this->doFoo();    } } In other words, the requirement is there because it is actually a requirement for the trait to work correctly, not because of some perceived "correct" use of the trait. This doesn't seem to match your reasoning for proposing the syntax, so maybe I'm missing something? Regards, -- Rowan Tommins [IMSoP]