Browse Source

Added PHP 8.1 attributes to Stack methods to suppress deprecation errors

domparser
Dustin Wilson 2 years ago
parent
commit
a8435f7c35
  1. 4
      lib/Parser/Stack.php

4
lib/Parser/Stack.php

@ -10,6 +10,7 @@ abstract class Stack implements \ArrayAccess, \Countable, \IteratorAggregate {
protected $_storage = [];
protected $count = 0;
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) {
assert($offset >= 0, new \Exception("Invalid stack index $offset"));
@ -21,16 +22,19 @@ abstract class Stack implements \ArrayAccess, \Countable, \IteratorAggregate {
$this->count = count($this->_storage);
}
#[\ReturnTypeWillChange]
public function offsetExists($offset) {
return isset($this->_storage[$offset]);
}
#[\ReturnTypeWillChange]
public function offsetUnset($offset) {
assert($offset >= 0 && $offset < count($this->_storage), new \Exception("Invalid stack index $offset"));
array_splice($this->_storage, $offset, 1, []);
$this->count = count($this->_storage);
}
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
assert($offset >= 0 && $offset < count($this->_storage), new \Exception("Invalid stack index $offset"));
return $this->_storage[$offset];

Loading…
Cancel
Save