Skip to content

Commit e9b7512

Browse files
committed
Fix return-type for XPath::xpQuery
1 parent 5d763af commit e9b7512

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/XPath/XPath.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DOMDocument;
88
use DOMNode;
9+
use DOMNodeList;
910
use DOMXPath;
1011
use SimpleSAML\XML\Assert\Assert;
1112
use SimpleSAML\XML\Constants as C_XML;
@@ -52,13 +53,15 @@ public static function getXPath(DOMNode $node): DOMXPath
5253
* @param \DOMNode $node The XML node.
5354
* @param string $query The query.
5455
* @param \DOMXPath $xpCache The DOMXPath object
55-
* @return array<int<0, max>, \DOMNameSpaceNode|\DOMNode|null> Array with matching DOM nodes.
56+
* @return array<\DOMNode> Array with matching DOM nodes.
5657
*/
5758
public static function xpQuery(DOMNode $node, string $query, DOMXPath $xpCache): array
5859
{
5960
$ret = [];
6061

6162
$results = $xpCache->query($query, $node);
63+
Assert::notFalse($results, 'Malformed XPath query or invalid contextNode provided.');
64+
6265
for ($i = 0; $i < $results->length; $i++) {
6366
$ret[$i] = $results->item($i);
6467
}

0 commit comments

Comments
 (0)