From ee5bf2c83fc72b706b05f382d9aa08de8b16f9b1 Mon Sep 17 00:00:00 2001 From: Kyryl Bogach Date: Wed, 1 Dec 2021 14:12:12 +0100 Subject: [PATCH] Improve PHP 8.1.0 support Fix errors when using PHP 8.1.0 like: Return type of Spatie\Period\PeriodCollection::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/spatie/period/src/IterableImplementation.php --- src/IterableImplementation.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/IterableImplementation.php b/src/IterableImplementation.php index ff2fa70..69a2759 100644 --- a/src/IterableImplementation.php +++ b/src/IterableImplementation.php @@ -6,12 +6,12 @@ trait IterableImplementation { protected $position = 0; - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->periods[$offset] ?? null; } - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { if (is_null($offset)) { $this->periods[] = $value; @@ -22,32 +22,32 @@ public function offsetSet($offset, $value) $this->periods[$offset] = $value; } - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return array_key_exists($offset, $this->periods); } - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->periods[$offset]); } - public function next() + public function next(): void { $this->position++; } - public function key() + public function key(): mixed { return $this->position; } - public function valid() + public function valid(): bool { return array_key_exists($this->position, $this->periods); } - public function rewind() + public function rewind(): void { $this->position = 0; }