From 752ac3a06ebd8d7552cd8d767ca2e10aa466be7d Mon Sep 17 00:00:00 2001 From: "Robin@PiedWeb" Date: Sat, 19 Nov 2022 09:12:05 +0100 Subject: [PATCH 1/2] Fix JSArray for PHP 8.1 compatibility with \ArrayAccess and \Iterator --- src/vierbergenlars/LibJs/JSArray.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/vierbergenlars/LibJs/JSArray.php b/src/vierbergenlars/LibJs/JSArray.php index 43d48c7..0b56b53 100644 --- a/src/vierbergenlars/LibJs/JSArray.php +++ b/src/vierbergenlars/LibJs/JSArray.php @@ -150,49 +150,49 @@ public function __get($name) } - public function current() + public function current(): mixed { return $this->_convert(current($this->array)); } - public function key() + public function key(): mixed { return $this->_convert(key($this->array)); } - public function next() + public function next(): void { - return $this->_convert(next($this->array)); + $this->_convert(next($this->array)); } - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return isset($this->array[$offset]); } - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { if(!$this->offsetExists($offset)) return null; return $this->_convert($this->array[$offset]); } - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->array[$offset] = $value; } - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->array[$offset]); } - public function rewind() + public function rewind(): void { - return reset($this->array); + reset($this->array); } - public function valid() + public function valid(): bool { return key($this->array) !== null; } From 684c9f243496c22a03988ed3e8eb06c761f1275f Mon Sep 17 00:00:00 2001 From: "Robin@PiedWeb" Date: Sat, 19 Nov 2022 09:14:00 +0100 Subject: [PATCH 2/2] Fix JSString for compatibility with PHP 8.1 --- src/vierbergenlars/LibJs/JString.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vierbergenlars/LibJs/JString.php b/src/vierbergenlars/LibJs/JString.php index a006ac6..ff4448f 100644 --- a/src/vierbergenlars/LibJs/JString.php +++ b/src/vierbergenlars/LibJs/JString.php @@ -207,22 +207,22 @@ public function __get($name) } } - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return isset($this->str[$offset]); } - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->str[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->str[$offset] = $value; } - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { throw new \LogicException('Cannot unset a position in a string'); }