Get array "struct" from XML.

@param bool $ignoreWhitespace
@param bool $ignoreCase

@return array

@see xml_parse_into_struct
504586
public function struct($ignoreWhitespace, $ignoreCase)
    {
        $parser = xml_parser_create();

        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE,  $ignoreWhitespace ? 1 : 0);

        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, $ignoreCase ? 1 : 0);

        xml_parse_into_struct($parser, $this->root()->asXml(), $struct, $index);

        xml_parser_free($parser);

        return $struct;
    }
403512
public function toArray($ignore = [])
    {
        return [
            'siteId' => $this->getSiteId(),
            'pageId' => $this->getPageId(),
            'name' => $this->getName(),
            'author' => $this->getAuthor(),
            'createdDate' => $this->getCreatedDateString(\DateTime::ISO8601),
            'lastPublished' => $this->getLastPublishedString(\DateTime::ISO8601),
            'pageLayout' => $this->getPageLayout(),
            'siteLayoutOverride' => $this->getSiteLayoutOverride(),
            'pageTitle' => $this->getPageTitle(),
            'description' => $this->getDescription(),
            'keywords' => $this->getKeywords(),
            'pageType' => $this->getPageType(),
        ];
    }
468350
static function getDocument($html, $ignore_error = false) {

		$doc = new \DOMDocument();

		$html = trim($html);

		if (!$html) {
			// DOMDocument doesn't support empty value and throws an error
			// Return empty document instead
			return $doc;
		}

		if ($html[0] !== '<') {
			// If HTML does not begin with a tag, we put a body tag around it.
			// If we do not do this, PHP will insert a paragraph tag around
			// the first block of text for some reason which can mess up
			// the newlines. See pre.html test for an example.
			$html = '<body>' . $html . '</body>';
		}

		if ($ignore_error) {
			$doc->strictErrorChecking = false;
			$doc->recover = true;
			$doc->xmlStandalone = true;
			$old_internal_errors = libxml_use_internal_errors(true);
			$load_result = $doc->loadHTML($html, LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NONET | LIBXML_PARSEHUGE);
			libxml_use_internal_errors($old_internal_errors);
		}
		else {
			$load_result = $doc->loadHTML($html);
		}

		if (!$load_result) {
			throw new Html2TextException("Could not load HTML - badly formed?", $html);
		}

		return $doc;
	}
119993
protected function getValueCollection(SimpleXMLElement $content, array $matches, $default = null)
    {
        $parent = $matches[1];
        $namespace = null;

        if (\strpos($parent, '/') !== false) {
            list($parent, $namespace) = \explode('/', $parent, 2);
        }

        $collection = data_get($content, $parent);
        $namespaces = $this->getAvailableNamespaces();

        $uses = $this->parseBasicUses($matches[2]);

        $values = [];

        if (! $collection instanceof SimpleXMLElement) {
            return $default;
        }

        foreach ($collection as $content) {
            if (empty($content)) {
                continue;
            }

            if (! \is_null($namespace) && isset($namespaces[$namespace])) {
                $content = $content->children($namespaces[$namespace]);
            }

            $values[] = $this->parseValueCollection($content, $uses);
        }

        return $values;
    }
863363
private function generateTableRows (array $namespaces, bool $hasDuplicatePath, array $pathMap) : array
    {
        $rows = [];

        foreach ($namespaces as $namespace => $path)
        {
            $row = [
                "<fg=yellow>@{$namespace}</>",
                $path,
            ];

            if ($hasDuplicatePath)
            {
                $warning = $pathMap[$path] > 1
                    ? '<fg=red>\\<!></>'
                    : '';

                \array_unshift($row, $warning);
            }


            $rows[$namespace] = $row;
        }

        // sort namespaces alphabetically
        ksort($rows);

        return  $rows;
    }
