From a8435f7c358faaf39f9a0daa7f7a331a3e7cffca Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Sun, 5 Dec 2021 09:00:39 -0600 Subject: [PATCH] Added PHP 8.1 attributes to Stack methods to suppress deprecation errors --- lib/Parser/Stack.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Parser/Stack.php b/lib/Parser/Stack.php index 7b37da1..88e021b 100644 --- a/lib/Parser/Stack.php +++ b/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];