Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120779 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91500 invoked from network); 11 Jul 2023 16:48:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jul 2023 16:48:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B3C8918050B for ; Tue, 11 Jul 2023 09:48:19 -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 out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (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 09:48:19 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 089395C01E2 for ; Tue, 11 Jul 2023 12:48:18 -0400 (EDT) Received: from imap45 ([10.202.2.95]) by compute4.internal (MEProxy); Tue, 11 Jul 2023 12:48:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=1689094098; x=1689180498; bh=0BTXp6iKP+ edloNWfTMku+yJyJuAdK/h6qDUA+KoSmc=; b=c3q7/ehdtgyoJudd5IzwhvagZf rMKHUOKSGQahH9Davsxffu3mDDq+dOhi1rdh9eun6t04kScwfGVIekjDAjWWUk/3 mpGaZXKNqX3f6nv9aTzIzwQ4eTeMkcHR23kxAGDPLsvfumE5W56u8G7j4cQvW0ny EgzQa8MKFQgp1HHvcO0wujpnbz22naftXsholbqnRc2TnhQhm2Gpf2yZMLixNXPu zwRbdUW30d7a8wOg50SEKOeM8ZoZHtD0Zb6BvXv+1J4yQbtC0pnPqJaaHuSgBwiT ESjF/vuRfF4BV8Rd4XLTaHLKuSTNmsSchUi2BdbJQzgYVj1ZmSQeJhDD1bSQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1689094098; x= 1689180498; bh=0BTXp6iKP+edloNWfTMku+yJyJuAdK/h6qDUA+KoSmc=; b=I M0jl4rj6yjicAZmZfkr6t0SmbhE1cSd77bS/B6j7BNDVeYzKaNG7h6UI1g9rMMnY qkSJj+tnpWb2jzQ84dlD72GxWu3hlSvXGBwhdNdO2ZWDbHywyMKfULEEzEnEDPdi YAxHN//gAzWVU0KN+MulKdUuH/ykvvOiWnOPKkdxLkZZvkqknYZO8UamLo00fUfP GFDZ4sNfwY0OJdHnNEEnOYpJrFBXePinoe5eyXW36nLjqC3qY9mB6lY26Rw83pld AJtj9KuyYdIU3RbABC2sHfAJ0mOS8DNvMJSwQBJ/Rue4QXfCAgpaFLczWmdcyZOU q174NEBXXoXsatKnBn2Ug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrfedtgddutdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhephfektdffgffhkeeiudehvdehfefgfeehuefgvdel teetkeetgfetjeeiledtleeknecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehg rghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B6727272007A; Tue, 11 Jul 2023 12:48:17 -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: <66e67efa-1f41-4971-b070-7785f99ab286@app.fastmail.com> In-Reply-To: References: <3a3e7781-c2b4-2880-8048-d19458ac287d@heigl.org> <308d32d6-c145-4f8c-8779-101a696b60a0@app.fastmail.com> Date: Tue, 11 Jul 2023 16:47:57 +0000 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Interface Default Methods From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 11, 2023, at 3:16 PM, Robert Landers wrote: > On Tue, Jul 11, 2023 at 4:36=E2=80=AFPM Larry Garfield wrote: >> You have to check your vendor folder for an interface, or trait, or a= bstract 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 a= bstract classes, you need to add 4: BazBase, FooBazBase, BarBazBase, and= FooBarBazBase. > > I guess I don't understand what the interface is solving if you're > creating an interface _and_ a trait, why not just create the trait? It > sounds like you're coupling your interface to a specific > implementation and trying to get multi-inheritance out of PHP. This > seems like a design issue, and this RFC seems like a back-way to > multiple inheritance. Why not just allow multiple inheritance? > >> And that's assuming you're even in control of the base classes; you m= ay not even be able to create all those combinations without lots of cop= y-pasta. >> >> Abstract classes are basically vestigial since PHP 5.4, and have no u= se cases: > > As a user of abstract classes since the early days of C++, I disagree. > > I'd love to see a concrete example, but to me, this just seems like a > bandaid on an architectural smell. Real code I wrote a week ago (specifically, for a series of events in a = domain model): https://gist.github.com/Crell/f5929e2ee44decd4e9353c41874f26c8 Two different interfaces, that I want to be able to check against, but t= heir implementations are trivial. One of them is used in 2 classes, the= other in 3. A base class simply wouldn't work, both because it's seman= tically incorrect (these events are not all "special cases of" some comm= on definition, that's not the data model), and because then I couldn't h= ave the class that uses only one of them. Traits, for now, are the best= solution, and this is an approach that gets taken a lot. Interface default methods saves a file, and lets us merge the traits int= o the interfaces. That's basically it. And that's helpful. As for it being "back door multi-inheritance", well, Java, Kotlin, and R= ust all do essentially that now. So we're hardly breaking new ground, d= esign-wise. If anything, it's playing catch up on data modeling capabil= ities, an area where PHP is still sadly very much lacking. --Larry Garfield