Wraps a type into a ResolvedFormTypeInterface implementation and connects
it with its parent type.

@param FormTypeInterface $type The type to resolve

@return ResolvedFormTypeInterface The resolved type
199136
private function resolveType(FormTypeInterface $type)
    {
        $typeExtensions = [];
        $parentType = $type->getParent();
        $fqcn = \get_class($type);

        if (isset($this->checkedTypes[$fqcn])) {
            $types = implode(' > ', array_merge(array_keys($this->checkedTypes), [$fqcn]));
            throw new LogicException(sprintf('Circular reference detected for form type "%s" (%s).', $fqcn, $types));
        }

        $this->checkedTypes[$fqcn] = true;

        try {
            foreach ($this->extensions as $extension) {
                $typeExtensions = array_merge(
                    $typeExtensions,
                    $extension->getTypeExtensions($fqcn)
                );
            }

            return $this->resolvedTypeFactory->createResolvedType(
                $type,
                $typeExtensions,
                $parentType ? $this->getType($parentType) : null
            );
        } finally {
            unset($this->checkedTypes[$fqcn]);
        }
    }
580477
public function converter(callable $callback, string ...$types): ResolverInterface
    {
        $rule = RuleFactory::converter($callback, ...$types);
        $this->addRule($rule, self::LOW_PRIORITY);

        return $this;
    }
961647
public static function fromType(TypeInterface $type, array $options = []): self
    {
        $optionsResolver = new OptionsResolver();

        $type->configureOptions($optionsResolver);

        $options = $optionsResolver->resolve($options);

        $builder = new self();

        $type->buildMessage($builder, $options);

        return $builder;
    }
1278032
private function resolveDataSource(FormInterface $form)
    {
        if ($form->isRoot()) {
            // Nothing to do if root
            $dataForm = $form->getData();
        } else {
            $dataForm = $form;
            while ($dataForm->getConfig()->getDataClass() === null) {
                $dataForm = $form->getParent();
            }
        }

        $data = $dataForm->getData();
        return array(
            $data,
            $data === null ? $dataForm->getConfig()->getDataClass() : get_class($data)
        );
    }
986753
public function usingTypecast(TypeCastInterface $typecast): HandlerInterface
    {
        $handler = clone $this;
        $handler->typecast = $typecast;

        return $handler;
    }
126302
private function resolve($reflection, Type $type = null)
    {
        if ($type === null) {
            return null;
        }

        if (
            method_exists($reflection, 'getDeclaringClass') && (
                $type instanceof This ||
                $type instanceof Self_ ||
                $type instanceof Static_ ||
                $type instanceof Parent_
            )
        ) {
            $class = $reflection->getDeclaringClass()->getName();

            if ($type instanceof Parent_) {
                $class = get_parent_class($class) ?: $class;
            }

            return new Object_(new Fqsen('\\' . $class));
        }

        return $type;
    }
670606
protected function build($type)
    {
        if ($concrete = array_get($this->aliases, $type)) {
            return $this->resolved[$type] = new $concrete($this);
        }

        throw new InternalServerErrorException;
    }
440535
private function createFormView(FormInterface $form)
    {
        $themes = $this->getParameterResolver()->resolveThemes();
        $view = $form->createView();

        if (!empty($themes)) {
            $this->formRenderer->setTheme($view, $themes);
        }

        return $view;
    }
833973
public function setType(string $type = self::TYPE_HIDDEN): InputInterface
    {
        $this->type = $type;

        return $this;
    }
486609
private function resolveSingleType($type, Context $context)
    {
        switch (true) {
            case $this->isKeyword($type):
                return $this->resolveKeyword($type);
            case $this->isTypedArray($type):
                return $this->resolveTypedArray($type, $context);
            case $this->isFqsen($type):
                return $this->resolveTypedObject($type);
            case $this->isPartialStructuralElementName($type):
                return $this->resolveTypedObject($type, $context);
            // @codeCoverageIgnoreStart
            default:
                // I haven't got the foggiest how the logic would come here but added this as a defense.
                throw new \RuntimeException(
                    'Unable to resolve type "' . $type . '", there is no known method to resolve it'
                );
        }

        // @codeCoverageIgnoreEnd
    }
819138
public function create($formType, InputInterface $input, array $options = [])
    {
        $options = $this->addDefaultOptions($options);

        $formBuilder = $this->formFactory->createBuilder(FormUtil::formTypeToString($formType), null, $options);

        foreach ($formBuilder as $name => $childBuilder) {
            /* @var FormBuilderInterface $childBuilder */
            if (!$input->hasOption($name)) {
                continue;
            }

            $providedValue = $input->getOption($name);
            if ($providedValue === null) {
                continue;
            }

            $childBuilder->setData($providedValue);
        }

        return $formBuilder->getForm();
    }
953630
public function forType(string $type): HandlerInterface
    {
        $class = $type !== 'object' ? $type : null;

        if ($class === $this->class) {
            return $this;
        }

        $handler = clone $this;
        $handler->class = $class;

        return $handler;
    }
421774
public function onAddedToType(TypeInterface &$type)
    {
        parent::onAddedToType($type);

        if ($this->getAddIndex()) {
            $type->addIndex(new Index($this->name));
        }

        $type->addTrait(UpdatedAtInterface::class, UpdatedAtInterfaceImplementation::class)->serialize($this->name);
    }
248717
private function resolveAndAddType(TableTypeInterface $type)
    {
        $parentType = $type->getParent();

        if ($parentType instanceof TableTypeInterface) {
            $this->resolveAndAddType($parentType);
            $parentType = $parentType->getName();
        }

        $typeExtensions = array();

        foreach ($this->extensions as $extension) {
            $typeExtensions = array_merge(
                $typeExtensions,
                $extension->getTypeExtensions($type->getName())
            );
        }

        $this->types[$type->getName()] = $this->resolvedTypeFactory->createResolvedType(
            $type,
            $typeExtensions,
            $parentType ? $this->getType($parentType) : null
        );
    }
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);
    }
213003
private function resolveFilterType(Filter\FilterTypeInterface $type)
    {
        $typeExtensions = [];
        $parentType = $type->getParent();
        $class = get_class($type);

        foreach ($this->extensions as $extension) {
            $typeExtensions = array_merge(
                $typeExtensions,
                $extension->getFilterTypeExtensions($class)
            );
        }

        return $this->resolvedTypeFactory->createResolvedFilterType(
            $type,
            $typeExtensions,
            $parentType ? $this->getFilterType($parentType) : null
        );
    }
61401
private function resolveAndAddType(JobTypeInterface $type)
    {
        $parentType = $type->getParent();

        if ($parentType instanceof JobTypeInterface) {
            $this->resolveAndAddType($parentType);
            $parentType = $parentType->getName();
        }

        $typeExtensions = array();

        foreach ($this->extensions as $extension) {
            /* @var FormExtensionInterface $extension */
            $typeExtensions = array_merge(
                $typeExtensions,
                $extension->getTypeExtensions($type->getName())
            );
        }

        $this->types[$type->getName()] = new ResolvedJob(
            $type, 
            $typeExtensions,
            $parentType ? $this->getType($parentType) : null
        );
    }