On Fri, Mar 29, 2024, at 2:39 AM, 하늘아부지 wrote: > Hello. > > I created a wiki for __callStatic related issues. > Please see: > https://wiki.php.net/rfc/complete_callstatc_magic > I look forward to your interest and advice.
I am firmly against this proposal. I think my objection boils down to this line in the RFC: > Of course, calling non-static methods in a static-like manner can be > confusing, but in modern PHP, it has already become common practice. I would argue this statement is false. Calling non-static methods in a static-like manner is confusing, which is why in modern PHP one should never do that, and respect that static and non-static methods exist in a separate universe. Static methods are methods *on a type*. Non-static methods are methods *on an instance*. Those are not the same thing.[1] It would be more accurate to say "calling non-static methods in a static-like manner is common *in Laravel*," where the badly-named "facades" system serves as a poorly designed, hard to debug, hard to test, archaic alternative to using dependency injection. While there may have once been an argument that DI was "too hard" for simple cases a decade ago or more (though even then I think it was a bade trade-off), the combination of auto-wiring DI Containers (which Laravel pioneered in PHP) and constructor promotion (introduced in PHP 8.0, 3.5 years ago.) completely eliminates those arguments. The level of effort to do actual DI today is trivially small, and the benefits over magic hidden globals are massive. Laravel Facades are a relic of an older time best avoided, even in Laravel projects. (I am far from the only person to argue this; many even within Laravel's inner community make this argument.) Adding features to the language that seemingly exist only to make that particular buggy hack easier to do is a step backwards, and I would argue harmful for the language. On the contrary, I would favor going the other direction: Calling a static method as though it were non-static currently works, and I would support making that an error, to further emphasize that static and non-static methods are not interchangeable. [1] https://peakd.com/hive-168588/@crell/cutting-through-the-static --Larry Garfield