Skip to content

The functionality of the __callStatic magic method is incomplete. #13813

@daddyofsky

Description

@daddyofsky

Description

The following code:

<?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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions