From f1e97dce2ae4b0550559f7906c0148dd6fa3d43e Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Thu, 7 Nov 2024 16:48:17 +0000 Subject: [PATCH] reduce deprecation notices from later PHP versions --- src/Collection/ArraySequence.php | 1 + src/Collection/EmptySequence.php | 1 + src/Collection/PromiseSequence.php | 1 + src/ImmutableArrayAccess.php | 4 ++-- src/Model/SearchSubjects.php | 10 ++++++---- src/Model/SearchTypes.php | 2 +- src/SlicedArrayAccess.php | 1 + src/SlicedIterator.php | 8 +++++--- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Collection/ArraySequence.php b/src/Collection/ArraySequence.php index 3fecfce2..314cb98e 100644 --- a/src/Collection/ArraySequence.php +++ b/src/Collection/ArraySequence.php @@ -141,6 +141,7 @@ public function offsetExists($offset) : bool return isset($this->array[$offset]); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { if (!isset($this->array[$offset])) { diff --git a/src/Collection/EmptySequence.php b/src/Collection/EmptySequence.php index 278e6811..4a3a555a 100644 --- a/src/Collection/EmptySequence.php +++ b/src/Collection/EmptySequence.php @@ -94,6 +94,7 @@ public function offsetExists($offset) : bool return false; } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return null; diff --git a/src/Collection/PromiseSequence.php b/src/Collection/PromiseSequence.php index b57e52b0..a996feda 100644 --- a/src/Collection/PromiseSequence.php +++ b/src/Collection/PromiseSequence.php @@ -191,6 +191,7 @@ public function offsetExists($offset) : bool return $this->wait()->offsetExists($offset); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->wait()->offsetGet($offset); diff --git a/src/ImmutableArrayAccess.php b/src/ImmutableArrayAccess.php index c7043e1e..e8d42440 100644 --- a/src/ImmutableArrayAccess.php +++ b/src/ImmutableArrayAccess.php @@ -6,12 +6,12 @@ trait ImmutableArrayAccess { - final public function offsetSet($offset, $value) + final public function offsetSet($offset, $value): void { throw new BadMethodCallException('Object is immutable'); } - final public function offsetUnset($offset) + final public function offsetUnset($offset): void { throw new BadMethodCallException('Object is immutable'); } diff --git a/src/Model/SearchSubjects.php b/src/Model/SearchSubjects.php index a7e6367e..60d765b4 100644 --- a/src/Model/SearchSubjects.php +++ b/src/Model/SearchSubjects.php @@ -19,33 +19,35 @@ public function __construct(array $subjects, array $results) $this->results = $results; } - public function count() + public function count(): int { return count($this->subjects); } + #[\ReturnTypeWillChange] public function current() { return current($this->results); } - public function next() + public function next(): void { next($this->subjects); next($this->results); } + #[\ReturnTypeWillChange] public function key() { return current($this->subjects); } - public function valid() + public function valid(): bool { return false !== $this->key(); } - public function rewind() + public function rewind(): void { reset($this->subjects); reset($this->results); diff --git a/src/Model/SearchTypes.php b/src/Model/SearchTypes.php index 0f9672eb..b600dadc 100644 --- a/src/Model/SearchTypes.php +++ b/src/Model/SearchTypes.php @@ -19,7 +19,7 @@ public function __construct(array $typesToResults) $this->typesToResults = $typesToResults; } - public function count() + public function count(): int { return count($this->typesToResults); } diff --git a/src/SlicedArrayAccess.php b/src/SlicedArrayAccess.php index e19c37fb..35d8c3e0 100644 --- a/src/SlicedArrayAccess.php +++ b/src/SlicedArrayAccess.php @@ -14,6 +14,7 @@ public function offsetExists($offset) : bool return null !== $this->offsetGet($offset); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { try { diff --git a/src/SlicedIterator.php b/src/SlicedIterator.php index 8052c8d3..18ac3bca 100644 --- a/src/SlicedIterator.php +++ b/src/SlicedIterator.php @@ -10,6 +10,7 @@ trait SlicedIterator private $key = 1; + #[\ReturnTypeWillChange] final public function current() { $page = (int) ceil($this->key / $this->pageBatch); @@ -23,11 +24,12 @@ final public function current() return $pageContents[$inPage]; } - final public function next() + final public function next(): void { ++$this->key; } + #[\ReturnTypeWillChange] final public function key() { if ($this->key > $this->count()) { @@ -37,12 +39,12 @@ final public function key() return $this->key; } - final public function valid() + final public function valid(): bool { return $this->key <= $this->count(); } - final public function rewind() + final public function rewind(): void { $this->key = 1; }