PHP Callable Class
__invoke
makes an object callable.
Though there is no magic method that makes a class callable e.g.
__invokeStatic
.
But we can still make a callable class. That’s to define a function with the same name as the class. E.g.
Note that before PHP 5.6, the constructor signature has to duplicate again as the function signature, this makes it a little bit awakard to define. (Using Reflection won’t be easier either) E.g.
This is solved by the introduction of Variable-length argument lists since PHP 5.6.