Transform the element to an instance of InputArgument or InputOption.

@param array $element
@return mixed
183551
public function transform(array $element)
    {
        // argument: [name, mode, description, default]
        // option: [name, shortcut, mode, description, default]

        $isArgument = $this->isArgument($element[0]);

        $class = 'Symfony\Component\Console\Input\Input'.($isArgument ? 'Argument' : 'Option');

        $reflector = new \ReflectionClass($class);

        if ($isArgument)
        {
            $element[1] = $this->transformMode($element[1]);
        }
        else
        {
            $element[2] = $this->transformMode($element[2]);
        }

        $element[0] = $this->cleanName($element[0]);

        return $reflector->newInstanceArgs($element);
    }
167157
public function pushScalar(array $element) {
        if(!empty($element['required'])) {
            $this->hasRequired = true;
        }
        if(empty($this->containers)) {
            $this->array += $element;
        } else {
            $this->containers[count($this->containers) - 1][\Illuminate\Support\Arr::get($element, 'id')] = $element;
        }
    }
341493
protected function elementToArray(\SimpleXMLElement $element): array
    {
        $result = [];
        foreach ($element->xpath('*') as $node) {
            if (count($node->xpath('*')) > 0) {
                $value = $this->elementToArray($node);
            } else {
                $value = strval($node);
            }
            $result = array_merge_recursive($result, [$node->getName() => $value]);
        }

        return $result;
    }
891199
public function renderElement($element)
    {
        if (is_string($element)) {
            if (($e = $this[$element]) === null && ($e = $this->getButtons()->itemAt($element)) === null) {
                return $element;
            } else {
                $element = $e;
            }
        }
        if ($element->getVisible()) {
            if ($element instanceof CFormInputElement) {
                if ($element->type === 'hidden') {
                    return TbHtml::tag('div', array('class' => 'hidden'), $element->render());
                }
            }
            return $element->render();
        }
        return '';
    }
398792
public function validate($element) {
        $this->last_error = null;
        $celement   = realpath($element);
        $cvalidator = realpath($this->location.DIRECTORY_SEPARATOR.$this->type);
        $result = (empty($celement) || empty($cvalidator));
        if (!$result) {
            $xml_error = new libxml_errors_mgr();
            $doc = new DOMDocument();
            $doc->validateOnParse = false;
            $result = $doc->load($celement, LIBXML_NONET) &&
                      $doc->schemaValidate($cvalidator);
        }
        return $result;
    }
1231685
public function convert(ElementInterface $element)
    {
        $text = trim($element->getValue(), "\t\n\r\0\x0B");

        $href = $element->getAttribute('href');

        $markdown = $text . ' (' . $href . ')';

        $autolink = $this->isValidAutolink((string) $href);

        $href === $text && $autolink && $markdown = $href;

        return $markdown;
    }
515526
public function addElement(Element $element): Element
    {
        if ($element instanceof FormStatus) {
            if ($this->hasStatus === true) {
                throw new InvalidArgumentException('Form can contain only one FormStatus element');
            }
            $this->hasStatus = true;
        }
        return parent::addElement($element);
    }
121076
public function addFormElement(array $element, $options = array())
    {
        if (array_key_exists($element['name'], $this->formElements)) {
            throw new \Exception('Form element "'.$element['name'].'" is already added, use replaceFormElement() or removeElement() instead');
        }
    	$this->formElements[$element['name']] = $element;
        if (!empty($options) && is_array($options)) {
            $this->formElementOptions[$element['name']] = $options;
        }
        return $this;
    }
1192159
protected function _asArray(\SimpleXMLElement $element)
    {
        $output = $this->_asData($element);

        if (!$element->count()) {
            return $output;
        }

        return $this->_pushArray($output, $element);
    }
1060944
public static function processElement(array $element) {
    $settings = \Drupal::configFactory()->get('openy_map.settings');
    $element['#attached']['library'][] = 'openy_map/openy_map';
    switch ($settings->get('map_engine')) {
      case 'gmaps':
        $element['#attached']['library'][] = 'openy_map/gmaps';
        $element['#attached']['drupalSettings']['openyMapSettings']['engine'] = 'gmaps';
      break;

      case 'leaflet':
      default:
        $element['#attached']['library'][] = 'openy_map/leaflet';
        $mapSettings = &$element['#attached']['drupalSettings']['openyMapSettings'];
        $mapSettings['engine'] = 'leaflet';
        $mapSettings['default_location'] = urlencode(trim(_openy_map_get_default_location()));
        $mapSettings['search_icon'] = $settings->get('leaflet.search_icon');
        $mapSettings['search_icon_retina'] = $settings->get('leaflet.search_icon_retina');
        $mapSettings['base_layer'] = $settings->get('leaflet.base_layer');
      break;
    }
    $element['#attached']['drupalSettings']['openyMap'] = $element['#element_variables'];
    $tags = $settings->get('default_tags');
    $element['#attached']['drupalSettings']['openyMapSettings']['default_tags'] = array_values(array_filter($tags));
    $element['#cache']['tags'][] = 'config:openy_map.settings';

    return $element;
  }
