2024년 3월 30일 (토) 오전 2:15, Robert Landers <landers.rob...@gmail.com>님이 작성:

> On Fri, Mar 29, 2024 at 3:41 AM 하늘아부지 <daddyof...@gmail.com> 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.
> >
> > Best Regards.
> > Daddyofsky
>
> Hey there,
>
> Some general feedback:
>
> The RFC is a bit hard for me to follow, for example:
>
> > However, the IDE cannot find active method, and the Go to Definition
> feature cannot be used.
>
> This sounds like a bug or feature request with your IDE, not a problem
> with PHP.
>
> > This code is very clear, aside from the fact that the method is not
> static.
>
> Clear to whom? As a developer this looks downright confusing. I can't
> even guess what the actual behavior is. If you call a non-static
> method statically, its currently an error. Why would this not be an
> error?
>
> > The IDE recognizes active methods well and the Go to definition feature
> also works properly.
>
> What is stopping the IDE to taking you to the __callStatic method?
> That would be the correct behavior IMHO, not the implementation for
> instance methods.
>
> > Even if there are only a few core methods, it cannot be made into a
> single file.
>
> There is nothing stopping you from putting multiple classes in a file.
>
> > As can be seen in the above examples, the code becomes clearer, and
> navigation through the IDE works much better.
>
> I completely disagree. It mixes concerns and makes spaghetti code into
> incomprehensible code. Also, maybe you should take up IDE navigation
> with your IDE?
>
> > Instead of throwing an error when a non-static public method is called
> statically, the _ _callStatic method should be invoked.
>
> I completely agree with this, btw. Your examples could use some work
> and shows all the reasons why it shouldn't call __callStatic(). A real
> life example, that has nothing to do with a specific framework:
>
> When generating proxies for existing types, you often need to share
> some state between the proxies. To do that, you put static
> methods/properties on the proxy class and hope to the PHP Gods that
> nobody will ever accidentally name something in their concrete class
> with the name you chose for things. To help with that, you create some
> kind of insane prefix. If __callStatic() were called ALWAYS in a
> static context, even if a non-static method exists, then collisions
> would literally be impossible. But at that point, why can't I just
> write:
>
> class Test {
>   public static function test(): string { return "hello world"; }
>   public function test(): int { return random_int(); }
> }
>
> ??? I feel like this is your real RFC and should be allowed if we're
> allowed to __callStatic() to instance methods. I don't think it makes
> sense to have one without the other, and then what you want with
> __callStatic() comes naturally, instead of this weird and confusing
> RFC.
>
>
> Robert Landers
> Software Engineer
> Utrecht NL
>

Hello.

I'm not very familiar with documentation. It would be helpful if you could
suggest how to fix the problematic parts.

Using the example of the IDE meant to illustrate that it should be
intuitive enough for the IDE to find it directly.

Even currently, `__callStatic` is called in cases of non-static methods
that are not public methods. `__callStatic` already acts as a rule-breaker.
It seems like there's a desire for the magic method to be named as such
without actually causing much magic. The current `__callStatic` is like a
magician who can use high-level magic to hit targets behind doors or
invisible targets but can't use basic magic to hit a visible door.

While it's good that the PHP kindly notifies errors, I think it would also
be beneficial to provide users with options to do other things,
specifically when they intentionally use `__callStatic`. That's the core
point of this proposal.

If there are better examples or ways to explain, I would appreciate
learning about them.

Daddyofsky

Reply via email to