src/DependencyInjection/Container.php
public function getSingleton($requestedClass, callable $singletonCreationCallback = null)
    {
        if (!isset($this->singletons[$requestedClass])){
            if ($singletonCreationCallback){
                $singleton = $singletonCreationCallback;
            } else {
                $singleton = $this->instance($requestedClass);
            }

            $this->singletons[$requestedClass] = $singleton;
            $this->concreteClassMappings["_".$requestedClass] = $requestedClass;
        }

        if (is_callable($this->singletons[$requestedClass])){
            $callback = $this->singletons[$requestedClass];
            $this->singletons[$requestedClass] = $callback();
        }

        return $this->singletons[$requestedClass];
    }
public function getSingleton($requestedClass, callable $singletonCreationCallback = null)
    {
        if (!isset($this->singletons[$requestedClass])){
            if ($singletonCreationCallback){
                $singleton = $singletonCreationCallback;
            } else {
                $singleton = $this->instance($requestedClass);
            }

            $this->singletons[$requestedClass] = $singleton;
            $this->concreteClassMappings["_".$requestedClass] = $requestedClass;
        }

        if (is_callable($this->singletons[$requestedClass])){
            $callback = $this->singletons[$requestedClass];
            $this->singletons[$requestedClass] = $callback();
        }

        return $this->singletons[$requestedClass];
    }
public function getSingleton ( $ requestedClass , callable $ singletonCreationCallback = null ) { if ( ! isset ( $ this -> singletons [ $ requestedClass ] ) ) { if ( $ singletonCreationCallback ) { $ singleton = $ singletonCreationCallback ; } else { $ singleton = $ this -> instance ( $ requestedClass ) ; } $ this -> singletons [ $ requestedClass ] = $ singleton ; $ this -> concreteClassMappings [ "_" . $ requestedClass ] = $ requestedClass ; } if ( is_callable ( $ this -> singletons [ $ requestedClass ] ) ) { $ callback = $ this -> singletons [ $ requestedClass ] ; $ this -> singletons [ $ requestedClass ] = $ callback ( ) ; } return $ this -> singletons [ $ requestedClass ] ; }
Creates a singleton object instance of the requested class from the current DI container

@see getInstance()
@param $requestedClass
@param ...$arguments
@return mixed
Creates a singleton object instance of the requested class from the current DI container