Skip to content

Commit 8c14461

Browse files
committed
Again
1 parent c8e9210 commit 8c14461

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/PhpWordTests/XmlDocument.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
use DOMDocument;
2222
use DOMElement;
23+
use DOMNameSpaceNode;
2324
use DOMNode;
2425
use DOMNodeList;
2526
use DOMXPath;
@@ -141,7 +142,7 @@ public function getFileDom(string $file = ''): DOMDocument
141142
/**
142143
* Get node list.
143144
*
144-
* @return DOMNodeList<DOMNode>
145+
* @return DDOMNodeList<DOMNameSpaceNode|DOMNode>|false
145146
*/
146147
public function getNodeList(string $path, string $file = ''): DOMNodeList
147148
{
@@ -159,10 +160,6 @@ public function getNodeList(string $path, string $file = ''): DOMNodeList
159160

160161
$query = $this->xpath->query($path);
161162

162-
if ($query === false) {
163-
self::fail('Unexpected false return from xpath query');
164-
}
165-
166163
return $query;
167164
}
168165

@@ -171,7 +168,13 @@ public function getNodeList(string $path, string $file = ''): DOMNodeList
171168
*/
172169
public function getElement(string $path, string $file = ''): ?DOMElement
173170
{
174-
return $this->getNodeList($path, $file)->item(0);
171+
$element = $this->getNodeList($path, $file)->item(0);
172+
173+
if ($element === false) {
174+
return null;
175+
}
176+
177+
return $element;
175178
}
176179

177180
/**

0 commit comments

Comments
 (0)