Browse Source

Fix XPathResult results when the result is null

master
Dustin Wilson 2 years ago
parent
commit
afc85da202
  1. 12
      composer.lock
  2. 10
      lib/XPathResult.php
  3. 12
      vendor-bin/phpunit/composer.lock

12
composer.lock

@ -54,16 +54,16 @@
},
{
"name": "mensbeam/html-parser",
"version": "1.2.2",
"version": "1.2.3",
"source": {
"type": "git",
"url": "https://github.com/mensbeam/HTML-Parser.git",
"reference": "8e087054df98703f6dda21698419508f144e2e6e"
"reference": "c1dc4b55ceeb5c93e14a8cc0715f501caeead506"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mensbeam/HTML-Parser/zipball/8e087054df98703f6dda21698419508f144e2e6e",
"reference": "8e087054df98703f6dda21698419508f144e2e6e",
"url": "https://api.github.com/repos/mensbeam/HTML-Parser/zipball/c1dc4b55ceeb5c93e14a8cc0715f501caeead506",
"reference": "c1dc4b55ceeb5c93e14a8cc0715f501caeead506",
"shasum": ""
},
"require": {
@ -119,9 +119,9 @@
],
"support": {
"issues": "https://github.com/mensbeam/HTML-Parser/issues",
"source": "https://github.com/mensbeam/HTML-Parser/tree/1.2.2"
"source": "https://github.com/mensbeam/HTML-Parser/tree/1.2.3"
},
"time": "2022-02-13T23:09:28+00:00"
"time": "2022-02-14T15:18:44+00:00"
},
{
"name": "mensbeam/intl",

10
lib/XPathResult.php

@ -30,7 +30,7 @@ class XPathResult implements \ArrayAccess, \Countable, \Iterator {
protected int $_resultType;
protected \DOMNodeList|array $storage;
protected function __get_booleanValue(): bool {
protected function __get_booleanValue(): ?bool {
if ($this->_resultType !== self::BOOLEAN_TYPE) {
throw new XPathException(XPathException::TYPE_ERROR);
}
@ -42,7 +42,7 @@ class XPathResult implements \ArrayAccess, \Countable, \Iterator {
return $this->_invalidIteratorState;
}
protected function __get_numberValue(): float {
protected function __get_numberValue(): ?float {
if ($this->_resultType !== self::NUMBER_TYPE) {
throw new XPathException(XPathException::TYPE_ERROR);
}
@ -54,13 +54,13 @@ class XPathResult implements \ArrayAccess, \Countable, \Iterator {
return $this->_resultType;
}
protected function __get_singleNodeValue(): Node {
protected function __get_singleNodeValue(): ?Node {
if (!in_array($this->_resultType, [ self::ANY_UNORDERED_NODE_TYPE, self::FIRST_ORDERED_NODE_TYPE ])) {
throw new XPathException(XPathException::TYPE_ERROR);
}
$node = $this->storage[0];
return $node->ownerDocument->getWrapperNode($node);
return ($node !== null) ? $node->ownerDocument->getWrapperNode($node) : node;
}
protected function __get_snapshotLength(): int {
@ -71,7 +71,7 @@ class XPathResult implements \ArrayAccess, \Countable, \Iterator {
return $this->count();
}
protected function __get_stringValue(): string {
protected function __get_stringValue(): ?string {
if ($this->_resultType !== self::STRING_TYPE) {
throw new XPathException(XPathException::TYPE_ERROR);
}

12
vendor-bin/phpunit/composer.lock

@ -1451,16 +1451,16 @@
},
{
"name": "sebastian/global-state",
"version": "5.0.4",
"version": "5.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "19c519631c5a511b7ed0ad64a6713fdb3fd25fe4"
"reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/19c519631c5a511b7ed0ad64a6713fdb3fd25fe4",
"reference": "19c519631c5a511b7ed0ad64a6713fdb3fd25fe4",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"shasum": ""
},
"require": {
@ -1503,7 +1503,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.4"
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
},
"funding": [
{
@ -1511,7 +1511,7 @@
"type": "github"
}
],
"time": "2022-02-10T07:01:19+00:00"
"time": "2022-02-14T08:28:10+00:00"
},
{
"name": "sebastian/lines-of-code",

Loading…
Cancel
Save