Will create an instance of `FormObject` based on a class which implements
the interface `FormInterface`.

@param string $className
@param string $name
@return FormObject
@throws ClassNotFoundException
@throws InvalidArgumentTypeException
172142
public function getInstanceFromClassName($className, $name)
    {
        if (false === class_exists($className)) {
            throw ClassNotFoundException::wrongFormClassName($className);
        }

        if (false === in_array(FormInterface::class, class_implements($className))) {
            throw InvalidArgumentTypeException::wrongFormType($className);
        }

        $cacheIdentifier = $this->getCacheIdentifier($className, $name);

        if (false === isset($this->instances[$cacheIdentifier])) {
            $cacheInstance = CacheService::get()->getCacheInstance();

            if ($cacheInstance->has($cacheIdentifier)) {
                $instance = $cacheInstance->get($cacheIdentifier);
            } else {
                $instance = $this->createInstance($className, $name);
                $cacheInstance->set($cacheIdentifier, $instance);
            }

            /** @var Configuration $formzConfigurationObject */
            $formzConfigurationObject = $this->configurationFactory
                ->getFormzConfiguration()
                ->getObject(true);

            if (false === $formzConfigurationObject->hasForm($instance->getClassName(), $instance->getName())) {
                $formzConfigurationObject->addForm($instance);
            }

            $this->instances[$cacheIdentifier] = $instance;
        }

        return $this->instances[$cacheIdentifier];
    }
714710
private function createClassInstance($className)
    {
        if (empty($className)) {
            return new stdClass();
        }

        try {
            $refClass = new ReflectionClass($className);
            return $refClass->newInstance();
        } catch (Exception $e) {
            throw new DeserializationException("Class [$className] could not be instantiated");
        }
    }
1281540
public function create(string $className, string $typeName): Type
    {
        $type = new InputObjectType([
            'name' => $typeName,
            'description' => 'Type to specify conditions on fields',
            'fields' => function () use ($className, $typeName): array {
                $filters = [];
                $metadata = $this->entityManager->getClassMetadata($className);

                // Get custom operators
                $this->readCustomOperatorsFromAnnotation($metadata->reflClass);

                // Get all scalar fields
                foreach ($metadata->fieldMappings as $mapping) {
                    if ($mapping['id'] ?? false) {
                        $leafType = Type::id();
                    } else {
                        /** @var LeafType $leafType */
                        $leafType = $this->types->get($mapping['type']);
                    }

                    $fieldName = $mapping['fieldName'];
                    $operators = $this->getOperators($fieldName, $leafType, false, false);

                    $filters[] = $this->getFieldConfiguration($typeName, $fieldName, $operators);
                }

                // Get all collection fields
                foreach ($metadata->associationMappings as $mapping) {
                    $fieldName = $mapping['fieldName'];
                    $operators = $this->getOperators($fieldName, Type::id(), true, $metadata->isCollectionValuedAssociation($fieldName));

                    $filters[] = $this->getFieldConfiguration($typeName, $fieldName, $operators);
                }

                // Get all custom fields defined by custom operators
                foreach ($this->customOperators as $fieldName => $customOperators) {
                    $operators = [];
                    /** @var Filter $customOperator */
                    foreach ($customOperators as $customOperator) {
                        /** @var LeafType $leafType */
                        $leafType = $this->types->get($customOperator->type);
                        $operators[$customOperator->operator] = $leafType;
                    }

                    $filters[] = $this->getFieldConfiguration($typeName, $fieldName, $operators);
                }

                return $filters;
            },
        ]);

        return $type;
    }
1320788
public static function instantiate($className)
    {
        $objectManager = self::get()->getObjectManager();
        $args = func_get_args();

        if (1 === count($args)) {
            return $objectManager->get($className);
        }

        return call_user_func_array([$objectManager, 'get'], $args);
    }
957669
public static function instantiate($className, array $namedArguments)
    {
        $reflectionClass = new ReflectionClass($className);
        $parameters = $reflectionClass->getConstructor()->getParameters();

        $positionalDefaultFilledArguments = array();
        foreach ($parameters as $parameter) {
            // Do we have an argument set? If so use that.
            if (isset($namedArguments[$parameter->name])) {
                $positionalDefaultFilledArguments[] = $namedArguments[$parameter->name];
                continue;
            }

            // Otherwise use the default.
            $positionalDefaultFilledArguments[] = $parameter->getDefaultValue();
        }

        return $reflectionClass->newInstanceArgs($positionalDefaultFilledArguments);
    }
