From cb0c9830c86c11b91eb6946168c4b53dd730f3d4 Mon Sep 17 00:00:00 2001 From: Andrew DalPino Date: Sat, 2 Apr 2022 22:15:13 -0500 Subject: [PATCH] Compensate for PHP 8.1 backward compatibility issues --- src/Matrix.php | 4 ++-- src/Vector.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Matrix.php b/src/Matrix.php index 81dfbe7..5bf612f 100644 --- a/src/Matrix.php +++ b/src/Matrix.php @@ -12,7 +12,7 @@ use Tensor\Exceptions\DimensionalityMismatch; use Tensor\Exceptions\RuntimeException; use Tensor\Exceptions\NotImplemented; -use Generator; +use Traversable; use function count; use function is_float; @@ -3435,7 +3435,7 @@ public function offsetGet($index) : Vector * * @return \Generator */ - public function getIterator() : Generator + public function getIterator() : Traversable { foreach ($this->a as $row) { yield Vector::quick($row); diff --git a/src/Vector.php b/src/Vector.php index a1a1c07..38d1310 100644 --- a/src/Vector.php +++ b/src/Vector.php @@ -6,6 +6,7 @@ use Tensor\Exceptions\DimensionalityMismatch; use Tensor\Exceptions\RuntimeException; use ArrayIterator; +use Traversable; use function count; use function is_float; @@ -2303,6 +2304,7 @@ public function offsetUnset($index) : void * @throws \Tensor\Exceptions\InvalidArgumentException * @return float */ + #[\ReturnTypeWillChange] public function offsetGet($index) { if (isset($this->a[$index])) { @@ -2318,7 +2320,7 @@ public function offsetGet($index) * * @return \ArrayIterator */ - public function getIterator() : ArrayIterator + public function getIterator() : Traversable { return new ArrayIterator($this->a); }