src/Container/src/AbstractContainer.php
private function createServiceFactoryFromClass(string $class): Closure
    {
        $reflection = new ReflectionClass($class);
        if (!$reflection->isInstantiable()) {
            throw new UninstantiableServiceException($class, $this->resolving);
        }
        $constructor = $reflection->getConstructor();

        if ($constructor && $constructor->getNumberOfParameters() > 0) {
            if ($constructor->getDeclaringClass() !== $class) {
                $invokable = new Invokable([$class, '__construct']);
            } else {
                $invokable = new Invokable($constructor);
            }

            return function (array $arguments = []) use ($invokable) {
                return $this->invoker->invoke($invokable, $arguments);
            };
        }

        return function () use ($class) {
            return new $class();
        };
    }
private function createServiceFactoryFromClass(string $class): Closure
    {
        $reflection = new ReflectionClass($class);
        if (!$reflection->isInstantiable()) {
            throw new UninstantiableServiceException($class, $this->resolving);
        }
        $constructor = $reflection->getConstructor();

        if ($constructor && $constructor->getNumberOfParameters() > 0) {
            if ($constructor->getDeclaringClass() !== $class) {
                $invokable = new Invokable([$class, '__construct']);
            } else {
                $invokable = new Invokable($constructor);
            }

            return function (array $arguments = []) use ($invokable) {
                return $this->invoker->invoke($invokable, $arguments);
            };
        }

        return function () use ($class) {
            return new $class();
        };
    }
private function createServiceFactoryFromClass ( string $ class ) : Closure { $ reflection = new ReflectionClass ( $ class ) ; if ( ! $ reflection -> isInstantiable ( ) ) { throw new UninstantiableServiceException ( $ class , $ this -> resolving ) ; } $ constructor = $ reflection -> getConstructor ( ) ; if ( $ constructor && $ constructor -> getNumberOfParameters ( ) > 0 ) { if ( $ constructor -> getDeclaringClass ( ) !== $ class ) { $ invokable = new Invokable ( [ $ class , '__construct' ] ) ; } else { $ invokable = new Invokable ( $ constructor ) ; } return function ( array $ arguments = [ ] ) use ( $ invokable ) { return $ this -> invoker -> invoke ( $ invokable , $ arguments ) ; } ; } return function ( ) use ( $ class ) { return new $ class ( ) ; } ; }
Create callable factory with resolved arguments from class name.

@param string $class
@return Closure
@throws UninstantiableServiceException
Create callable factory with resolved arguments from class name .