src/Container.php
private function createService($name)
    {
        $entry = &$this->services[$name];

        if (!is_array($entry) || !isset($entry['class'])) {
            throw new ContainerException($name.' service entry must be an array containing a \'class\' key');
        } elseif (!class_exists($entry['class'])) {
            throw new ContainerException($name.' service class does not exist: '.$entry['class']);
        } elseif (isset($entry['lock'])) {
            throw new ContainerException($name.' contains circular reference');
        }

        $entry['lock'] = true;

        $arguments = isset($entry['arguments']) ? $this->resolveArguments($entry['arguments']) : [];

        $reflector = new \ReflectionClass($entry['class']);
        $service = $reflector->newInstanceArgs($arguments);

        if (isset($entry['calls'])) {
            $this->initializeService($service, $name, $entry['calls']);
        }

        return $service;
    }
private function createService($name)
    {
        $entry = &$this->services[$name];

        if (!is_array($entry) || !isset($entry['class'])) {
            throw new ContainerException($name.' service entry must be an array containing a \'class\' key');
        } elseif (!class_exists($entry['class'])) {
            throw new ContainerException($name.' service class does not exist: '.$entry['class']);
        } elseif (isset($entry['lock'])) {
            throw new ContainerException($name.' contains circular reference');
        }

        $entry['lock'] = true;

        $arguments = isset($entry['arguments']) ? $this->resolveArguments($entry['arguments']) : [];

        $reflector = new \ReflectionClass($entry['class']);
        $service = $reflector->newInstanceArgs($arguments);

        if (isset($entry['calls'])) {
            $this->initializeService($service, $name, $entry['calls']);
        }

        return $service;
    }
private function createService ( $ name ) { $ entry = & $ this -> services [ $ name ] ; if ( ! is_array ( $ entry ) || ! isset ( $ entry [ 'class' ] ) ) { throw new ContainerException ( $ name . ' service entry must be an array containing a \'class\' key' ) ; } elseif ( ! class_exists ( $ entry [ 'class' ] ) ) { throw new ContainerException ( $ name . ' service class does not exist: ' . $ entry [ 'class' ] ) ; } elseif ( isset ( $ entry [ 'lock' ] ) ) { throw new ContainerException ( $ name . ' contains circular reference' ) ; } $ entry [ 'lock' ] = true ; $ arguments = isset ( $ entry [ 'arguments' ] ) ? $ this -> resolveArguments ( $ entry [ 'arguments' ] ) : [ ] ; $ reflector = new \ ReflectionClass ( $ entry [ 'class' ] ) ; $ service = $ reflector -> newInstanceArgs ( $ arguments ) ; if ( isset ( $ entry [ 'calls' ] ) ) { $ this -> initializeService ( $ service , $ name , $ entry [ 'calls' ] ) ; } return $ service ; }
Attempt to create a service.

@param string $name The service name.

@return mixed The created service.

@throws ContainerException On failure.
Attempt to create a service .