Issue #2587229 by Chi, claudiu.cristea: Cleanup AssertContentTrait::xpath()
parent
b0bc757792
commit
7b4baac538
|
@ -220,23 +220,23 @@ trait AssertContentTrait {
|
||||||
* placeholders in the query. The values may be either strings or numeric
|
* placeholders in the query. The values may be either strings or numeric
|
||||||
* values.
|
* values.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return \SimpleXMLElement[]|bool
|
||||||
* The return value of the xpath search. For details on the xpath string
|
* The return value of the xpath search or FALSE on failure. For details on
|
||||||
* format and return values see the SimpleXML documentation,
|
* the xpath string format and return values see the SimpleXML
|
||||||
* http://php.net/manual/function.simplexml-element-xpath.php.
|
* documentation.
|
||||||
|
*
|
||||||
|
* @see http://php.net/manual/function.simplexml-element-xpath.php
|
||||||
*/
|
*/
|
||||||
protected function xpath($xpath, array $arguments = array()) {
|
protected function xpath($xpath, array $arguments = []) {
|
||||||
if ($this->parse()) {
|
if ($this->parse()) {
|
||||||
$xpath = $this->buildXPathQuery($xpath, $arguments);
|
$xpath = $this->buildXPathQuery($xpath, $arguments);
|
||||||
$result = $this->elements->xpath($xpath);
|
$result = $this->elements->xpath($xpath);
|
||||||
// Some combinations of PHP / libxml versions return an empty array
|
// Some combinations of PHP / libxml versions return an empty array
|
||||||
// instead of the documented FALSE. Forcefully convert any falsish values
|
// instead of the documented FALSE. Forcefully convert any falsish values
|
||||||
// to an empty array to allow foreach(...) constructions.
|
// to an empty array to allow foreach(...) constructions.
|
||||||
return $result ? $result : array();
|
return $result ?: [];
|
||||||
}
|
|
||||||
else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue