On Mon, Jan 15, 2024, at 13:54, Nuno Maduro wrote:
> On Mon, 15 Jan 2024 at 10:36, Daniil Gentili <daniil.gentili@gmail.com>
> wrote:
>
> > Hi all,
> >
> > I've opened voting for the final-by-default anonymous classes RFC:
> > https://wiki.php.net/rfc/final_by_default_anonymous_classes
> >
> > Regards,
> >
> > Daniil Gentili.
> >
>
> Hi Daniil,
>
> Thank you for your work on this RFC. In my opinion, this RFC should not
> move forward for consistency reasons. If regular class definitions are
> non-final by default, anonymous classes should be non-final too.
I don't think that consistency is a good argument here, because anonymous classes are qualitatively different in this regard. In order to extend a class you need to name it -- which *should* be impossible-by-design for an anonymous class.
Unfortunately, due to an implementation oversight, this is not actually true. I consider the fact that extending anonymous classes is possible to be a bug, which is why I also accept the minor backwards compatibility break that comes with fixing it. Of course, the line between a bug and a feature is quite fine sometimes, so I understand that people have differing views on where this falls.
Regards,
Nikita