Re: Final anonymous classes
| From: | Claude Pache | Date: | Mon, 24 Apr 2023 22:11:50 +0000 |
| Subject: | Re: Final anonymous classes | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120120@lists.php.net to get a copy of this message | ||
> Le 24 avr. 2023 à 12:28, Daniil Gentili <daniil@daniil.it> a écrit :
>
> Hi all,
>
> I've submitted https://github.com/php/php-src/pull/11126
> to add support for final anonymous classes, though as noted by iluuu1994, it would probably make
> more sense to just make all anonymous classes final by default, what do you think?
>
> Daniil Gentili.
>
Hi,
Extending an anonymous class is indeed possible (https://3v4l.org/pDFTL), but it is a hack as best.
If someone wants a non-final class, could they not write a non-anonymous one? As a bonus, they
wouldn’t need to instantiate the class before referencing it.
—Claude