PHPUnit_Util_XML::getDescendants PHP Method

getDescendants() protected static method

Recursively get flat array of all descendants of this node.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
protected static getDescendants ( DOMNode $node ) : array
$node DOMNode
return array
    protected static function getDescendants(DOMNode $node)
    {
        $allChildren = array();
        $childNodes = $node->childNodes ? $node->childNodes : array();
        foreach ($childNodes as $child) {
            if ($child->nodeType === XML_CDATA_SECTION_NODE || $child->nodeType === XML_TEXT_NODE) {
                continue;
            }
            $children = self::getDescendants($child);
            $allChildren = array_merge($allChildren, $children, array($child));
        }
        return isset($allChildren) ? $allChildren : array();
    }