Hi Claude

> > 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?
>
> 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.

Indeed. The argument was that, if you need to give the anonymous class
a dedicated name through an alias to extend it, you might as well
declare a named class in the first place.

In case somebody finds benefit in making anonymous classes open, it
seems more sensible to make them opt into openness, rather than
applying this behavior to all anonymous classes that are used as final
99.9% of the time. Although I really don't think that is necessary.

Ilija

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to