@param string $type
@param string $name

@return ElementInterface
@throws InvalidClassException
@throws UnknownTypeException
763691
private function buildElement(string $type, string $name): ElementInterface
    {
        if (class_exists($type)) {
            $element = new $type($name);

            if (! $element instanceof ElementInterface) {
                throw new InvalidClassException(
                    sprintf(
                        'The given type "%s" does not implement %s.',
                        $type,
                        ElementInterface::class
                    )
                );
            }

            return $element;
        }

        if (isset($this->typeToElement[$type])) {
            return new $this->typeToElement[$type]($name);
        }

        throw new UnknownTypeException(
            sprintf(
                'The given type "%s" will not create a valid class which implements "%s"',
                $type,
                ElementInterface::class
            )
        );
    }
469490
protected function addComplexType($type, $name = false, $parent = false)
    {
        if (!$parent) {
            //outline element
            //check if the complexType doesn't already exists
            if (isset($this->types[$name])) {
                return $this->types[$name];
            }
            //create the complexType tag beneath the xsd:schema tag
            $complexTypeTag = $this->addElement('xsd:complexType', $this->parentElement);
            if ($name) {
                //might be an anonymous element
                $complexTypeTag->setAttribute('name', $name);
                $this->types[$name] = $complexTypeTag;
            }
        } else {
            //inline element
            $complexTypeTag = $this->addElement('xsd:complexType', $parent);
        }

        $tag = $this->addElement('xsd:all', $complexTypeTag);
        //check if it has the name 'object()' (kind of a stdClass)
        if (strtolower(substr($type, 0, 6)) == 'object') {
            //stdClass
            $content = substr($type, 7, -1);
            $properties = explode(',', $content);//split the content into properties
            foreach ($properties as $property) {
                if (strpos($property, '=>') !== false) {
                    //array with keys (order is important, so use 'sequence' tag)
                    list($keyType, $valueType) = explode('=>', $property);
                    $el = $this->addTypeElement($valueType, $keyType, $tag);
                } else {
                    throw new WSDLException('Error creating WSDL: expected "=>". When using the object() as type, use it as object(paramname=>paramtype,paramname2=>paramtype2)', 100);
                }
            }
        } else { //should be a known class
            if (!class_exists($name)) {
                throw new WSDLException("Error creating WSDL: no class found with the name '$name' / $type : $parent, so how should we know the structure for this datatype?", 101);
            }
            $v = new IPReflectionClass($name);
            $properties = $v->getProperties(false, false, false);//not protected and private properties

            foreach ((array) $properties as $property) {
                if (!$property->isPrivate) {
                    $el = $this->addTypeElement($property->type, $property->name, $tag, $property->optional);
                }
            }
        }

        return $complexTypeTag;
    }
262634
public static function getType($name, &$type=null) {
		if( !isset(static::$types[$name]) ) {
			throw new Exception('unknownType_'.$name);
		}
		$type	= &static::$types[$name];
		return $type;
	}
937857
public function setValidator($name, $element)
    {
        $name = trim($name);
        if ($name === '') {
            throw new InvalidArgumentException('Empty rule name');
        } elseif (is_array($element) && !empty($element['type'])) {
            $element['parent'] = $this;
            $type = $element['type'];
            unset($element['type']);
            $validator = $this->createValidator($type, $element);
        } elseif (true === ($element instanceof \marvin255\serviform\interfaces\Validator)) {
            $element->setParent($this);
            $validator = $element;
        } else {
            throw new InvalidArgumentException('Wrong child type for rule: ' . $name);
        }
        $this->validators[$name] = $validator;

        return $this;
    }
635612
public function getType($name)
    {
        if (false === $this->hasType($name)) {
            throw new InvalidArgumentException(sprintf('The type "%s" was not found.', $name));
        }
        if (isset($this->loaded[$name])) {
            return $this->loaded[$name];
        }
        $fqcn = $this->types[$name];
        $type = new $fqcn;

        if (!$type instanceof TypeInterface) {
            throw new InvalidArgumentException(sprintf('The class "%s" must implement the "%s\\Types\TypeInterface"', $fqcn, __NAMESPACE__));
        }

        return $this->loaded[$name] = new $fqcn;
    }
1220618
protected function createQuestion(string $name, $type): Question
    {
        if (!is_int($type)) {
            $type = strtoupper($type);
            $types = static::getRecordTypes();
            if (!array_key_exists($type, $types)) {
                throw new InvalidTypeError($type);
            }
            $type = $types[$type];
        } elseif (0 > $type || 0xffff < $type) {
            throw new InvalidTypeError($type);
        }

        $question = $this->questionFactory->create($type);
        $question->setName($name);

        return $question;
    }
