private function resolveObject($definition, $alias)
    {
        if ($definition instanceof \Closure) {
            return $this->resolveClosure(
                $alias,
                $definition
            );
        }


        try {
            $class = new \ReflectionClass($definition);
        } catch (\ReflectionException $exception) {
            throw new ReflectionException(
                $exception->getMessage()
            );
        }


        $this->resolveProviderAnnotations($class);


        // the given class if is not instantiable throw an exception
        // that happens when you try resolve an interface or abstract class
        // without saving an alias on that class before
        if (false === $class->isInstantiable()) {
            throw new ReflectionException(
                sprintf(
                    '%s class in not instantiable, probably an interface or abstract',
                    $class->getName()
                )
            );
        }

        $constructor = $class->getConstructor();

        $parameters = [];

        if (null !== $constructor) {
            $this->resolveInjectAnnotations($constructor, $alias);

            $parameters = $this->resolveParameters(
                $constructor,
                $this->argumentManager->getClassArgs($alias)
            );
        }

        return $class->newInstanceArgs($parameters);
    }
private function resolveObject($definition, $alias)
    {
        if ($definition instanceof \Closure) {
            return $this->resolveClosure(
                $alias,
                $definition
            );
        }


        try {
            $class = new \ReflectionClass($definition);
        } catch (\ReflectionException $exception) {
            throw new ReflectionException(
                $exception->getMessage()
            );
        }


        $this->resolveProviderAnnotations($class);


        // the given class if is not instantiable throw an exception
        // that happens when you try resolve an interface or abstract class
        // without saving an alias on that class before
        if (false === $class->isInstantiable()) {
            throw new ReflectionException(
                sprintf(
                    '%s class in not instantiable, probably an interface or abstract',
                    $class->getName()
                )
            );
        }

        $constructor = $class->getConstructor();

        $parameters = [];

        if (null !== $constructor) {
            $this->resolveInjectAnnotations($constructor, $alias);

            $parameters = $this->resolveParameters(
                $constructor,
                $this->argumentManager->getClassArgs($alias)
            );
        }

        return $class->newInstanceArgs($parameters);
    }
private function resolveObject ( $ definition , $ alias ) { if ( $ definition instanceof \ Closure ) { return $ this -> resolveClosure ( $ alias , $ definition ) ; } try { $ class = new \ ReflectionClass ( $ definition ) ; } catch ( \ ReflectionException $ exception ) { throw new ReflectionException ( $ exception -> getMessage ( ) ) ; } $ this -> resolveProviderAnnotations ( $ class ) ; // the given class if is not instantiable throw an exception // that happens when you try resolve an interface or abstract class // without saving an alias on that class before if ( false === $ class -> isInstantiable ( ) ) { throw new ReflectionException ( sprintf ( '%s class in not instantiable, probably an interface or abstract' , $ class -> getName ( ) ) ) ; } $ constructor = $ class -> getConstructor ( ) ; $ parameters = [ ] ; if ( null !== $ constructor ) { $ this -> resolveInjectAnnotations ( $ constructor , $ alias ) ; $ parameters = $ this -> resolveParameters ( $ constructor , $ this -> argumentManager -> getClassArgs ( $ alias ) ) ; } return $ class -> newInstanceArgs ( $ parameters ) ; }
resolves the instance

@param object $definition
@param string $alias
@throws ContainerExceptionInterface
@throws ContainerNotFoundException
@throws ReflectionException
@return mixed
resolves the instance