hamcrest-php icon indicating copy to clipboard operation
hamcrest-php copied to clipboard

document of class DOMXPath constructor expects DOMDocument, DOMDocument|null given. in HasXPath:106

Open pscheit opened this issue 5 months ago • 0 comments

        if ($node instanceof \DOMDocument) {
            $xpathDocument = new \DOMXPath($node);

            return $xpathDocument->evaluate($this->_xpath);
        } else {
            $xpathDocument = new \DOMXPath($node->ownerDocument);

            return $xpathDocument->evaluate($this->_xpath, $node);
        }

This error is detected by phpstan and was written to the baseline in #88

 ------ ------------------------------------------------------------------------------------------------------------------------------------------
  Line   hamcrest/Hamcrest/Xml/HasXPath.php
 ------ ------------------------------------------------------------------------------------------------------------------------------------------
  106    Parameter #1 $document of class DOMXPath constructor expects DOMDocument, DOMDocument|null given.
         🪪  argument.type
         ✏️  hamcrest/Hamcrest/Xml/HasXPath.php
  120    Method Hamcrest\Xml\HasXPath::matchesContent() has parameter $nodes with generic class DOMNodeList but does not specify its types: TNode
         🪪  missingType.generics
         ✏️  hamcrest/Hamcrest/Xml/HasXPath.php
 ------ ------------------------------------------------------------------------------------------------------------------------------------------

pscheit avatar Jul 26 '25 09:07 pscheit