Throw exceptions instead of silently returning null
I'm trying to find the namespace of an XML file with:
$saxonProc = new SaxonProcessor(); $xPathProcessor = $saxonProc->newXPathProcessor(); $xPathProcessor->setContextFile($file->getPathname()); $item = $xPathProcessor->evaluateSingle('/*/namespace::*[name()=\'\']');
According to the documentation:
evaluateSingle(string $xpathStr) Compile and evaluate an XPath expression whose result is expected to be a single item, with a given context item. The expression is supplied as a character string, and the result returned as an XdmItem.
So the return value is expected to be an XdmItem. However, when the expression could not be evaluated, it can also return null.
It would be great if exceptions can be thrown when these situations occur. (I expect these can be applied on other functions as well?), so these exceptions can be caught with a try-catch block. Now, the return type is not documented, but 'silently' returning a null value is also not desirable.
Please register to edit this issue