src/RuntimeContainer.php
protected function autoWireClass(string $name, ?array $parameters = null)
    {
        $config = $this->config->get($name);
        $class = $config['use'];

        if (null !== $parameters) {
            $config['singleton'] = false;
        }

        if (preg_match('#^\{([^{}]+)\}$#', $class, $match)) {
            return $this->wireReference($name, $match[1], $config);
        }

        $reflection = new ReflectionClass($class);

        if (isset($config['factory'])) {
            $factory = $reflection->getMethod($config['factory']);
            $args = $this->autoWireMethod($name, $factory, $config, $parameters);
            $instance = call_user_func_array([$class, $config['factory']], $args);

            return $this->prepareService($name, $instance, $reflection, $config);
        }

        $constructor = $reflection->getConstructor();

        if (null === $constructor) {
            return $this->storeService($name, $config, new $class());
        }

        $args = $this->autoWireMethod($name, $constructor, $config, $parameters);

        return $this->createInstance($name, $reflection, $args, $config);
    }
protected function autoWireClass(string $name, ?array $parameters = null)
    {
        $config = $this->config->get($name);
        $class = $config['use'];

        if (null !== $parameters) {
            $config['singleton'] = false;
        }

        if (preg_match('#^\{([^{}]+)\}$#', $class, $match)) {
            return $this->wireReference($name, $match[1], $config);
        }

        $reflection = new ReflectionClass($class);

        if (isset($config['factory'])) {
            $factory = $reflection->getMethod($config['factory']);
            $args = $this->autoWireMethod($name, $factory, $config, $parameters);
            $instance = call_user_func_array([$class, $config['factory']], $args);

            return $this->prepareService($name, $instance, $reflection, $config);
        }

        $constructor = $reflection->getConstructor();

        if (null === $constructor) {
            return $this->storeService($name, $config, new $class());
        }

        $args = $this->autoWireMethod($name, $constructor, $config, $parameters);

        return $this->createInstance($name, $reflection, $args, $config);
    }
protected function autoWireClass ( string $ name , ? array $ parameters = null ) { $ config = $ this -> config -> get ( $ name ) ; $ class = $ config [ 'use' ] ; if ( null !== $ parameters ) { $ config [ 'singleton' ] = false ; } if ( preg_match ( '#^\{([^{}]+)\}$#' , $ class , $ match ) ) { return $ this -> wireReference ( $ name , $ match [ 1 ] , $ config ) ; } $ reflection = new ReflectionClass ( $ class ) ; if ( isset ( $ config [ 'factory' ] ) ) { $ factory = $ reflection -> getMethod ( $ config [ 'factory' ] ) ; $ args = $ this -> autoWireMethod ( $ name , $ factory , $ config , $ parameters ) ; $ instance = call_user_func_array ( [ $ class , $ config [ 'factory' ] ] , $ args ) ; return $ this -> prepareService ( $ name , $ instance , $ reflection , $ config ) ; } $ constructor = $ reflection -> getConstructor ( ) ; if ( null === $ constructor ) { return $ this -> storeService ( $ name , $ config , new $ class ( ) ) ; } $ args = $ this -> autoWireMethod ( $ name , $ constructor , $ config , $ parameters ) ; return $ this -> createInstance ( $ name , $ reflection , $ args , $ config ) ; }
Auto wire.
Auto wire .