On 24/06/2024 07:59, Alexandru Pătrănescu wrote:
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.

Hi Alex, and thanks for your excellent feedback!

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

It is my sincere hope that everyone will vote with similar empathy.

Feedback:

1. I agree that static classes may extend other non-static classes (that might have some static behavior).
To be clear, they must /exclusively/ have static members, not just /some/.
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.
This is an interesting debate, and something we may end up doing. I am currently undecided if it would be better to enforce full static class hierarchy, but I could definitely be so convinced.
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.
This is a very interesting point that I had not considered. I agree, it should be correct to forbid type hinting static classes. However, if I understood you correctly, we cannot actually implement that? My knowledge of engine internals is too weak to know the correct answer here. If it is possible, I think we should do it.
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.

Thank you for catching this. This is strictly a mistake on my part. I have never used, or even heard of, __set_state() in my life. I was merely perusing the magic methods to make sure I caught them all and it seemed, at a glance, this might apply to static classes, but as you point out, if this indeed requires an instance then it does not apply. I will remove this from the next version of the RFC, which I shall publish imminently.

Many thanks,
Bilge

Reply via email to