Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116843 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45789 invoked from network); 7 Jan 2022 07:53:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jan 2022 07:53:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 10FA5180089 for ; Fri, 7 Jan 2022 01:01:03 -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_05,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-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 ; Fri, 7 Jan 2022 01:01:02 -0800 (PST) Received: by mail-wr1-f51.google.com with SMTP id a5so5806056wrh.5 for ; Fri, 07 Jan 2022 01:01:02 -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=SCv8Us+CvDujkVJSJheQt0U4e9sFq/wexYxxatOXYfg=; b=cZqE4BJpS9A7x+b0iLuQWXVVAksW7Of11QB2neAuskuQe1fhDrM3Hb8ozFt54AnVRj g1dso9QoB3lJytMcasLjHeJp87sDf5Cf9JbuA7WR0sCaX0xTUroSpX0cGIy0gmIdGKa+ uLUV/o0sE3NnH0q+yiHWW8vwUL2x/A+oetj8ahpT7RkNyQt0MuGTEEu+C2BtBEv91LJ1 jpuWgqSqRNeV6PQzAEJ55DoUrcpVirKP2Ugu4xfZPShXIJVNlfN5okcAedKW0yCY83gB gFRfvnECBG98Vx8GO+S5XLG5d24ck1XIWzg+rPLp9C9h7Ri16ML1QzgZm44l/y1Q1+5w 4Kyg== 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=SCv8Us+CvDujkVJSJheQt0U4e9sFq/wexYxxatOXYfg=; b=O8D8fq+R5QfddQw66OCKDa5kLxASd6RJiCJxBnZvxMhNVQfqO67LAvsHJf37cja50T cDW67cJ/FCiIli5KSTHDIhNjRJJjVxSRhfAWYmOpCoiYg5Rj49t/NNtQW1tBmpfy3ErD M4RoXMq1z2lgEA5KVK1eEuGDscqaWnsBCDFTadBL5DlolVVYlIlAlG7lXK7W/s7OhvE/ CT0pUHz6DuXg5QjGVU7pfscuF9OECtANzoE+S5W00fp3A0BFWx8TLfyVwnQuoi5n0uQU zdIYjGnsYSPAv9b7bf/nnHR3XQFvdhMlh1YkFMK/DbIi/eslDzkln4TLdMMHxV19IMX9 8QtQ== X-Gm-Message-State: AOAM53038Hw83Rsvs4ZCASJOoz6i4Xkq9FOcwYxPp2jKHvTvhM6gcelh Zbvr4TpoDZ1az3nbla9zYj6B2xS4BDI= X-Google-Smtp-Source: ABdhPJyBolLck4p+GuoZXivrH89u/PTXbYESQu6/5lCQmT8LMqCF84viDndziw6f5kgOJOhO1Lssqg== X-Received: by 2002:a5d:670e:: with SMTP id o14mr4196959wru.232.1641546061648; Fri, 07 Jan 2022 01:01:01 -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 1sm4752526wry.33.2022.01.07.01.01.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jan 2022 01:01:00 -0800 (PST) Message-ID: Date: Fri, 7 Jan 2022 09:00:59 +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> <5a4aebf8-e592-4517-8930-d18b112ef1fd@www.fastmail.com> <5a99809d-afda-546c-5a11-a4f0f821aa37@korulczyk.pl> <6E50C348-9452-40E1-ACE8-06DED11C9136@gmail.com> <9070564d-e138-81f6-c757-812d8962416e@korulczyk.pl> In-Reply-To: <9070564d-e138-81f6-c757-812d8962416e@korulczyk.pl> 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 06/01/2022 23:53, Robert Korulczyk wrote: > But there is no easy way to say "`FooTrait::someMethod()` is > implementation of `FooInterface::someMethod()`" that PHP and SCA will > understand. And I think this proposal handles this quite well I'm not convinced it does, actually. Consider the following trait: trait PropertyCount {     public function count(): int {         return count(get_object_vars($this));     } } This trait CAN be used to implement the built-in Countable interface, and it might be useful to label it as such; but does it really make sense to say that classes MUST implement that interface? Even if we put it as a requirement, we can't guarantee that the class will actually use the trait's implementation of the interface, because this would still be valid: class Foo implements Countable {     private $whatever;     use PropertyCount {         count as getPropertyCount;     }     public function count(): int {         return 0;     } } It feels like this use case would work better with an annotation like /** @can-implement Countable */ since it is really just documentation about possible uses. Regards, -- Rowan Tommins [IMSoP]