From 81085345b197b0b8035d63ad8825ec454a8d004d Mon Sep 17 00:00:00 2001 From: Edvin Hultberg Date: Sun, 27 Feb 2022 13:49:14 +0100 Subject: [PATCH] Fix getIterator must be compatible with interface Deprecation notice in php 8.1: ``` Deprecation Notice: Return type of Ayesh\ComposerPreload\PreloadList::getIterator(): iterable should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/php/build/hbw/vendor/ayesh/composer-preload/src/PreloadList.php:19 ``` I saw no reason to use the attribute to suppress the notice than to fix it since this class is final. --- src/PreloadList.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PreloadList.php b/src/PreloadList.php index e4511d6..eb1d4db 100644 --- a/src/PreloadList.php +++ b/src/PreloadList.php @@ -4,6 +4,7 @@ use BadMethodCallException; use IteratorAggregate; +use Traversable; final class PreloadList implements IteratorAggregate { @@ -16,7 +17,7 @@ public function setList(iterable $list): void { $this->list = $list; } - public function getIterator(): iterable { + public function getIterator(): Traversable { if (!$this->list) { throw new BadMethodCallException('Attempting to fetch the iterator without setting one first.'); }