960636
public function create($name, $type, array $options)
    {
        if (is_string($type)) {
            $type = $this->registry->getType($type);
        }
        if (!$type instanceof WidgetTypeInterface) {
            throw new \InvalidArgumentException('Unexpected widget type.');
        }

        $options['name'] = $name;

        $resolver = new OptionsResolver();
        $type->configureOptions($resolver);
        $options = $resolver->resolve($options);

        $widget = new Widget($name, $type);
        $type->buildWidget($widget, $options);

        return $widget;
    }
156493
public function getTypeByName($name)
    {
        foreach ($this->collection as $type) {
            /** @var $type TypeInterface */
            if ($type->getName() === $name) {
                return $type;
            }
        }

        throw new \RuntimeException(\sprintf('No type found for name %s, list: %s', \var_export($name, true), \var_export($this->collection, true)));
    }
1124044
public static function input($type, $name, $attributes)
    {
        // Set id attribute to be same as the name
        // if one has not been set
        if (!isset($attributes['id'])) {
            $attributes['id'] =  $name;
        }

        // Check if the value is set in the
        // attributes array
        if (isset($attributes['value'])) {
            $value = $attributes['value'];
        }
        // Check if its in the _POST array
        elseif (isset($_POST[$name])) {
            $value = $_POST[$name];
        }
        // It's nowhere...
        else {
            $value = '';
        }

        // Add selected or checked attribute?
        foreach (array('selected', 'checked') as $attr) {
            if (isset($attributes[$attr]) and !$attributes[$attr]) {
                unset($attributes[$attr]);
            } elseif (isset($attributes[$attr])) {
                $attributes[$attr] = $attr;
            }
        }

        // Merge default attributes with
        // the specified attributes.
        $attributes = array_merge(array('type' => $type, 'name' => $name), $attributes);

        // Textareas
        if ($type == 'textarea') {
            return "<textarea " . HTML::buildAttributes($attributes) . ">{$value}</textarea>";
        }
        // Everything else
        else {
            // Don't pass the checked attribute if its false.
            if (isset($attributes['checked']) and !$attributes['checked']) {
                unset($attributes['checked']);
            }
            return "<input " . HTML::buildAttributes($attributes) . ">";
        }
    }
1354009
public static function passive(string $name, Type $type): self
    {
        $self = new self($name, $type);
        $self->passive = true;

        return $self;
    }
121289
public function sendXml($type, $name, $xml)
    {
        $this->factory
            ->setBuilder($this->getBuilder($type))
            ->setSender($this->getSender($type));

        return $this->factory->sendXml($name, $xml);
    }
848540
private function instanciateField(string $name, string $type): FieldInterface
    {
        $fieldClass = $this->getFieldClass($type);
        $field = new $fieldClass($name);

        if (!$field instanceof FieldInterface) {
            throw new Exception("Field class \"{$fieldClass}\" must implements ".FieldInterface::class);
        }

        if ($field instanceof TranslatorAwareFieldInterface) {
            $field->setTranslator($this->translator);
        }
        if ($field instanceof TwigAwareFieldInterface) {
            $field->setTwig($this->twig);
        }

        return $field;
    }
329997
public function get($type, $name)
    {
        return isset($this->clients[$type][$name]) ? $this->clients[$type][$name] : null;
    }
1290499
public function createColumn($name, $type = null, array $options = [])
    {
        $this->preventIfLocked();

        if (null !== $type) {
            return $this->getFactory()->createColumnBuilder($name, $type, $options);
        }

        throw new \InvalidArgumentException('Column type guessing is not yet supported.');
        // TODO return $this->getFormFactory()->createBuilderForProperty($this->getDataClass(), $name, $options);
    }
490353
public function getType($name)
    {
        if ($this->hasType($name)) {
            return $this->types[$name];
        } else {
            throw new \InvalidArgumentException(sprintf('Widget type "%s" not found.', $name));
        }
    }
895137
public function orderBy(?string $name, string $type = self::ORDER_ASC): AbstractRepository
    {
        $this->sorter['name'] = $name;
        $this->sorter['type'] = $type;

        return $this;
    }
453511
public function getType($name)
    {
        if (class_exists($name) || interface_exists($name)) {
            if ($this->hasTypeForClass($name)) {
                $name = $this->getTypeForClass($name);
            }
        }

        if (!$this->hasType($name)) {
            throw new \UnexpectedValueException(sprintf('Does not exist a valid definition for "%s" type', $name));
        }

        return $this->types[$name];
    }