Laravel (sometimes) calls this feature a "Facade" -- explaining how this is accomplished in Laravel means going way down the Laravel rabbit hole and is beyond the scope of a single Stack Overflow answer -- if you're interested in that I'm the author of a 10 article series that covers the implementation details of a lot of Laravel's "magic" methods -- worth checking out if you're the sort who likes those sort of nitty gritty details. The PHP manual entry on overloading is also useful.
The short version is, all PHP classes have a magic method named __callStatic
. If your class has __callStatic
defined
class Foo
{
public function __callStatic($method, $args)
{
}
}
and you call a method that does not exist, or is protected/private
Foo::notThere(1,2,'foo');
Then PHP will call the __callStatic
method instead, with $method
being the method's name (notThere
above) and $args
being an array of parameters passed to the method (1
, 2
, and foo
above)