QueryPath\CSS\DOMTraverser::initialMatchOnID PHP 메소드

initialMatchOnID() 보호된 메소드

If the element is set to '*' and an ID is set, then this should be used to find by ID, which will drastically reduce the amount of comparison operations done in PHP.
protected initialMatchOnID ( $selector, $matches )
    protected function initialMatchOnID($selector, $matches)
    {
        $id = $selector->id;
        $found = $this->newMatches();
        $baseQuery = ".//*[@id='{$id}']";
        $xpath = new \DOMXPath($this->dom);
        // Now we try to find any matching IDs.
        foreach ($matches as $node) {
            if ($node->getAttribute('id') == $id) {
                $found->attach($node);
            }
            $nl = $this->initialXpathQuery($xpath, $node, $baseQuery);
            $this->attachNodeList($nl, $found);
        }
        // Unset the ID selector.
        $selector->id = null;
        return $found;
    }