Skip to content

Commit

Permalink
API Strongly type iterator classes and remove ReturnTypeWillChange an…
Browse files Browse the repository at this point in the history
…notation
  • Loading branch information
Maxime Rainville committed Jan 20, 2023
1 parent fc415c3 commit 35340d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
17 changes: 6 additions & 11 deletions src/Utils/CombinationsArrayIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,26 @@ public function __construct($args)
$this->rewind();
}

#[\ReturnTypeWillChange]
public function rewind()
public function rewind(): void
{
if (!$this->numArrays) {
$this->isValid = false;
} else {
$this->isValid = true;
$this->k = 0;

for ($i = 0; $i < $this->numArrays; $i++) {
reset($this->arrays[$i]);
}
}
}

#[\ReturnTypeWillChange]
public function valid()
public function valid(): bool
{
return $this->isValid;
}

#[\ReturnTypeWillChange]
public function next()
public function next(): void
{
$this->k++;

Expand All @@ -71,8 +68,7 @@ public function next()
}
}

#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
$res = array();
for ($i = 0; $i < $this->numArrays; $i++) {
Expand All @@ -81,8 +77,7 @@ public function current()
return $res;
}

#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return $this->k;
}
Expand Down
15 changes: 5 additions & 10 deletions src/Utils/MultipleArrayIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,25 @@ public function __construct()
$this->rewind();
}

#[\ReturnTypeWillChange]
public function rewind()
public function rewind(): void
{
$this->active = $this->arrays;
if ($this->active) {
reset($this->active[0]);
}
}

#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
return $this->active ? current($this->active[0]) : false;
}

#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return $this->active ? key($this->active[0]) : false;
}

#[\ReturnTypeWillChange]
public function next()
public function next(): void
{
if (!$this->active) {
return;
Expand All @@ -58,8 +54,7 @@ public function next()
}
}

#[\ReturnTypeWillChange]
public function valid()
public function valid(): bool
{
return $this->active && (current($this->active[0] ?? []) !== false);
}
Expand Down

0 comments on commit 35340d4

Please sign in to comment.