Q:

How does laravels IoC/Dependency Injector intsantiate to static instances?

So this is probably a rather simple question but I can't seems to find a very direct answer.  I supposed to could keep reading the source until i figure it out but I was hoping to get a bit of understand of the process of doing so.  
I understand IoC and Dependency injection, I am certainly not very experienced in either but I have a good understand of what they are trying to accomplish.  So how does this Laravel instantiate to static instances?  I know it uses PHP reflections but I'm still lost on the part of going from non-static to static methods.  Also I know Laravel is not the only framework to implement such a design but its my preferred and most understood framework.

A:

When you call a static method on a facade it is being handled by the magic __callStatic method on the Facade class. This method gets the underlying class that serves the facade and proxies the static call to it.
Let's look at an example facade:
<?php
class MyFacade extends Facade {
  public function getFacadeAccessor() { return "MyFacade"; }
}

With this example when we make a call to the class in a static manner such as: MyFacade::doSomething() no static method exists on the class. The underlying Facade base class however contains a __callStatic method that will be called.
Facade Class Source Code
public static function __callStatic($method, $args)
{
        $instance = static::resolveFacadeInstance(static::getFacadeAccessor());

        switch (count($args))
        {
                case 0:
                        return $instance->$method();
        // Snipped for brevity...

This method then looks up the underlying class to service the facade. If the getFacadeAccessor method on the facade returns a string then a matching entry in the application's IOC container is used (i.e. $app['MyFacade']). If we returned an object from the getFacadeAccessor method it would be used instead (i.e. public function getFacadeAccessor(){ return new MyClass(); }