723228
public function getContentForElement(Element $element) : string
    {
        if ($element instanceof HasChildren && $element instanceof HasContent) {
            throw new InvalidArgumentException('An element can only implement one of HasChildren and HasContent');
        }

        if ($element instanceof HasChildren) {
            $renderedChildren = array_map(function(Element $element) {
                return $this->renderElement($element);
            }, $element->getChildren());

            return implode('', $renderedChildren);
        }

        if ($element instanceof HasContent) {
            return $element->getContent();
        }

        return '';
    }
569735
public function formElement(IElement $element)
    {
        if ($element instanceof Textarea) {
            return $this->formTextarea($element);
        } elseif ($element instanceof Select) {
            return $this->formSelect($element);
        } elseif ($element instanceof Submit) {
            return $this->formInput($element);
        } elseif ($element instanceof Button) {
            // todo: is it right?
            throw new InvalidArgumentException("Button element should be rendered without Helper.");
        } else {
            return $this->formInput($element);
        }
    }
1171100
protected function renderInstance(ElementInterface $element)
    {
        $value = $this->getElementValue($element);

        foreach ($this->classMap as $class => $pluginName) {
            if ($value instanceof $class) {
                return $this->renderHelper($pluginName, $value, $element);
            }
        }

        return;
    }
1013325
private static function simpleXmlToArray($element)
    {
        //====================================================================//
        // Safety Check
        if (false === $element) {
            return false;
        }
        //====================================================================//
        // Init Result
        $result = array();
        //====================================================================//
        // Get First Level Childrens
        $children = $element->children();
        $isArrayElement = false;
        //====================================================================//
        // For All Childrens
        foreach ($children as $elementName => $node) {
            //====================================================================//
            // This Element is an ArrayElement
            $isArrayElement = true;
            //====================================================================//
            // If Element Doesn't Already Exists => Store as Single Element
            if (!isset($result[$elementName])) {
                $result[$elementName] = array();
                $result[$elementName] = self::simpleXmlToArray($node);

                continue;
            }
            //====================================================================//
            // Element Already Exists => Store as Array Element
            //====================================================================//
            // Convert Single Element to Array Element
            if (!is_array($result[$elementName])) {
                $singleElement = $result[$elementName];       // Store Firts Element
                $result[$elementName] = array();                    // Create New Array
                $result[$elementName][] = $singleElement;             // Append To Array
            }
            //====================================================================//
            // Append Array Element
            $result[$elementName][] = self::simpleXmlToArray($node);
        }
        //====================================================================//
        // Return Single Element
        if (!$isArrayElement && '' == $children->getName()) {
            $result = base64_decode((string) $element, true);
        }

        return $result;
    }
453008
public function addElement($element) : SidebarBuilderEvent
    {
        if (!is_array($element)) {
            return $this;
        }

        if (!array_key_exists('key', $element)) {
            foreach ($element as $subElement) {
                $this->addElement($subElement);
            }
        } elseif (array_key_exists($element['key'], $this->sidebar['admin'])) {
            if (!array_key_exists('children', $element)) {
                throw new \UnexpectedValueException('no children found for key ' . $element['key']);
            }
            $this->sidebar['admin'][$element['key']]['children'] = array_merge($this->sidebar['admin'][$element['key']]['children'], $element['children']);
        } else {
            $this->sidebar['admin'][$element['key']] = $element;
        }

        return $this;
    }
1178647
public function validate_element( $element ) {
		$type = gettype( $element );
		$callable = $this->type === 'callable';
		$is_object = 'object' === $type;
		$loose_check = $this->type === 'object';

		// callable must be callable
		if ( $callable && ! is_callable( $element ) ) {
			throw new InvalidArgumentException( 'Item must be callable' );
		}

		// target isn't callable, object must be an instance of target
		if ( ! $loose_check && ! $callable && $is_object && ! is_a( $element, $this->type ) ) {
			throw new InvalidArgumentException( "Item is not type or subtype of $this->type" );
		}

		// a non callable, non object type should match the target string
		if ( ! $callable && ! $is_object && $type !== $this->type ) {
			throw new InvalidArgumentException( "Item is not of type: $this->type" );
		}
	}
1192993
protected function extractNodesFromElement($element)
    {
        $references = array();
        if ($this->isNodeChoiceAttribute($element)) {
            $references = array($this->extractNodeFromChoiceAttribute($element));
        } elseif (is_string($element) && $this->hasInternalLinkBBCode($element)) {
            $references = array_merge($references, $this->extractNodeFromBBCode($element));
        } elseif (is_array($element)) {
            foreach ($element as $item) {
                $references = array_merge($references, $this->extractNodesFromElement($item));
            }
        }
        return $references;
    }