Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121690 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4080 invoked from network); 15 Nov 2023 21:53:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Nov 2023 21:53:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B106218002E for ; Wed, 15 Nov 2023 13:53:04 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Nov 2023 13:53:01 -0800 (PST) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-32deb2809daso104723f8f.3 for ; Wed, 15 Nov 2023 13:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700085179; x=1700689979; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6vYyg63aaH5LEiyHKpmGnax80mb/bmzzAhFDTrtpxsg=; b=mK9gkh4RSRKtnoUH0Alzm9Gm2NnMVD/XFhia61/PhEwPke9iYa4TMF/qcycdHh2LpO J/n347b8BIQfNTrJakpUhwP97E4S3Es7yg+d/lIFi2GJxLlMuCDjCau2iLVf/ivG9vIP hND2g7WVXEHOmclg3AJISof9xFb19Lln96xd/tigi61a9g4UWdkLq0CHDpPkboIJuc9N AVC5nZoXh2L5OpCM+m702UopmCeHh/JIY1KBonZHir1jGx/ko9Vt+eg7QmP/d3D6yZpm 9cm+txn8uITuxZYH8ZRDzcxcGyVcBkEhakc4nv1wqhJIdR01xclWgwKnGC8KT4x4UR+X FvbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700085179; x=1700689979; 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=6vYyg63aaH5LEiyHKpmGnax80mb/bmzzAhFDTrtpxsg=; b=nWn+po0EnY99oftMgA2tkoUEgvgv6II1LOBsvjNK/IZrM4w7FCKtkk6fUDVhoXXDF6 snKouEi3pV8zf2Cpk+GbfUKXozdlreSggIjLJvVL4eD6oa4QKN6gtbOBLB/tWyHUH/+K gvonFZVEuLPtXR6BpU4mTdKADmhbbVImsP/55EICdneEd7bg0IzivZ2aW6RSNEcYe6C5 Ew7uL8lkjN1D5ELARVdy3pvNWFbb1+YzCzfYBwqMnn4gOr4vyrGtMm0Df/4kuK0J3uXJ f0feP7fI0UzRHPa2PRiFw/cxSI4jyDewKAvaS58MOspIo7gi4P3YqhUJ3Wi6OQnalazX FpBQ== X-Gm-Message-State: AOJu0YyvIAvB+UlgT20E4uTQ9hDBJWfpOeYrkIJKL9dzs8afaB99NZMU l6WBlqGwCO+cKlpiCE4fjuFE2MOmE/zniqIp9FFueMMmc872vw== X-Google-Smtp-Source: AGHT+IFSLYwygQz4ZjMXb9DVv4yVnyGZPVGfnzdU0tTWOgtrokuWhmTrcv9wUf1ZFdZKFQ1QwkAinYDCidiBYYoquZ0= X-Received: by 2002:a05:6000:1541:b0:32f:b1f2:1f99 with SMTP id 1-20020a056000154100b0032fb1f21f99mr13807553wry.9.1700085179229; Wed, 15 Nov 2023 13:52:59 -0800 (PST) MIME-Version: 1.0 References: <06e7cf8c-c5f5-4fb8-b9fe-92b441a70485@daniil.it> In-Reply-To: <06e7cf8c-c5f5-4fb8-b9fe-92b441a70485@daniil.it> Date: Wed, 15 Nov 2023 22:52:47 +0100 Message-ID: To: Daniil Gentili Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000322b77060a37eddb" Subject: Re: [PHP-DEV] [RFC] [Discussion] Final anonymous classes From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000322b77060a37eddb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Daniil and thanks for the RFC. I would like to submit an RFC and PR to add support for final anonymous > classes, /or/ make all anonymous classes final by default, with or > without the possibility to make them non-final. > > Here's the URL of the RFC: > https://wiki.php.net/rfc/final_anonymous_classes > > I'd more more than glad to receive some feedback! > I've read the RFC proposing to make anonymous classes final by default, and as defender of backward compatibility, I have concerns. The RFC cites potential performance gains and a cleaner codebase as justifications. However, the performance improvement seems limited to a narrow use case =E2= =80=93 anonymous classes aren't that common in everyday PHP coding. Without concrete data demonstrating significant performance benefits, this argument doesn't seem strong enough to warrant a BC break. Regarding the argument for cleaner code, while I acknowledge the appeal of streamlined design, we must remember that breaking backward compatibility isn't the right tool for correcting past decisions. PHP has a rich history of handling such transitions gracefully, typically introducing changes with a deprecation notice in a minor version before a major shift. This approach has served our community well, maintaining stability and predictability. Is this change truly worth such a departure from our norms? I believe not. Making anonymous classes final by default goes against the principle of least surprise, a core philosophy in PHP where regular classes aren't final by default. While I'm open to Proposal 1, which introduces final anonymous classes without breaking BC, Proposals 2 and 3 are a different story. They seem to suggest we can break backward compatibility on a whim, but our release process (https://wiki.php.net/rfc/releaseprocess) clearly advises against such moves in minor releases. Overriding this policy should require a more substantial rationale. As an example, in my work with Symfony, I've utilized class_alias to extend anonymous classes within a test suite ( https://github.com/symfony/symfony/blob/c9e7809f045a1366afe2c2643bae15751ae= 7b500/src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php#L294). While the RFC suggests alternative methods to achieve something similar, the essence of preserving backward compatibility is about ensuring stability and reliability without imposing the burden of code modification on userland. In summary, I advocate for the RFC to focus on the non-BC-breaking option. Let's maintain our commitment to stability and gradual evolution in PHP. Cheers, Nicolas --000000000000322b77060a37eddb--