Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120776 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80664 invoked from network); 11 Jul 2023 14:36:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jul 2023 14:36:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 102EE1804D4 for ; Tue, 11 Jul 2023 07:36:33 -0700 (PDT) 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Jul 2023 07:36:32 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E6CCB5C00D9 for ; Tue, 11 Jul 2023 10:36:29 -0400 (EDT) Received: from imap45 ([10.202.2.95]) by compute4.internal (MEProxy); Tue, 11 Jul 2023 10:36:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1689086189; x= 1689172589; bh=hyS9V2wRRvcbuEkba2UKajWO0FO+Ehoki+P1lkyoC18=; b=W 4PYFIOCc5N23L3yDTe7YRSnHGlZZ3WhE33MaVD0O3f2NKVX6NT3vCEXEmT3IMGwk du/kN+hlLt4pRM+otsXbQyzzFB9sHtRHbROZjLvlzyhKOy++T8hnmE2fwEEPCpCS BRhhdrrwrfOhqLNK55eIYHdPtwHoTezkRKEVCmtnp7DOn6ivhJiaXWbPV9yclv6/ bcK8hJJ220HS5CZSEDcSorXxATGYle9r0xw7rNSVPICpOVtJBSYKrZnI9vxG74jU IAr/YttyXVbqACObYqLTGIeejdwheUoml1xoVMOVF1ARHtqn22QZLmX6aMjHW4Jg R6C0T4IaYM4NByK5jTqUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1689086189; x=1689172589; bh=hyS9V2wRRvcbu Ekba2UKajWO0FO+Ehoki+P1lkyoC18=; b=HkUkQ14e0z/y5kwK4kkEAa0xefeft tqBT4Xv1xlmxNkwuu8stQdXNlfvvSIOUOLN1TkNbeu/xZDu20irF7QlGMQabJE7r RA+6b08wat80UBIpivCZGKHmkXYxYj2vw9v+4hPkdqxV+PRoE+FKSIgf757yPV81 6uGOLBRoINQpDWX0qQQd/hg8lxGmUghu4D3TpBHJx9n/3bbGzOcTxX5JQekuG1WO 6eTfHS9VR1bz4emQtMjSmEfe1dQFnavBcbPA/tMsY+5kOLCS0fukvt1TJIq/J+sR ui+l76/S2DhLdODA9GvM/SxiGRkotPaaydvir+Rhzv9OiKqWq7HKOpSkQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrfedtgdejlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnheptdffteevffeljeehjeffueejgedtfeefjeegvedvtedu gfegtdevheegiedtkedunecuffhomhgrihhnpehgrghrfhhivghlughtvggthhdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghr rhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A0196272007B; Tue, 11 Jul 2023 10:36:29 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 Mime-Version: 1.0 Message-ID: <308d32d6-c145-4f8c-8779-101a696b60a0@app.fastmail.com> In-Reply-To: References: <3a3e7781-c2b4-2880-8048-d19458ac287d@heigl.org> Date: Tue, 11 Jul 2023 14:36:09 +0000 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [VOTE] Interface Default Methods From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 11, 2023, at 2:04 PM, Robert Landers wrote: >> Not exactly, How you wanna solve by abstract class two interfaces >> which can be implemented using let's say two traits - let's say >> >> interface Foo { >> public function foo(): string; >> } >> trait HasFoo { >> public function foo(): string { return 'foo'; } >> } >> interface Bar { >> public function bar(): bool; >> } >> traitHasBar { >> public function bar(): bool { return true; } >> } >> >> Now I can need to implement Foo or Bar separately or together. >> Using abstract class that would require 3 abstract classes: Foo, Bar, and FooWithBar. >> With this RFC that would require just two interfaces with default methods. > > This seems like a software design issue, not a language issue... > > But 3 abstract classes vs. 2 interfaces + 2 traits seems like a better > tradeoff if you're going to need the coupling anyway. It's more > obvious that you want/require FooWithBar when you want it. If you're > expecting these exact implementations, moving them to the interface > makes it even more confusing. > > I want FooWithBar (iow, I want these exact implementations) > > I want Foo&Bar (iow, I don't care about the implementation) > > You can pass a FooWithBar to Foo&Bar, but you can't pass a Foo&Bar to > a FooWithBar. > > If the default implementation is on the interface ... who knows what > you have, you'll have to check you /vendor folder. You have to check your vendor folder for an interface, or trait, or abstract class. That doesn't change anything. As noted, now consider a Baz interface. For interface-and-trait, you add 2 more definitions. For interface-with-defaults, you add 1. For abstract classes, you need to add 4: BazBase, FooBazBase, BarBazBase, and FooBarBazBase. And that's assuming you're even in control of the base classes; you may not even be able to create all those combinations without lots of copy-pasta. Abstract classes are basically vestigial since PHP 5.4, and have no use cases: https://www.garfieldtech.com/blog/beyond-abstract --Larry Garfield