Invoker
Invoker copied to clipboard
[feature] Allow to call via magic methods
Hi! Are there any plans to support magic methods? I didn't find an answer in the docs.
Example:
class TransportFactory {
public static function __callStatic(string $method, array $arguments): string {
return $method;
}
}
echo $invoker->call([TransportFactory::class, 'some.transport.example']);
// Output:
// some.transport.example
P.S.: Thank you for the development and support of the library.
Is this duplicating #36?
Are there any plans to support magic methods?
FYI they are not supported at the moment.
Is this duplicating #36?
No, this is not a duplicate. Here I decided to leave the question of plans to implement support for magical methods. #36 and #37 describe and resolve unexpected exception if __callStatic magic method is used.
Currently, we can use Closure::fromCallable
as an explicit workaround, but the $arguments
always will be empty array
. Example:
class TransportFactory {
public static function __callStatic(string $method, array $arguments): string {
return $method;
}
}
echo $invoker->call(Closure::fromCallable([TransportFactory::class, 'some.transport.example']));