Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120202 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62926 invoked from network); 6 May 2023 07:16:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 May 2023 07:16:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BBBB4180384 for ; Sat, 6 May 2023 00:16:24 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) (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 00:16:21 -0700 (PDT) Received: by mail-ua1-f51.google.com with SMTP id a1e0cc1a2514c-780bb3b96e0so467493241.0 for ; Sat, 06 May 2023 00:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683357380; x=1685949380; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MPqYDWlqyD7I7bRnoB41z5snnhpZce5CbwzjNyzNrJo=; b=iFCCVGO4X/rB4Bgxcd9prEVy0AnJ1Lqr3o6GJ/e7KNTJmKbhepoWQyBf5I0fEZnQod lRMiEqNMgtSyBEWSzqEQdthjBiz5uTy+Ow8M04M340HfXcEEqWclBJOcfVuMgQiwMdPw JGhK8+tKqoBTErfvS87GEe7yDJPwvoGT+uUpI5LKTN0Y0ubrcU6ExyGICzUShM1UnzGX 0MaQ1H8pdVmlt9q0Mp/UxfH3g1xis59qbAoICK1UuI4i9KxUG+foyDmuGp7B1lU+ITIW hIn0cg6aLl4DkyMQdNy/ZIdFcSvUS4skpHKkD/BagEHgV9c3jgjFpfWygp3cnJ6mMIW2 JPUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683357380; x=1685949380; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MPqYDWlqyD7I7bRnoB41z5snnhpZce5CbwzjNyzNrJo=; b=FU9KEZ4OaK/IOAxbDfan4uyi63zSVnsyjQho4nR26NepDjBVSZBe9FlTgRP/RjmBH2 nX8BITWslf9qsBnA40wdqQb7RAsQ+cUYnwLIphVqBCQv8eNu/DXUp3BmYI5bz/6ANXWp URb3KCjQLATH3t4o28bGgba7EJUjdUJMmXeKIQx1AGJKcKStguk3LmqIrOzq3+4n4YDw gqQpkw6Shq9NPJBY6ixIMd81GO4JsuvsUyzuGZ3WPLhOXqz5IjppifMDrRFnzX4IXpyI drkEbnFERHAmNWzSQCQlGbBAPu4H8G9L9w+laageSdNW1jpNIvxsqZjwVFzePAXUppGC N4xA== X-Gm-Message-State: AC+VfDxIQs0HhpDcNbsoXVXProKx3l/KgkAuonLTI2isZpzYWexbGYWB X6QWEOKLBj/YUKRFw1vqrz5c5VmubIbDk8KJhT8= X-Google-Smtp-Source: ACHHUZ4VNj/APGeItOgH7bRrNVcCvDXpREZ5Z76ngyQIpSGky/UIlhzqrrUaATmMRSMkPpwqHA330SjddbNIN/MhBwc= X-Received: by 2002:a05:6102:1da:b0:434:2e18:8d23 with SMTP id s26-20020a05610201da00b004342e188d23mr1515324vsq.6.1683357380505; Sat, 06 May 2023 00:16:20 -0700 (PDT) MIME-Version: 1.0 References: <67b1e9b0-b7c6-71d4-cad2-2286edab759b@daniil.it> <5536a702-4a15-86d2-a178-8d0ef8797e50@php.net> In-Reply-To: Date: Sat, 6 May 2023 10:16:04 +0300 Message-ID: To: Levi Morrison Cc: Derick Rethans , Daniil Gentili , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Final anonymous classes From: rokas.sleinius@gmail.com (=?UTF-8?Q?Rokas_=C5=A0leinius?=) 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. 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.