On Mon, Jun 24, 2024, 02:15 Bilge <bi...@scriptfusion.com> wrote:

> Hi Internals!
>
> I am pleased to present my first RFC: Static class
> <https://wiki.php.net/rfc/static_class>.
>
>
Hi! and good luck with the RFC.

While I don't use static classes, I can see how this can be used by others.

I worked in big projects that used too many libraries, and when those
libraries have functions.php file, they pile up and loading the composer
autoloader can take a small dent on performance of each request.
Having functions grouped by a class that can autoloader instead of a file
is an advantage that should be spelled out as an use case.



Feedback:

1. I agree that static classes may extend other non-static classes (that
might have some static behavior).
But I think that static classes should be extended only by other static
classes, or at least for the first iteration of these feature.
This should be documented more in the RFC, no matter how it ends up being.
1.1 I think using a static class as a type should be considered an error,
as there will never be instances of it if we consider all child classes
will also be static classes.
Of course, this cannot be an error on php side given the class per file
loading separation.


2. __set_state() is strongly linked to exporting a class instance as a
valid php string, and is used to reconstruct the class instance upon
execution.
Considering we forbid instances, we should not support __set_state(). If
you think otherwise, please share an example how it can be used.

Regards,
Alex

Reply via email to