Support for multiple elements with the same name

@param string $elementName

@return void
483470
protected function prepareElementName(&$elementName)
    {
        $tempElementName = explode('_', $elementName);
        $elementName = isset($tempElementName[0]) && is_numeric($tempElementName[0])
            ? $tempElementName[1]
            : $elementName;
    }
1274481
public function MoodleQuickForm_header($elementName = null, $text = null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($elementName, $text);
    }
1344222
private function parseAttributes(DOMElement $xml) : void
    {
        $firstAttribute = true;
        /** @var \DOMElement[] $attributes */
        $attributes = Utils::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
        foreach ($attributes as $attribute) {
            if (!$attribute->hasAttribute('Name')) {
                throw new \Exception('Missing name on <saml:Attribute> element.');
            }
            $name = $attribute->getAttribute('Name');

            if ($attribute->hasAttribute('NameFormat')) {
                $nameFormat = $attribute->getAttribute('NameFormat');
            } else {
                $nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
            }

            if ($firstAttribute) {
                $this->nameFormat = $nameFormat;
                $firstAttribute = false;
            } else {
                if ($this->nameFormat !== $nameFormat) {
                    $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
                }
            }

            if (!array_key_exists($name, $this->attributes)) {
                $this->attributes[$name] = [];
                $this->attributesValueTypes[$name] = [];
            }

            $this->parseAttributeValue($attribute, $name);
        }
    }
79047
protected function addNode(DOMElement $element, $key, $value): void
    {
        $key   = \str_replace(' ', '-', $key);
        $child = $this->element($key);
        $element->appendChild($child);
        $this->convert($child, $value);
    }
437721
public function addElement(Element $element)
    {
        if (!in_array($element, $this->elements, true)) {
            array_push($this->elements, $element);
        }
        return $this;
    }
464842
public function remove_element($elementname) {
        if ($this->_form->elementExists($elementname)) {
            return $this->_form->removeElement($elementname);
        } else {
            return false;
        }
    }
1342497
public function removeElement($name)
    {
        $returnValue = false;

		foreach($this->elements as $index => $element){
			if($element->getName() == $name){
				unset($this->elements[$index]);
				$groupName = $this->getElementGroup($name);
				if(!empty($groupName)){
					if(isset($this->groups[$groupName]['elements'][$name])){
						unset($this->groups[$groupName]['elements'][$name]);
					}
				}
				$returnValue = true;
			}
		}

        return $returnValue;
    }
1109178
public function ElementsByName( $names )
	{
		if ( is_string( $names ) )
			$names = array_map( 'trim', explode( ",", $names ) );

		if ( ! is_array( $names ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $names must be a string or array' );

		$names = array_flip( $names );
		return new InstanceElementsFilter( $this->instance, array_intersect_key( $this->elements, $names ) );
	}
1081563
public function isElementHidden($elementName)
	{
		if( $this->settingExists($elementName) ? $settings = $this->getSetting($elementName) : false)
		{
			if(isset($settings['hidden']) && $settings['hidden'] == true)
			{
				return true;
			}
		}
		return false;
	}
850796
public function setName($name)
    {
        $this->name = $name;
        if ($this->node) {
            $this->node->name = $name;
        }
    }
656101
public function setFilename($filename)
    {
        if (is_array($filename) && isset($filename['name'])) {
            $this->filename = $filename['name'];
        } else {
            $this->filename = $filename;
        }
    }
488777
public function isElementNillable($name)
    {
        foreach ($this->element->getElementsByTagName('element') as $element) {
            if ($element->getAttribute('name') == $name && $element->getAttribute('nillable') == true) {
                return true;
            }
        }
        return false;
    }
667611
public function add($element)
    {
        if (!$this->contains($element)) {
            $hashIndex = $this->hashIndex($element);

            $this->_items[$hashIndex] = $element;
            $this->_iterator = null;
            return true;
        } else {
            // element already exist
            return false;
        }
    }
134998
public function setPlaceholderParameter($name, $value, $elementName = null)
    {
        if (null != $elementName) {
            $this->placeholderParameters['element'][$elementName][$name] = $value;
        } else {
            $this->placeholderParameters['global'][$name] = $value;
        }
        return $this;
    }
1049900
public void clearNamespaces( String elementName ) {
      if( StringUtils.isBlank( elementName ) ){
         rootNamespace.clear();
      }else{
         namespacesPerElement.remove( elementName );
      }
   }
279086
protected function allowElementWithSafety($elName, $allowUnsafe)
	{
		$elName  = $this->normalizeElementName($elName);
		$tagName = $this->prefix . ':' . $elName;

		if (!$allowUnsafe && in_array($elName, $this->unsafeElements))
		{
			throw new RuntimeException("'" . $elName . "' elements are unsafe and are disabled by default. Please use " . __CLASS__ . '::allowUnsafeElement() to bypass this security measure');
		}

		// Retrieve or create the tag
		$tag = ($this->configurator->tags->exists($tagName))
		     ? $this->configurator->tags->get($tagName)
		     : $this->configurator->tags->add($tagName);

		// Rebuild this tag's template
		$this->rebuildTemplate($tag, $elName, $allowUnsafe);

		// Record the element name
		$this->elements[$elName] = 1;

		return $tag;
	}
1234197
function setElementTemplate($html, $element = null)
    {
        if (is_null($element)) {
            $this->_elementTemplate = $html;
        } else {
            $this->_templates[$element] = $html;
        }
    }