Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116893 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15066 invoked from network); 18 Jan 2022 18:02:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2022 18:02:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BE99C1804D9 for ; Tue, 18 Jan 2022 11:13:09 -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.3 required=5.0 tests=BAYES_20,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-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 ; Tue, 18 Jan 2022 11:13:09 -0800 (PST) Received: by mail-wm1-f47.google.com with SMTP id 25-20020a05600c231900b003497473a9c4so8284990wmo.5 for ; Tue, 18 Jan 2022 11:13:09 -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=3vQwH6I47cJTGRpuCzj8AitvOYwZGNKiJoQP6MQ21sM=; b=ecWgthZRo2nJ6XE9sNmAebNwjMcVrac39kolndNyPpUKyE86dl5HKyeR5NgWz/CAW0 xdPCW/8Zj+n5vJG3SboQ+eUB2jMMHnfN7AFM7we81wMP8Dhpc/2O0GjUPFuhW4XLtJCF KI70bekr83HBP6qc/tGI5bxBT4BSm/Wec6YYUnaVkb+jjP+Tc9vABLMhMcHDuq1vMU4G 8++Xr0Ddo/hZSQYQD0FNyN7PVxJF8tHdaQM+NWFxRjX4ksoUsJKXTPjaFUcOfBrIdkxf Mb3zCSFR1TQoQE+qieIltztG3/zEiYWUtqVAOhLyzTN371Zfq+dUSfsKhH40FTDAxxFH RIFw== 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=3vQwH6I47cJTGRpuCzj8AitvOYwZGNKiJoQP6MQ21sM=; b=HIqkwIzGo+JlCJjZ8A0wPZiaZixArcxtjAD5ALF7YvmmpgE5Mf+BTZ3Egiob+HcjKz 7TimBKTUjA8WnLn878FN1o2Pi/UR948HrGdT433eU8dJUQTPljhhOSrr0+I/r1ty6Z73 X1CX5EDGuG6K8x1GsV8EI+J/wHxCe1jd/hb/6vAfNLPx7ldGUYNUq5nh1QJ1XVb0Z9Ww 10bUhiblNk2O0DY3vRw5fpmXpmtLtboXhrZwOQJ7opk4LqTZg1AvmmkokFMyzn4WiZEn sZBBTJ4MSb1hLOkSB52Uncbl8KXq0DaHPT1hItvpq5ENPSw7ldGE1BJcqYXkm9a/QV08 xdbg== X-Gm-Message-State: AOAM530yJ+u1xC/TvJ+QWrqZkqTaozD24V3RTyZHamb+oT1V1IaCkrgM /a4V6+N0iVbadFRuPelR8A9cWKt7gFg= X-Google-Smtp-Source: ABdhPJy6o9aDjP/mDGqKgT8sBq+re4ZvODybMakQnjbn8IdTICcEdAgAScmzWQY9MDmwfIZqufWPhQ== X-Received: by 2002:a1c:a786:: with SMTP id q128mr4795876wme.176.1642533187414; Tue, 18 Jan 2022 11:13:07 -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 k37sm4033258wms.0.2022.01.18.11.13.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 11:13:06 -0800 (PST) Message-ID: <3543d7e3-9a26-25f8-8c48-d646431e84a2@gmail.com> Date: Tue, 18 Jan 2022 19:13:06 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 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> <23f78a61-a73e-eaa3-861f-75e9bca28485@korulczyk.pl> <262352f2-a3e6-272d-1118-5455497217a7@gmail.com> <6ABDE9F5-C69A-4FEE-9736-F2DED514184A@newclarity.net> In-Reply-To: <6ABDE9F5-C69A-4FEE-9736-F2DED514184A@newclarity.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Trait expects interface From: rowan.collins@gmail.com (Rowan Tommins) On 17/01/2022 18:03, Mike Schinkel wrote: > > "...I must implement an abstract method" > > "...I must implement all the methods in an interface" > > "...I must pass all arguments declared in a function" > > "...I must pass arguments that are of the type that were type-hinted" > In all of these cases, failing to meet the requirements means the code *probably won't work correctly*. As I've said previously, there are legitimate cases where a trait *uses the methods from an interface*, which is a similar scenario. That use case is currently covered by including abstract methods in the trait, and while "requires interface" could be a short-hand for that, it's been made clear to me that that is not the use case people are talking about. > "...I cannot extend a final class" > > "...I cannot access a private property outside the class" > > "...I cannot change a readonly property after it has been initialized" > These are more relevant comparisons, because there could be valid uses of the class which violate the restrictions; and particularly "final" is often used out of principle rather than specific need. However, they do allow the author of the class to make certain assumptions about how it will behave - for example, if a property is private, you know exactly which lines need changing if you want to rename it; if a class is final, other code referencing it can make stronger assumptions than its method signatures; and so on. The difference with the "trait requires interface" proposal is that I don't understand what advantage it gives the author of the trait. What decisions can you make as a library developer because you've said "users of this trait must implement the matching interface" as opposed to "... can implement the matching interface"? It's possible there is some advantage I'm missing, but so far nobody seems to have presented it. Regards, -- Rowan Tommins [IMSoP]