[php-src] Issue #13813: The functionality of the `__callStatic` magic method is incomplete.
| From: | daddyofsky | Date: | Tue, 26 Mar 2024 21:36:22 +0000 |
| Subject: | [php-src] Issue #13813: The functionality of the `__callStatic` magic method is incomplete. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246656@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13813
Author: daddyofsky
### Description
The following code:
```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
```
It seems that the
__callStatic magic method is discriminating against public methods.
;)
### PHP Version
PHP 8.x
### Operating System
Any