src/Di/Container.php
public function create(string $class, $args = [], $explicit = null)
    {
        // check first for definition even if auto wiring is on
        $def = $this->getDefinition($class);
        if ($def === null && !$this->auto_wiring) {
            throw new ClassDefinitionNotFoundException($class);
        } elseif ($def !== null) {
            return $this->binding_resolver->resolve(
                $this->getDefinition($class),
                $this,
                $args,
                $explicit
            );
        }

        // process class dependencies with reflection
        $args = $this->resolver->resolve($class, $this, $args, $explicit);

        // instantiate class with resolved dependencies and args if apply
        return $this->instantiator->instantiate($class, $args);
    }
public function create(string $class, $args = [], $explicit = null)
    {
        // check first for definition even if auto wiring is on
        $def = $this->getDefinition($class);
        if ($def === null && !$this->auto_wiring) {
            throw new ClassDefinitionNotFoundException($class);
        } elseif ($def !== null) {
            return $this->binding_resolver->resolve(
                $this->getDefinition($class),
                $this,
                $args,
                $explicit
            );
        }

        // process class dependencies with reflection
        $args = $this->resolver->resolve($class, $this, $args, $explicit);

        // instantiate class with resolved dependencies and args if apply
        return $this->instantiator->instantiate($class, $args);
    }
public function create ( string $ class , $ args = [ ] , $ explicit = null ) { // check first for definition even if auto wiring is on $ def = $ this -> getDefinition ( $ class ) ; if ( $ def === null && ! $ this -> auto_wiring ) { throw new ClassDefinitionNotFoundException ( $ class ) ; } elseif ( $ def !== null ) { return $ this -> binding_resolver -> resolve ( $ this -> getDefinition ( $ class ) , $ this , $ args , $ explicit ) ; } // process class dependencies with reflection $ args = $ this -> resolver -> resolve ( $ class , $ this , $ args , $ explicit ) ; // instantiate class with resolved dependencies and args if apply return $ this -> instantiator -> instantiate ( $ class , $ args ) ; }
Instantiate a class

The generated instance is not stored, but may use stored
instance(s) as dependency when needed

@param string $class
@param array $args
@param null $explicit
@return mixed|object
@throws ClassDefinitionNotFoundException
@throws Exception\AmbiguousResolutionException
@throws Exception\InterfaceNotFoundException
@throws \ReflectionException
Instantiate a class