Re: Final anonymous classes

From: Date: Wed, 18 Oct 2023 12:35:28 +0000
Subject: Re: Final anonymous classes
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-121384@lists.php.net to get a copy of this message
On Wed, Oct 18, 2023 at 2:26 PM Tim Düsterhus <tim@bastelstu.be> wrote: > > Hi > > On 10/17/23 19:06, Daniil Gentili wrote: > > Personally, I would have instead preferred the much cleaner approach of > > making *all* anonymous classes final by default, (preferrably) without > > offering the option to make them non-final. > > > > However, I understand that this might be a little bit too restrictive > > for something that may have some valid usecases, even if extending > > anonymous classes currently requires some hack-ish workarounds with > > class_alias. > > Hello, > Perhaps make it two votes, each requiring a 2/3 majority? > > 1. Allow the 'final' keyword on anonymous classes? > 2. Enforce that all anonymous classes are final? How would someone make an anonymous class "unfinal"? I've used this "hack" in unit tests, many times. It's quite useful, so this would probably break a number of (at least my) unit tests if (2) were chosen. Robert Landers Software Engineer Utrecht NL

« previous php.internals (#121384) next »