Check if $elements is a traversable node list. It returns
the $elements or NULL
public static isNodeList ( mixed $elements ) : Traversable | array | ||
$elements | mixed | |
리턴 | Traversable | array |
/** * @param mixed $content * @param bool $includeTextNodes * @param int $limit * @return array|\Traversable null */ private function getNodeList($content, $includeTextNodes = TRUE, $limit = -1) { if ($callback = Constraints::isCallable($content)) { $content = $callback(); } if ($content instanceof \DOMElement) { return array($content); } elseif ($includeTextNodes && Constraints::isNode($content)) { return array($content); } elseif (Constraints::isNodeList($content)) { return $this->getLimitedArray($content, $limit); } return NULL; }
/** * Push new element(s) an the internal element list * * @param \DOMNode|\Traversable|array|NULL $elements * @param boolean $ignoreTextNodes ignore text nodes * @throws \OutOfBoundsException * @throws \InvalidArgumentException * @return $this */ public function push($elements, $ignoreTextNodes = FALSE) { if (Constraints::isNode($elements, $ignoreTextNodes)) { if ($elements->ownerDocument !== $this->_document) { throw new \OutOfBoundsException('Node is not a part of this document'); } $this->_nodes[] = $elements; } elseif ($nodes = Constraints::isNodeList($elements)) { $this->_useDocumentContext = FALSE; foreach ($nodes as $index => $node) { if ($node->ownerDocument !== $this->_document) { throw new \OutOfBoundsException(sprintf('Node #%d is not a part of this document', $index)); } $this->_nodes[] = $node; } } elseif (NULL !== $elements) { throw new \InvalidArgumentException('Invalid elements variable.'); } return $this; }