Iterates all <line></line> nodes and produces an array holding line coverage information.
@param \SimpleXMLElement $node The XML node holding the <line></line> nodes
@return array: (lineNumber -> hits)
965708
private function getLineCoverage(\SimpleXMLElement $node)
    {
        $lineCoverage = (object)array();
        if ($node->file->coverage) {
            foreach ($node->file->coverage->line as $line) {
                $count = $line->covered->count();
                $nr = (string)$line["nr"];
                $lineCoverage->$nr = $count;
            }
        }
        return $lineCoverage;
    }
1074890
public function getNode( $node )
	{
		for( $i=0; $i<$this->count(); $i++ )
			if( $this->nodes[$i]->getNodeName() == $node )
				return $this->nodes[$i];
		return NULL;
	}
964105
private function getReplacementNodes(Element $node): NodeList {
        $nodesToReturn = $node->newNodeList();
        $nodesToRemove = $node->newNodeList();
        $replacementNodes = $node->newNodeList();

        $fnCompareSiblingNodes = function($node) {
            if ($node->is(':not(a)') || $node->nodeType == XML_TEXT_NODE) {
                return true;
            }
        };

        foreach ($node->contents() as $child) {
            if ($child->is('p') && $replacementNodes->count()) {
                $nodesToReturn[] = $this->getFlushedBuffer($replacementNodes);
                $replacementNodes->fromArray([]);
                $nodesToReturn[] = $child;
            } else if ($child->nodeType == XML_TEXT_NODE) {
                $replaceText = $child->text();

                if (!empty($replaceText)) {
                    // Get all previous sibling <a> nodes, the current text node, and all next sibling <a> nodes.
                    $siblings = $child
                        ->precedingUntil($fnCompareSiblingNodes, 'a')
                        ->merge([$child])
                        ->merge($child->followingUntil($fnCompareSiblingNodes, 'a'));

                    foreach ($siblings as $sibling) {
                        // Place current nodes textual contents in-between previous and next nodes.
                        if ($sibling->isSameNode($child)) {
                            $replacementNodes[] = new Text($replaceText);

                        // Grab the contents of any unprocessed <a> siblings and flag them for removal.
                        } else if ($sibling->getAttribute('grv-usedalready') != 'yes') {
                            $sibling->setAttribute('grv-usedalready', 'yes');

                            $replacementNodes[] = $sibling->cloneNode(true);
                            $nodesToRemove[] = $sibling;
                        }

                    }
                }

                $nodesToRemove[] = $child;
            } else {
                if ($replacementNodes->count()) {
                    $nodesToReturn[] = $this->getFlushedBuffer($replacementNodes);
                    $replacementNodes->fromArray([]);
                }

                $nodesToReturn[] = $child;
            }
        }

        // Flush any remaining replacementNodes left over from text nodes.
        if ($replacementNodes->count()) {
            $nodesToReturn[] = $this->getFlushedBuffer($replacementNodes);
        }

        // Remove potential duplicate <a> tags.
        foreach ($nodesToReturn as $key => $return) {
            if ($nodesToRemove->exists($return)) {
                unset($nodesToReturn[$key]);
            }
        }

        $nodesToRemove->remove();

        return $nodesToReturn;
    }
1157593
protected function getCurrentDimensionPresetIdentifiersForNode($node)
    {
        $targetPresets = $this->contentDimensionsPresetSource->findPresetsByTargetValues($node->getDimensions());
        $presetCombo = [];
        foreach ($targetPresets as $dimensionName => $presetConfig) {
            $fullPresetConfig = $this->contentDimensionsPresetSource->findPresetByDimensionValues($dimensionName, $presetConfig['values']);
            $presetCombo[$dimensionName] = $fullPresetConfig['identifier'];
        }
        return $presetCombo;
    }
739564
public static function get_ancestors( \DOMNode $node ) {
		$result = [];

		while ( ( $node = $node->parentNode ) && ( $node instanceof \DOMElement ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
			$result[] = $node;
		}

		return $result;
	}
818974
public function filter($node)
    {
        $ret = array();
        $items = $this->_combinator->filter($node, $this->_element->getTagName());

        // filters items by element
        foreach ($items as $item) {
            if ($this->_element->match($item)) {
                array_push($ret, $item);
            }
        }

        // filter items by element filters
        $filters = $this->_element->getFilters();
        foreach ($filters as $filter) {
            $items = array();
            foreach ($ret as $i => $item) {
                if ($filter->match($item, $i, $ret)) {
                    array_push($items, $item);
                }
            }
            $ret = $items;
        }

        return $ret;
    }
555773
protected function formatStringCellValue($node)
    {
        $pNodeValues = [];
        $pNodes = $node->getElementsByTagName(self::XML_NODE_P);

        foreach ($pNodes as $pNode) {
            $currentPValue = '';

            foreach ($pNode->childNodes as $childNode) {
                if ($childNode instanceof \DOMText) {
                    $currentPValue .= $childNode->nodeValue;
                } else if ($childNode->nodeName === self::XML_NODE_S) {
                    $spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C);
                    $numSpaces = (!empty($spaceAttribute)) ? intval($spaceAttribute) : 1;
                    $currentPValue .= str_repeat(' ', $numSpaces);
                } else if ($childNode->nodeName === self::XML_NODE_A || $childNode->nodeName === self::XML_NODE_SPAN) {
                    $currentPValue .= $childNode->nodeValue;
                }
            }

            $pNodeValues[] = $currentPValue;
        }

        $escapedCellValue = implode("\n", $pNodeValues);
        $cellValue = $this->escaper->unescape($escapedCellValue);
        return $cellValue;
    }
