@param \DOMNode $node

@return \DOMNodeList|\DOMElement[]
357588
static protected function get_cell_list(\DOMNode $node)
    {
        $xpath = new \DOMXpath($node->ownerDocument);

        switch ($node->nodeName) {
            default:
            case "table":
                $query = "tr/td | thead/tr/td | tbody/tr/td | tfoot/tr/td | tr/th | thead/tr/th | tbody/tr/th | tfoot/tr/th";
                break;

            case "tbody":
            case "tfoot":
            case "thead":
                $query = "tr/td | tr/th";
                break;

            case "tr":
                $query = "td | th";
                break;
        }

        return $xpath->query($query, $node);
    }
236185
public function getModuleNames(AbstractNode $node): array
    {
        $docBlock = $this->getDocBlock($node);

        if ($docBlock === null) {
            return [];
        }

        $moduleTags = $docBlock->getTagsByName(static::TAG_MODULE);
        $moduleTags = $this->docBlockMapper->tagsToArray($moduleTags);

        return $moduleTags[static::TAG_MODULE] ?? [];
    }
964114
protected function getReturn(\DOMNode $node)
    {
        $crawler = new Crawler($node);
        $type = $crawler->attr('type');
        $description = $this->getInner($node);

        return array($type, $description);

    }
174311
public function create(DOMElement $node)
    {
        $item = new Item();
        $this->setProperties($node, $item);
        $this->setDate($node, $item);
        $this->setTags($node, $item);
        $this->executeAggregators($node, $item);

        return $item;
    }
363703
protected function _toArray(DOMNodeList $nodes) {
		$array = array();
		foreach ($nodes as $node) {
			if ($node->nodeType != XML_ELEMENT_NODE) {
				continue;
			}
			if ($node->hasAttributes()) { // deep
				if ($node->tagName == 'error') {
					$array = array(
						'id' => $node->getAttribute('id'),
						'code' => $node->getAttribute('code'),
						'auxCode' => $node->getAttribute('auxCode'),
						'message' => $node->nodeValue
					);
				} else {
					// in the case of custom charges, use the id for the key
					if ($node->hasAttribute('code') && $node->getAttribute('code')) {
						$key = $node->getAttribute('code');

						$tmpArr = array();

						if ($node->hasAttribute('id')) {
							$tmpArr = array(
								'id' => $node->getAttribute('id')
							);
						}
						$tmpArr = $tmpArr + array('code'=>$key);

						// charges need to be a nested array since there can be multiple charges with the same charge code
						if ($node->tagName == 'charge') {
							$array[$key][] = $tmpArr;
						} else {
							$array[$key] = $tmpArr;
						}

						unset($tmpArr);

					} else {
						$key = $node->getAttribute('id');
						$array[$key] = array('id' => $node->getAttribute('id'));
					}
					$array[$key] = $array[$key] + $this->_toArray($node->childNodes);
				}
			} else {
				if ($node->tagName == 'errors') {
					$array[$node->tagName][] = $this->_toArray($node->childNodes);
				} else if ($node->childNodes->length > 1) { // sub array
					$array[$node->tagName] = $this->_toArray($node->childNodes);
				} else {
					$array[$node->tagName] = $node->nodeValue;
				}
			}
		}
		return $array;
	}
342057
private function decodeArrayNode(\DOMNode $node): array
    {
        $data = [];
        foreach ($node->childNodes as $childNode) {
            if ($childNode instanceof \DOMText) {
                continue;
            }

            $data[] = $this->decodeNode($childNode);
        }

        return $data;
    }
225915
private function processNode(\SimpleXMLElement $node): array
    {
        $config = [];
        foreach ($node as $name => $value) {
            if (\preg_match('/^num__([0-9]+)$/', $name, $matches)) {
                $name = $matches[1];
            }
            if ($value->count() > 0) {
                $config[$name] = $this->processNode($value->children());
            } else {
                $value = (string)$value;
                $config[$name] = $value;

                if (\preg_match('/^[0-9]+$/', $value)) {
                    $config[$name] = (int)$value;
                } elseif (\preg_match('/^[0-9\.]+$/', $value)) {
                    $config[$name] = (float)$value;
                } elseif (\preg_match('/^true|false$/', $value)) {
                    $config[$name] = $value === 'true' ? true : false;
                }
            }
        }
        return $config;
    }
