QueryPath\DOMQuery::prev PHP Метод

prev() публичный Метод

For each element in the DOMQuery, this retrieves the previous sibling (if any). If a selector is supplied, it retrieves the first matching sibling (if any is found).
См. также: prevAll()
См. также: next()
См. также: siblings()
См. также: children()
public prev ( string $selector = null )
$selector string A valid CSS 3 selector.
    public function prev($selector = null)
    {
        $found = new \SplObjectStorage();
        foreach ($this->matches as $m) {
            while (isset($m->previousSibling)) {
                $m = $m->previousSibling;
                if ($m->nodeType === XML_ELEMENT_NODE) {
                    if (!empty($selector)) {
                        if (QueryPath::with($m, null, $this->options)->is($selector)) {
                            $found->attach($m);
                            break;
                        }
                    } else {
                        $found->attach($m);
                        break;
                    }
                }
            }
        }
        return $this->inst($found, null, $this->options);
    }