Get return information (type, description) from a DOMNode

@param \DOMNode $node The DOMNode to parse

@return array First element is the type, second the description
964114
protected function getReturn(\DOMNode $node)
    {
        $crawler = new Crawler($node);
        $type = $crawler->attr('type');
        $description = $this->getInner($node);

        return array($type, $description);

    }
1268919
protected function valueOf(DOMNode $node)
	{
		switch ($node->nodeName)
		{
			case 'input':

				switch ($node->getAttribute('type'))
				{
					case 'checkbox':
						return $node->getAttribute('checked') ? $node->getAttribute('value') : false;
						break;

					default:
						return $node->getAttribute('value');
				}

			break;
		}
		return null;
	}
851899
protected function getDisplayText(Node $node) {
    if ($this->isRootTypeNode($node->getOID())) {
      $mapper = $node->getMapper();
      return $mapper->getTypeDisplayName($this->getMessage());
    }
    else {
      return strip_tags(preg_replace("/[\r\n']/", " ", NodeUtil::getDisplayValue($node)));
    }
  }
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;
    }
322388
private function decodeNode(\DOMNode $node)
    {
        $nodeName = $node->nodeName;

        $nodeType = substr($nodeName, 5);

        if (self::DATATYPE_OBJECT === $nodeType) {
            return $this->decodeObjectNode($node);
        }

        if (self::DATATYPE_ARRAY === $nodeType) {
            return $this->decodeArrayNode($node);
        }

        if (self::DATATYPE_BOOLEAN === $nodeType) {
            return $this->decodeBooleanNode($node);
        }

        if (self::DATATYPE_STRING === $nodeType) {
            return $this->decodeStringNode($node);
        }

        if (self::DATATYPE_NUMBER === $nodeType) {
            return $this->decodeNumberNode($node);
        }

        if (self::DATATYPE_NULL === $nodeType) {
            return null;
        }

        throw DeserializerRuntimeException::createNotParsable($this->getContentType());
    }
388124
public function getChildrenNodes(Node $node)
    {
        $result = $this->search($node->getDn(), null, false);

        $nodes = array();
        foreach ($result as $node) {
            $nodes[] = $node;
        }

        return $nodes;
    }
488063
public function getGroups($node) {

    $groupcontents = GroupContent::loadByEntity($node);

    $groups = [];
    // Only react if it is actually posted inside a group.
    if (!empty($groupcontents)) {
      foreach ($groupcontents as $groupcontent) {
        /* @var \Drupal\group\Entity\GroupContent $groupcontent */
        $group = $groupcontent->getGroup();
        /* @var \Drupal\group\Entity\Group $group */
        $groups[] = $group;
      }
    }

    return $groups;
  }
1372432
public function getDescription(Crawler $node = null)
    {
        $node = $node ?: $this->node;

        return [
            'description' => $this->getFieldValue(
                $node->filter("p[itemprop=description]"),
                null
            ),
        ];
    }
785803
private static function DOMtoArray($node)
    {
        $occurence = array();
        $result = null;

        if ($node->childNodes) {
            foreach ($node->childNodes as $child) {
                if (isset($occurence[$child->nodeName])) {
                    $occurence[$child->nodeName]++;
                } else {
                    $occurence[$child->nodeName] = 1;
                }
            }
        }

        if ($node->nodeType == XML_TEXT_NODE || $node->nodeType == XML_CDATA_SECTION_NODE) {
            $result = html_entity_decode(
                htmlentities(
                    (string) $node->nodeValue,
                    ENT_COMPAT,
                    'UTF-8'
                ),
                ENT_COMPAT,
                'ISO-8859-15'
            );
        } else {
            if ($node->hasChildNodes()) {
                $children = $node->childNodes;

                for ($i=0; $i<$children->length; $i++) {
                    $child = $children->item($i);

                    switch ($child->nodeName) {
                        case '#cdata-section':
                        case '#text':
                            $text = static::DOMtoArray($child);

                            if (trim($text) != '') {
                                $result[self::VALUE] = static::DOMtoArray($child);
                            };
                            break;

                        default:
                            if ($occurence[$child->nodeName] > 1) {
                                $result[$child->nodeName][] = static::DOMtoArray($child);
                            } else {
                                $result[$child->nodeName] = static::DOMtoArray($child);
                            }
                    }
                }
            }

            if ($node->hasAttributes()) {
                $attributes = $node->attributes;

                if (!is_null($attributes)) {
                    foreach ($attributes as $key => $attr) {
                        $result[self::ATTRIBUTES][$attr->name] = $attr->value;
                    }
                }
            }
        }

        return $result;
    }
