[RFC idea introduce] The issue where the __callStatic magic method is not called when statically calling a public method.
| From: | 하늘아부지 | Date: | Thu, 28 Mar 2024 02:29:35 +0000 |
| Subject: | [RFC idea introduce] The issue where the __callStatic magic method is not called when statically calling a public method. | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-122782@lists.php.net to get a copy of this message | ||
Hi.
I would like to register an RFC on the following issue.
https://github.com/php/php-src/issues/13813
To summarize briefly, users expect that the
__callStatic magic method
will be called in all cases when a method is not static while using the
__callStatic. However, in reality, if the method is public, the
__callStatic magic method is not called, and an error still occurs.
I would like to hear your opinions.
I also hope someone can help with the RFC registration.
--------------------------------------------------------
```php
<?php
class MyClass
{
public static function __callStatic($method, $args)
{
echo $method . "\n";
}
private function privateMethod() {}
protected function protectedMethod() {}
public function publicMethod() {}
}
MyClass::privateMethod();
MyClass::protectedMethod();
MyClass::publicMethod();
```
Resulted in this output:
```
privateMethod
protectedMethod
Fatal error: Uncaught Error: Non-static method MyClass::publicMethod()
cannot be called statically in ...
```
But I expected this output instead:
```
privateMethod
protectedMethod
publicMethod
```