Merge pull request #338 from creative-commoners/pulls/4/ReturnTypeWillChange

API Strongly type iterator classes and remove ReturnTypeWillChange annotation
This commit is contained in:
Guy Sartorelli 2023-01-24 11:52:38 +13:00 committed by GitHub
commit d73868f8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 21 deletions

View File

@ -32,29 +32,26 @@ class CombinationsArrayIterator implements Iterator
$this->rewind(); $this->rewind();
} }
#[\ReturnTypeWillChange] public function rewind(): void
public function rewind()
{ {
if (!$this->numArrays) { if (!$this->numArrays) {
$this->isValid = false; $this->isValid = false;
} else { } else {
$this->isValid = true; $this->isValid = true;
$this->k = 0; $this->k = 0;
for ($i = 0; $i < $this->numArrays; $i++) { for ($i = 0; $i < $this->numArrays; $i++) {
reset($this->arrays[$i]); reset($this->arrays[$i]);
} }
} }
} }
#[\ReturnTypeWillChange] public function valid(): bool
public function valid()
{ {
return $this->isValid; return $this->isValid;
} }
#[\ReturnTypeWillChange] public function next(): void
public function next()
{ {
$this->k++; $this->k++;
@ -71,8 +68,7 @@ class CombinationsArrayIterator implements Iterator
} }
} }
#[\ReturnTypeWillChange] public function current(): mixed
public function current()
{ {
$res = array(); $res = array();
for ($i = 0; $i < $this->numArrays; $i++) { for ($i = 0; $i < $this->numArrays; $i++) {
@ -81,8 +77,7 @@ class CombinationsArrayIterator implements Iterator
return $res; return $res;
} }
#[\ReturnTypeWillChange] public function key(): mixed
public function key()
{ {
return $this->k; return $this->k;
} }

View File

@ -22,8 +22,7 @@ class MultipleArrayIterator implements Iterator
$this->rewind(); $this->rewind();
} }
#[\ReturnTypeWillChange] public function rewind(): void
public function rewind()
{ {
$this->active = $this->arrays; $this->active = $this->arrays;
if ($this->active) { if ($this->active) {
@ -31,20 +30,17 @@ class MultipleArrayIterator implements Iterator
} }
} }
#[\ReturnTypeWillChange] public function current(): mixed
public function current()
{ {
return $this->active ? current($this->active[0]) : false; return $this->active ? current($this->active[0]) : false;
} }
#[\ReturnTypeWillChange] public function key(): mixed
public function key()
{ {
return $this->active ? key($this->active[0]) : false; return $this->active ? key($this->active[0]) : false;
} }
#[\ReturnTypeWillChange] public function next(): void
public function next()
{ {
if (!$this->active) { if (!$this->active) {
return; return;
@ -58,8 +54,7 @@ class MultipleArrayIterator implements Iterator
} }
} }
#[\ReturnTypeWillChange] public function valid(): bool
public function valid()
{ {
return $this->active && (current($this->active[0] ?? []) !== false); return $this->active && (current($this->active[0] ?? []) !== false);
} }