252438
public function bind(Form $form, $class)
    {
        if (!((is_string($class) && class_exists($class)) || ($class instanceof ReflectionClass)))
            throw new BinderException("Provide a classname or a reflection class to bind");

        if ($class instanceof ReflectionClass)
        {
            $refl = $class;
            $class = $refl->getName();
            $isModel = $refl->isSubclassOf(Model::class);
            $isForm = $refl->isSubclassOf(BaseForm::class);
        }
        else
        {
            $refl = new ReflectionClass($class);
            $isModel = $refl->isSubclassOf(Model::class);
            $isForm = $refl->isSubclassOf(BaseForm::class);
        }

        if (!$isModel && !$isForm)
            throw new BinderException("Can only bind subclasses of BaseForm and Model");

        $instance = new $class;
        foreach ($form as $key => $formelement)
        {
            if ($formelement instanceof Form)
                throw new BinderException("Cannot bind nested forms");

            $this->bindValue($formelement, $refl, $instance);
        }
        return $instance;
    }
516371
protected function createClass(string $className)
    {
        if (!class_exists($className)) {
            throw new class("The class $className does not exists") extends Exception implements
                NotFoundExceptionInterface {
            };
        }

        $reflection = new ReflectionClass($className);

        if ($reflection->hasMethod('__construct')) {
            return $reflection->newInstanceArgs($this->arguments);
        }

        return $reflection->newInstance();
    }
401776
public static function addAvailableNamingStrategy($name, $className)
    {
        $ref = new \ReflectionClass($className);
        if (!$ref->isSubclassOf(NamingStrategy::class)) {
            throw new \InvalidArgumentException($className);
        }
        self::$strategies[$name] = $ref->getName();
    }
50634
public function newManager($classname) {
		$profile = Profiler::getClassProfile($classname);
		if (!$profile->isEntity())
			throw new \InvalidArgumentException(sprintf("Class %s is not declared as an entity", $profile->reflectionClass->getName()));
		return new Manager($this, $profile);
	}
558677
public function createObjectState(
        ?ObjectStateCreateData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(ObjectStateCreateType::class);

        return $this->formFactory->createNamed(
            $name,
            ObjectStateCreateType::class,
            $data ?? new ObjectStateCreateData()
        );
    }
481308
public function createForm() : FormInterface
    {
        foreach ($this->value as $key => $val) {
            if (in_array($val['type'], $this->validMethods)) {
                $method = $val['type'];
                unset($val['type']);
                (!method_exists($this, $method)) ?: $this->{$method}($key, $val);
            } else {
                $this->input($key, $val);
            }

            if (isset($val['type']) && in_array($val['type'], $this->validArray)) {
                $this->setValidationError($key, $val);
            } elseif (!isset($val['type']) && in_array($method, $this->validArray)) {
                $this->setValidationError($key, $val);
            }
        }

        return $this;
    }
76517
protected function createComponentForm(string $name): Form
    {
        $form = new Form($this, $name);
        $form->setTranslator($this->translator);
        $this->formContainer->getForm($form);

        $form->onSuccess[] = $this->eventContainer;
        return $form;
    }
805961
public function addResource($name, $className)
    {
        $ref = new \ReflectionClass($className);
        try {
            $ref->implementsInterface(ResourceInterface::class);
        } catch (\ReflectionException $e) {
            throw new \InvalidArgumentException(sprintf('This resource "%s" does not implements ResourceInterface.', $name));
        }

        $this->resources[$name] = $className;
    }
453884
public function getJavaClass($name): Interfaces\JavaClass
    {
        if (!array_key_exists($name, $this->classMapCache)) {
            $this->classMapCache[$name] = new JavaClass($name);
        }

        return $this->classMapCache[$name];
    }
763639
public function makeInstance($className)
    {
        // class reflection
        $reflection = new ReflectionClass($className);
        // get the class constructor
        $constructor = $reflection->getConstructor();

        // if there is no constructor, just create and
        // return a new instance
        if (!$constructor) {
            return $reflection->newInstance();
        }

        // created and returns the new instance passing the
        // resolved parameters
        return $reflection->newInstanceArgs($this->resolveParameters($constructor->getParameters(), []));
    }
539516
private function resolveChild(string $name): FormBuilderInterface
    {
        list($type, $options) = $this->unresolvedChildren[$name];

        unset($this->unresolvedChildren[$name]);

        return $this->children[$name] = $this->create($name, $type, $options);
    }
73043
protected function instance($name)
    {
        $methodName = $this->methodName($name);

        return $this->objectBuild($name, $methodName);
    }