1142343
protected static function getNextElement(\DOMNode $node)
    {
        while ($node && ($node = $node->nextSibling)) {
            if ($node instanceof \DOMElement) {
                break;
            }
        }

        return $node;
    }
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;
    }
391663
protected function nodeToArray($node)
    {
        $output = array();
        switch ($node->nodeType) {
            case XML_CDATA_SECTION_NODE:
            case XML_TEXT_NODE:
                $output = trim($node->textContent);
                break;
            case XML_ELEMENT_NODE:
                for ($i = 0, $m = $node->childNodes->length; $i < $m; $i++) {
                    $child = $node->childNodes->item($i);
                    $value = $this->nodeToArray($child);
                    if (isset($child->tagName)) {
                        $tag = $child->tagName;
                        if (!isset($output[$tag])) {
                            $output[$tag] = array();
                        }
                        $output[$tag][] = $value;
                    } elseif ($value || $value === '0') {
                        $output = (string) $value;
                    }
                }

                // Edge case of a node containing a text node, which also has
                // attributes. this way we'll retain text and attributes for
                // this node.
                if (is_string($output) && $node->attributes->length) {
                    $output = array('@text' => $output);
                }

                if (is_array($output)) {
                    if ($node->attributes->length) {
                        $attributes = array();
                        foreach ($node->attributes as $attrName => $attrNode) {
                            $attributes[$attrName] = (string) $attrNode->value;
                        }
                        $output['@attributes'] = $attributes;
                    }
                    foreach ($output as $tag => $value) {
                        if (is_array($value) && count($value) == 1 && $tag != '@attributes') {
                            $output[$tag] = $value[0];
                        }
                    }
                }
                break;
        }

        return $output;
    }
398501
public function getDeclarationLineFromNode($node): string
    {
        // If node is part of a declaration list, build a declaration line that discludes other elements in the list
        //  - [PropertyDeclaration] // public $a, [$b = 3], $c; => public $b = 3;
        //  - [ConstDeclaration|ClassConstDeclaration] // "const A = 3, [B = 4];" => "const B = 4;"
        if (
            ($declaration = ParserHelpers\tryGetPropertyDeclaration($node)) && ($elements = $declaration->propertyElements) ||
            ($declaration = ParserHelpers\tryGetConstOrClassConstDeclaration($node)) && ($elements = $declaration->constElements)
        ) {
            $defLine = $declaration->getText();
            $defLineStart = $declaration->getStart();

            $defLine = \substr_replace(
                $defLine,
                $node->getFullText(),
                $elements->getFullStart() - $defLineStart,
                $elements->getFullWidth()
            );
        } else {
            $defLine = $node->getText();
        }

        // Trim string to only include first line
        $defLine = \rtrim(\strtok($defLine, "\n"), "\r");

        // TODO - pretty print rather than getting text

        return $defLine;
    }
162013
public static function get_block_parent_name( \DOMNode $node ) {
		$parent = self::get_block_parent( $node );

		if ( ! empty( $parent ) ) {
			return $parent->tagName;
		} else {
			return '';
		}
	}
1196167
protected static function getPreviousElement(\DOMNode $node)
    {
        while ($node && ($node = $node->previousSibling)) {
            if ($node instanceof \DOMElement) {
                break;
            }
        }

        return $node;
    }
1300824
public function getNodeAttributes(Node $node)
    {
        // Extract the properties of the node
        $attributes = $node->getProperties();

        // Add the node id to the attributes since \Everyman\Neo4j\Node
        // does not consider it to be a property, it is treated differently
        // and available through the getId() method.
        $attributes['id'] = $node->getId();

        return $attributes;
    }
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;
	}