Neos\Flow\ObjectManagement\ObjectManager::instantiateClass PHP Метод

instantiateClass() защищенный Метод

Speed optimized alternative to ReflectionClass::newInstanceArgs()
protected instantiateClass ( string $className, array $arguments ) : object
$className string Name of the class to instantiate
$arguments array Arguments to pass to the constructor
Результат object The object
    protected function instantiateClass($className, array $arguments)
    {
        if (isset($this->classesBeingInstantiated[$className])) {
            throw new Exception\CannotBuildObjectException('Circular dependency detected while trying to instantiate class "' . $className . '".', 1168505928);
        }
        try {
            switch (count($arguments)) {
                case 0:
                    $object = new $className();
                    break;
                case 1:
                    $object = new $className($arguments[0]);
                    break;
                case 2:
                    $object = new $className($arguments[0], $arguments[1]);
                    break;
                case 3:
                    $object = new $className($arguments[0], $arguments[1], $arguments[2]);
                    break;
                case 4:
                    $object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                    break;
                case 5:
                    $object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]);
                    break;
                case 6:
                    $object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5]);
                    break;
                default:
                    $class = new \ReflectionClass($className);
                    $object = $class->newInstanceArgs($arguments);
            }
            unset($this->classesBeingInstantiated[$className]);
            return $object;
        } catch (\Exception $exception) {
            unset($this->classesBeingInstantiated[$className]);
            throw $exception;
        }
    }