1056864
private function SkipWhitespace()
	{
		do
		{
			// if ( XmlCharType.Instance.IsWhiteSpace( $this->Peek( 0 ) ) )
			if ( preg_match( "/\s/", $this->Peek( 0 ) ) )
			{
				$c;
				while ( ( $c = $this->Peek( 0 ) ) && ord( $c ) != 0 && preg_match( "/\s/", $c ) )
				{
					$this->Read();
				}
				continue;
			}
			if ( $this->Peek( 0 ) == '(' && $this->Peek( 1 ) == ':' )
			{
				$this->Read();
				$this->Read();
				$n = 1;
				while ( true )
				{
					$c = $this->Peek( 0 );
					if ( ord( $c ) == 0 )
					{
						break;
					}
					else if ( $c == '(' && $this->Peek( 1 ) == ':' )
					{
						$this->Read();
						$this->Read();
						$n++;
					}
					else if ( $c == ':' && $this->Peek( 1 ) == ')' )
					{
						$this->Read();
						$this->Read();
						if ( --$n == 0 )
						{
							break;
						}
					}
					else
					{
						$this->Read();
					}
				}
				if ( $n )
				{
					throw XPath2Exception::withErrorCodeAndParam( "XPST0003", Resources::XPST0003, "Comment not closed" );
				}
				continue;
			}
			break;
		}
		while ( true );
	}
840296
public static function simpleArrayToXml($array, $suppress_empty = false)
    {
        $xml = '';
        foreach ($array as $key => $value) {
            $value = trim($value, " ");
            if (empty($value) and (bool)$suppress_empty) {
                continue;
            }
            $htmlValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
            if ($htmlValue != $value) {
                $xml .= "\t" . "<$key>$htmlValue</$key>\n";
            } else {
                $xml .= "\t" . "<$key>$value</$key>\n";
            }
        }

        return $xml;
    }
67803
private function arrayWhitespace($loc): ?string
    {
        $tokens = $this->getTokenStream();
        $type   = $tokens->type($loc);
        switch ($type) {
            case T_DOUBLE_ARROW:
                return ' => ';
            case ',':
                return ', ';
            default:
                return $tokens->value($loc);
        }
    }
1043560
function toArray($user_message = true, $ignore = [])
    {
        $result = array(
            'code' => $this->code,
            'message' => $user_message ? $this->getUserMessage() : (empty($this->args)?$this->message:array($this->message, $this->args)),
            'children' => []
        );
        foreach ($this->children as $name => $e){
            if (!in_array($name, $ignore, true)){
                if ($e instanceof Error){
                    $result['children'][$name] = $e->toArray($user_message);
                }else{
                    /** @var $e Exception */
                    $result['children'][$name] = array(
                        'code' => $this->getCode(),
                        'message' => $this->getMessage(),
                    );
                }
            }
        }
        return $result;
    }
917207
function getPropertyWhitespace(property) {
            const whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice(
                property.key.range[1], property.value.range[0]
            ));

            if (whitespace) {
                return {
                    beforeColon: whitespace[1],
                    afterColon: whitespace[2]
                };
            }
            return null;
        }
813740
public function extractDefaultDataFromDataStructure($dataStructure)
    {
        $returnXML = '';
        $sheetArray = [];
        if ($dataStructure) {
            $structureArray = GeneralUtility::xml2array($dataStructure);
            if (!isset($structureArray['sheets']) && isset($structureArray['ROOT'])) {
                $structureArray['sheets']['sDEF']['ROOT'] = $structureArray['ROOT'];
                unset($structureArray['ROOT']);
            }
            if (isset($structureArray['sheets']) && !empty($structureArray['sheets'])) {
                foreach ($structureArray['sheets'] as $sheetName => $sheet) {
                    if (is_array($sheet['ROOT']['el']) && !empty($sheet['ROOT']['el'])) {
                        $elArray = [];
                        foreach ($sheet['ROOT']['el'] as $elName => $elConf) {
                            $config = $elConf['TCEforms']['config'];
                            $elArray[$elName]['vDEF'] = $config['default'];
                            if (!$elArray[$elName]['vDEF'] && $config['type'] === 'select' && !empty($config['items'])) {
                                $elArray[$elName]['vDEF'] = $config['items'][0][1];
                            }
                        }
                        $sheetArray['data'][$sheetName]['lDEF'] = $elArray;
                    }
                }
            }
            if (!empty($sheetArray)) {
                $flexformTools = GeneralUtility::makeInstance(FlexFormTools::class);
                $returnXML = $flexformTools->flexArray2Xml($sheetArray, true);
            }
        }

        return $returnXML;
    }
