diff options
Diffstat (limited to 'src/Nodes/DOM/DOMNodeList.php')
-rw-r--r-- | src/Nodes/DOM/DOMNodeList.php | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/src/Nodes/DOM/DOMNodeList.php b/src/Nodes/DOM/DOMNodeList.php index 28d4d42..6a53fdf 100644 --- a/src/Nodes/DOM/DOMNodeList.php +++ b/src/Nodes/DOM/DOMNodeList.php @@ -14,7 +14,7 @@ namespace andreskrey\Readability\Nodes\DOM; * * @package andreskrey\Readability\Nodes\DOM */ -class DOMNodeList implements \ArrayAccess, \Countable, \IteratorAggregate +class DOMNodeList implements \Countable, \IteratorAggregate { /** * @var array @@ -42,11 +42,11 @@ class DOMNodeList implements \ArrayAccess, \Countable, \IteratorAggregate } /** - * @param \DOMNode $node + * @param DOMNode|DOMElement|DOMComment $node * * @return DOMNodeList */ - public function add(\DOMNode $node) + public function add($node) { $this->items[] = $node; $this->length++; @@ -55,54 +55,31 @@ class DOMNodeList implements \ArrayAccess, \Countable, \IteratorAggregate } /** - * @return int|void - */ - public function count() - { - return $this->length; - } - - /** - * To make it compatible with iterator_to_array() function + * @param int $offset * - * {@inheritDoc} + * @return DOMNode|DOMElement|DOMComment */ - public function getIterator() - { - return new \ArrayIterator($this->items); - } - - /** - * {@inheritDoc} - */ - public function offsetExists($offset) - { - return isset($this->items[$offset]); - } - - /** - * {@inheritDoc} - */ - public function offsetGet($offset) + public function item(int $offset) { return $this->items[$offset]; } /** - * {@inheritDoc} + * @return int|void */ - public function offsetSet($offset, $value) + public function count(): int { - $this->items[$offset] = $value; - $this->length = count($this->items); + return $this->length; } /** + * To make it compatible with iterator_to_array() function + * * {@inheritDoc} */ - public function offsetUnset($offset) + public function getIterator(): \ArrayIterator { - unset($this->items[$offset]); - $this->length--; + return new \ArrayIterator($this->items); } + } |