Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120204 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89462 invoked from network); 6 May 2023 15:20:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 May 2023 15:20:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AE209180044 for ; Sat, 6 May 2023 08:20:54 -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,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 out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 6 May 2023 08:20:54 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A4EAA5C00FD for ; Sat, 6 May 2023 11:20:53 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Sat, 06 May 2023 11:20:53 -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=fm3; t=1683386453; x=1683472853; bh=bnhk8lSGBe oWX8+qQ61KjIDdXtZs90lDBoS636NuUrw=; b=bnSSq0dMftG7G9FedCbEAkw501 ZkxMTdV7MAxoZhzIHGSV7JGVk5Mgh3nNuzkUaPKWvJHTAeJSdgE3P9KXW0X19sLt NxgTZ1PkRNr6x+HypN82pJb9+XOP90MHZL5rGHEIqPxrem0P5yePRNiFl4VFKjBz C9tiPwl9uDhpitcYBj0IplsIJkFzEd1Hq+Gk+rdlEy+eugEV+siH8fgU3KBXi3GN B8lEScjm8OO+T6MldmoeYSNex1hiVh0QVA8wu94ytR1XKZI48EMF29BRpfa2y53b bme4IShNe6xMi8OQ5gMmptCzUQktZaqnHpOFsZZCwuvK6fvuKJam9oAtuBpA== 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=fm3; t=1683386453; x= 1683472853; bh=bnhk8lSGBeoWX8+qQ61KjIDdXtZs90lDBoS636NuUrw=; b=E lZ7TFG/8GG2sGRttLx9gh8L/g9+ktWtSasmgla9/tRCXP+m6m7Abfq660bzDWrol p9PkZFW0tvUl7hanoBrtVyHKwIghq9sAf8GIa3jlWllLcNO6umIs6hWisP0XWSKC puuB6oHlzfpSFBwuo/7rIk55aul56DJwtgcuPqqFZMYGfpATgGlIm0MJAuLADIqR DYM3/6VRHg2Wi7ebQZcySUu3S+PvLsNzICFsMpB5dEpT4YkNVuBPCPSWdZWkVEdK PXbqY7+w9a44xRpN3kq8NrN3Sj88eyZh8KwKnkK2KnC/ViZwnOV1hZsiKdnMjvb2 PscV6FTv1Aj2VGx43bm8g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefgedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeeghefgteejheeggfeghfelueeggfdtjeeivedv tefhveeguedufeelhedvteeinecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 13F061700089; Sat, 6 May 2023 11:20:52 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-386-g2404815117-fm-20230425.001-g24048151 Mime-Version: 1.0 Message-ID: <97c44cf8-14bb-4735-ab2e-3ec04636e8e3@app.fastmail.com> In-Reply-To: References: <67b1e9b0-b7c6-71d4-cad2-2286edab759b@daniil.it> <5536a702-4a15-86d2-a178-8d0ef8797e50@php.net> Date: Sat, 06 May 2023 10:20:32 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Final anonymous classes From: larry@garfieldtech.com ("Larry Garfield") On Sat, May 6, 2023, at 2:16 AM, Rokas =C5=A0leinius wrote: > On Fri, 5 May 2023 at 23:58, Levi Morrison via internals > wrote: >> >> I am not sure about making them final by default. I think it's a more >> consistent language design to allow `new final class()` as you >> originally proposed. Although I don't know why anyone would want to >> extend anonymous classes, we can see that people do, in fact, do it. I >> don't see why we couldn't allow `new class() extends $someClass` in >> the future to specifically allow them to do this. I mean, I'm not >> going to lobby for it, I'm just pointing out that is more aligned and >> consistent with other parts of the language, than to simply make it >> final by default. >> >> Cheers. >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: https://www.php.net/unsub.php >> > > My work currently is integrating with various shipping provider APIs > such as DHL. I have to deal with the enormous API request (and > response) definitions. I am just creating a DTO class for each level > of JSON key, which results in a HUGE amount of classes. > > I have a hunch this problem can be solved better with anonymous > classes, but their support is not great yet - PHPStorm has a breaking > bug with their autocompletion and I am too dumb to figure out a better > solution in any case. I think you're on the right track with named classes, honestly. With cu= rrent PHP versions that's syntactically a lot nicer than it used to be. > However, I totally agree with Levi in that the way forward is better > towards `new class() extends $someClass` and not "all anonymous > classes final by default". It may open patterns and opportunities we > have yet to think about. My understanding of the engine implementation is that extending from a c= lass dynamically would be really really hard. (Anon classes are not def= ined at runtime, they get defined at compile time, just with an auto-gen= erated name.) That said, I have to agree here as well that I'm not a fa= n of forcing anon classes to be final, but if someone could figure out d= ynamic-extension anon classes, I would be a happy camper. --Larry Garfield