title: Laravel core method confusion
body: <p>I have been digging in the core of Laravel because I would like to understand how it works. But I come up with a method that I just cannot wrap my head around even after 3 days.
  In start.php the app is binded to itself. So far so good. But when I check the $app->share method I am lost.</p>
  
  <pre><code>    public function share(Closure $closure)
  {
      return function($container) use ($closure)
      {
  
          // We'll simply declare a static variable within the Closures and if
          // it has not been set we'll execute the given Closure to resolve
          // the value and return it back to the consumers of the method.
          static $object;
          if (is_null($object))
          {
              $object = $closure($container);
          }
  
          return $object;
      };
  }
  </code></pre>
  
  <p>This method returns an anonymous function which when executed returns an instance of the app. Do I see that right? Why is this? Why do you want to return a closure and not just the instance. This seems like a strange way, but I am quite sure that there is a reason ;) ??</p>
  
  <p><strong>UPDATE</strong>
  The line in start.php:</p>
  
  <pre><code>$app['app'] = $app-&gt;share(function($app) { return $app; });
  </code></pre>
  
  <p>So I would think that $app['app'] is a closure object. However if I do get_class the class is Illuminate\Foundation\Application . 
  Furthermore there is also no way to execute it as $app'app' will not work obviously.</p>