private function prepareSingletonBindingClosure($id, $blueprint, $dependencies): Closure
    {
        $binding = $this->bindings[$id];
        $instance = $blueprint;

        if ($blueprint instanceof ReflectionClass) {
            foreach ($dependencies as $key => $dependency) {
                if ($dependency instanceof Closure) {
                    $dependencies[$key] = $dependency();
                }
            }
            $instance = $blueprint->newInstanceArgs($dependencies);
        }
        if ($blueprint instanceof Closure) {
            $instance = $blueprint();
        }
        // If blueprint is supplied as a class name.
        if (is_string($blueprint)) {
            $instance = new $blueprint;
        }
        // Singletons won't need these any longer so free up the memory.
        unset($binding['dependencies'], $binding['reflector']);

        return $this->cache[$id] = function () use ($instance) {
            return $instance;
        };
    }
private function prepareSingletonBindingClosure($id, $blueprint, $dependencies): Closure
    {
        $binding = $this->bindings[$id];
        $instance = $blueprint;

        if ($blueprint instanceof ReflectionClass) {
            foreach ($dependencies as $key => $dependency) {
                if ($dependency instanceof Closure) {
                    $dependencies[$key] = $dependency();
                }
            }
            $instance = $blueprint->newInstanceArgs($dependencies);
        }
        if ($blueprint instanceof Closure) {
            $instance = $blueprint();
        }
        // If blueprint is supplied as a class name.
        if (is_string($blueprint)) {
            $instance = new $blueprint;
        }
        // Singletons won't need these any longer so free up the memory.
        unset($binding['dependencies'], $binding['reflector']);

        return $this->cache[$id] = function () use ($instance) {
            return $instance;
        };
    }
private function prepareSingletonBindingClosure ( $ id , $ blueprint , $ dependencies ) : Closure { $ binding = $ this -> bindings [ $ id ] ; $ instance = $ blueprint ; if ( $ blueprint instanceof ReflectionClass ) { foreach ( $ dependencies as $ key => $ dependency ) { if ( $ dependency instanceof Closure ) { $ dependencies [ $ key ] = $ dependency ( ) ; } } $ instance = $ blueprint -> newInstanceArgs ( $ dependencies ) ; } if ( $ blueprint instanceof Closure ) { $ instance = $ blueprint ( ) ; } // If blueprint is supplied as a class name. if ( is_string ( $ blueprint ) ) { $ instance = new $ blueprint ; } // Singletons won't need these any longer so free up the memory. unset ( $ binding [ 'dependencies' ] , $ binding [ 'reflector' ] ) ; return $ this -> cache [ $ id ] = function ( ) use ( $ instance ) { return $ instance ; } ; }
Make a singleton binding closure method to store in the cache.

@param  string $id
@param  mixed $blueprint
@param  array $dependencies
@return Closure
Make a singleton binding closure method to store in the cache .