For reference, this is the share method @ v4.0.5 .
So what is going on here. I will explain this in a couple of steps.
Share method call
As you indicated, this method is called from service providers. Thus, FilesystemServiceProvider calls this method, which looks something like this:
$this->app['files'] = $this->app->share(function() { return new Filesystem; });
It assigns the return value of this share method to the binding in the container. In short, this return value will be a new instance of Filesystem , which is returned in close.
So what does Share do?
The share method is another way of defining a singleton in an IoC container. All of this can be a little intimidating at first. Basically, Laravel itself is an IoC container. All classes are connected as container instances. Sometimes these instances must be the same for each call.
If you look at the link method above on GitHub, you will notice that a static variable is defined inside the closure. He then checks to see if this variable is null, and if it allows closure (this is the closure that our new Filesystem instance returns). Then it just returns the variable.
Now, the next time you use File::get() , you do not need to instantiate the Filesystem class again, as it has already been created and is stored in the static variable $object . That way, it just returns the same object to you.
So! Indeed, you could replace the string $this->app['files'] this, and it will still work.
$this->app->instance('files', new Filesystem);
99% of the services actually use the share method, though, since working inside the closure allows you to create objects with more complex dependencies.
Hope this helps.