42477
protected function getParentElementId(DOMNode $node)
	{
		$parentNode = $node->parentNode;
		while (isset($parentNode))
		{
			if ($parentNode->nodeName === 'element')
			{
				return $parentNode->getAttribute('id');
			}
			$parentNode = $parentNode->parentNode;
		}
	}
1129518
protected function getNodeDepth(DomNode $node)
    {
        // initial depth for top level elements (to avoid "ifs")
        $depth = -2;

        while ($node) {
            ++$depth;
            $node = $node->parentNode;
        }

        return $depth;
    }
708071
protected function registerNode(\DOMNode $node)
    {
        if ($node->nodeType == XML_ELEMENT_NODE) {
            /** @var \DOMElement $node */
            $localContext = $this->elementProcessor->processElement($node, $this->initialContext);

            // Register the node context
            $localContextId = spl_object_hash($localContext);
            if (empty($this->contexts[$localContextId])) {
                $this->contexts[$localContextId] = $localContext;
            }

            $this->contextMap[$node->getNodePath()] = $localContextId;
        }

        return $node;
    }
1092050
private function getChildren(\DOMNode $node, $name)
    {
        $children = [];
        foreach ($node->childNodes as $child) {
            if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) {
                $children[] = $child;
            }
        }

        return $children;
    }
1356880
private function decodeObjectNode(\DOMNode $node): array
    {
        $data = [];
        foreach ($node->childNodes as $childNode) {
            if ($childNode instanceof \DOMText) {
                continue;
            }

            $data[$childNode->getAttribute('name')] = $this->decodeNode($childNode);
        }

        return $data;
    }
510611
private function transformType(\DOMElement $node): array
    {
        $data = [];

        $childNodes = [];
        foreach ($node->childNodes as $childNode) {
            if ($childNode instanceof \DOMElement) {
                $childNodes[] = $childNode;
            }
        }

        foreach ($childNodes as $childNode) {
            if (0 === $childNode->childNodes->length) {
                $data[$this->getKey($childNode)] = null;

                continue;
            }

            if (1 === $childNode->childNodes->length) {
                $data[$this->getKey($childNode)] = $this->getValue($childNode);

                continue;
            }

            if ('object' === $childNode->nodeName
                && $childNode->hasAttribute('type')
                && !$childNode->hasAttribute('key')
            ) {
                return $this->transformType($childNode);
            }

            $data[$this->getKey($childNode)] = $this->transformType($childNode);
        }

        if ('object' === $node->nodeName && $node->hasAttribute('type')) {
            $data['_type'] = $node->getAttribute('type');
        }

        return $data;
    }
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;
	}
784206
protected function getCustomTagContent(DOMNode $node)
    {
        $xmlString = '';

        /** @var \DOMNode $child */
        foreach ($node->childNodes as $child) {
            $xmlString .= $node->ownerDocument->saveXML($child);
        }

        return $xmlString;
    }
564317
private function processDOM(\DOMNode $node, \DOMDocument $dom)
    {
        if ($node->hasChildNodes()) {
            $nodes = [];
            foreach ($node->childNodes as $childNode) {
                if ($childNode instanceof \DOMElement && $childNode->tagName) {
                    if (in_array($childNode->tagName, $this->protectedTags)) {
                        continue;
                    }
                }

                $nodes[] = $childNode;
            }

            $depth = $this->stateBag->getCurrentDepth();

            foreach ($nodes as $childNode) {
                if ($childNode instanceof \DOMText && !$childNode->isWhitespaceInElementContent()) {
                    $this->stateBag->setCurrentDepth($depth);
                    $this->doFix($childNode, $node, $dom);
                } else {
                    $this->stateBag->setCurrentDepth($this->stateBag->getCurrentDepth() + 1);
                    $this->processDOM($childNode, $dom);
                }
            }
        }
    }
1142343
protected static function getNextElement(\DOMNode $node)
    {
        while ($node && ($node = $node->nextSibling)) {
            if ($node instanceof \DOMElement) {
                break;
            }
        }

        return $node;
    }