1104449
public static function parse(\SimpleXMLElement $node)
	{
		if ($node->getName() != self::$tagName) {
			return null;
		}

		$bounds = new Bounds();

		$bounds->minLatitude = isset($node['minlat']) ? (float) $node['minlat'] : null;
		$bounds->minLongitude = isset($node['minlon']) ? (float) $node['minlon'] : null;
		$bounds->maxLatitude = isset($node['maxlat']) ? (float) $node['maxlat'] : null;
		$bounds->maxLongitude = isset($node['maxlon']) ? (float) $node['maxlon'] : null;

		return $bounds;
	}
1270203
public function transform($node)
    {
        $blocksData = $this->transformBlock($node);
        $documentData = array(
            'id' => $node->getNodeId() . '-' . $node->getLanguage(). '-' . $node->getSiteId(),
            'elementId' => $node->getId(),
            'nodeId' => $node->getNodeId(),
            'siteId' => $node->getSiteId(),
            'language' => $node->getLanguage(),
            'name' => $node->getName(),
            'blocks' => $blocksData
        );

        if (!is_null($node->getUpdatedAt())) {
            $documentData['updatedAt'] = $node->getUpdatedAt()->getTimestamp();
        }

        $document = new Document($documentData['id'], $documentData);

        return $document;
    }
1266985
private function arrayDeference(Node $node) {
    while ($this->currentType === '[') {
      $n = $node;
      $node = new ArrayLookupNode();
      $node->addChild($n, 'array');
      $this->dimOffset($node);
    }
    return $node;
  }
362578
private static function getXml(\SimpleXMLElement $element) {
        $getTest = $element->asXML();
        if ($getTest === false) {
            $getTest = '';
        }

        return $getTest;
    }
1268297
public static function arrayToXml(\DOMDocument $xml, \DOMNode $node, $array = [])
    {
        foreach ($array as $el => $val) {
            if (is_array($val)) {
                self::arrayToXml($xml, $node->$el, $val);
            } else {
                $node->appendChild($xml->createElement($el, $val));
            }
        }
        return $xml;
    }
379083
public function convertXml($xml)
    {
        try {
            $xml = Xml::build($xml, ['return' => 'domdocument', 'readFile' => false]);
            // We might not get child nodes if there are nested inline entities.
            if ((int)$xml->childNodes->length > 0) {
                return Xml::toArray($xml);
            }

            return [];
        } catch (XmlException $e) {
            return [];
        }
    }
797386
protected static function parseAtom(\SimpleXMLElement $xml)
    {
        if (!isset($xml->entry)) {
            return false;
        }

        $url = '';

        foreach ($xml->link as $link) {
            $attributes = $link->attributes();

            if (empty($attributes->href) || ((string) $attributes->rel === 'self')) {
                continue;
            }
            $url = (string) $attributes->href;
            break;
        }

        return [
            'url' => $url,
            'items' => self::getAtomEntries($xml->entry),
        ];
    }
599549
public function find(AbstractNode $node): Collection
    {
        $results = new Collection;
        foreach ($this->selectors as $selector) {
            $nodes = [$node];
            if (count($selector) == 0) {
                continue;
            }

            $options = [];
            foreach ($selector as $rule) {
                if ($rule['alterNext']) {
                    $options[] = $this->alterNext($rule);
                    continue;
                }
                $nodes = $this->seek($nodes, $rule, $options);
                // clear the options
                $options = [];
            }

            // this is the final set of nodes
            foreach ($nodes as $result) {
                $results[] = $result;
            }
        }

        return $results;
    }
385877
public function leaveNode(Node $node)
    {
        if ($node instanceof Stmt\GroupUse) {
            $nodes = [];
            foreach ($node->uses as $use) {
                $name = Name::concat($node->prefix, $use->name);
                $nodes[] = new Stmt\Use_([new Stmt\UseUse($name)]);
            }
            return $nodes;
        }
    }
1125530
private function parseXmlAttributes(\DOMNode $node, array $context = []): array
    {
        if (!$node->hasAttributes()) {
            return [];
        }

        $data = [];
        $typeCastAttributes = (bool) ($context[self::TYPE_CASE_ATTRIBUTES] ?? $this->defaultContext[self::TYPE_CASE_ATTRIBUTES]);

        foreach ($node->attributes as $attr) {
            if (!is_numeric($attr->nodeValue) || !$typeCastAttributes) {
                $data['@'.$attr->nodeName] = $attr->nodeValue;

                continue;
            }

            if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) {
                $data['@'.$attr->nodeName] = $val;

                continue;
            }

            $data['@'.$attr->nodeName] = (float) $attr->nodeValue;
        }

        return $data;
    }