739565
protected function getArrayForSpecialCase($xml)
    {
        $regEx            = '#\s*(&lt;\?xml.*interface&gt;)\s*#is';
        $regExReplace     = '#\s*>\s*(&lt;\?xml.*interface&gt;)\s*<[^>]+>\s*#is';
        $regExReplaceWith = '/>';

        // what can happen is that the valid XML element suddenly has,
        // as its element content, a full version of url-encoded XML.
        if ( ! preg_match($regEx, $xml)) {
            return [0 => $xml];
        }
        $xml = preg_replace($regExReplace, $regExReplaceWith, $xml);

        return $this->parse($xml);
    }
1258745
public static function create(bool $allowSerializeEmpty = false): ArrayNode
    {
        $node = new self();
        $node->allowSerializeEmpty = $allowSerializeEmpty;

        return $node;
    }
1158711
private function getWebspaceKey(Request $request, $ignoreWebspaces)
    {
        if ($ignoreWebspaces) {
            return null;
        }

        $sulu = $request->get('_sulu');
        if (!$sulu) {
            return null;
        }

        /** @var Webspace $webspace */
        $webspace = $sulu->getAttribute('webspace');
        if (!$webspace) {
            return null;
        }

        return $webspace->getKey();
    }
1275284
public static boolean containsAny(final String str, final String[] list, final boolean ignoreCase) {
        
        if(str == null) {
            return false;
        }
        
        if(list == null || list.length == 0) {
            return false;
        }
        
        for(String item : list) {
            if(ignoreCase) {
                if(containsIgnoreCase(str, item)) {
                    return true;
                }
            } else {
                if(str.indexOf(item) >= 0) {
                    return true;
                }
                
            }
        }
        
        return false;
        
    }
993976
public function toArray($ignore = ['pages', 'containers', 'sitePlugins'])
    {
        $data = parent::toArray($ignore);

        if (!in_array('pages', $ignore)) {
            $data['pages'] = $this->modelArrayToArray(
                $this->getPages()->toArray(),
                ['parent', 'site', 'revisions']
            );
        }

        if (!in_array('containers', $ignore)) {
            $data['containers'] = $this->modelArrayToArray(
                $this->getContainers()->toArray(),
                ['parent', 'site', 'revisions']
            );
        }

        if (!in_array('domainId', $ignore)) {
            $data['domainId'] = $this->getDomainId();
        }
        if (!in_array('domainName', $ignore)) {
            $data['domainName'] = $this->getDomainName();
        }
        if (!in_array('languageId', $ignore)) {
            $data['languageId'] = $this->getLanguageId();
        }
        if (!in_array('languageIso6392t', $ignore)) {
            $data['languageIso6392t'] = $this->getLanguageIso6392t();
        }
        if (!in_array('countryId', $ignore)) {
            $data['countryId'] = $this->getCountryId();
        }
        if (!in_array('locale', $ignore)) {
            $data['locale'] = $this->getLocale();
        }

        return $data;
    }
324909
public function match($token, $ignoreSpaces = true)
    {
        switch($token) {
        case Tokens::T_WHITESPACE:
            $pos = $this->getPosAfterSpaces($this->pos);

            $spaces = substr($this->value, $this->pos, $pos - $this->pos);

            $this->pos = $pos;
            return $spaces;
        case Tokens::T_IDENTIFIER:
            if($ignoreSpaces) {
                $this->ignoreSpaces();
            }
            //
            if(preg_match('/^[\w\d_]+/i', substr($this->value, $this->pos), $matches))
            {
                $identifier = $matches[0];
                $this->pos += strlen($identifier);
                return $identifier;
            }

            throw new \InvalidArgumentException(sprintf('T_IDENTIFIER is not matched with next token.'));
            break;
        default:
            $literal = $this->literals->getLiteralForToken($token);
            
            if($this->literals->isSpace($literal)) {
                $ignoreSpaces = false;
            }
            if($ignoreSpaces) {
                $this->ignoreSpaces();
            }
            // If next token is match with the literal, forward the point
            if($literal !== substr($this->value, $this->pos, strlen($literal))) {
                throw new \InvalidArgumentException(sprintf('Token "%s" is not match with next token on "%s"', $literal, substr($this->value, $this->pos)));
            }
            // 
            $this->pos += strlen($literal);

            return $literal;
            break;
        }
    }