Skip to content

Commit

Permalink
fix: Update return types.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 22, 2021
1 parent d1a1ed6 commit c48eebf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/ClosureIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace loophp\iterators;

use Iterator;
use IteratorAggregate;
use Traversable;

/**
* @template TKey
Expand Down Expand Up @@ -40,7 +40,10 @@ public function __construct(callable $callable, iterable $parameters = [])
$this->parameters = $parameters;
}

public function getIterator(): Traversable
/**
* @return Iterator<TKey, T>
*/
public function getIterator(): Iterator
{
yield from ($this->callable)(...$this->parameters);
}
Expand Down
6 changes: 3 additions & 3 deletions src/IterableIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace loophp\iterators;

use Iterator;
use IteratorAggregate;
use Traversable;

/**
* @template TKey
Expand All @@ -34,9 +34,9 @@ public function __construct(iterable $iterable)
}

/**
* @return Traversable<TKey, T>
* @return Iterator<TKey, T>
*/
public function getIterator(): Traversable
public function getIterator(): Iterator
{
yield from $this->iterator->getIterator();
}
Expand Down
6 changes: 3 additions & 3 deletions src/PackIterableAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace loophp\iterators;

use Iterator;
use IteratorAggregate;
use Traversable;

/**
* @template TKey
Expand All @@ -34,9 +34,9 @@ public function __construct(iterable $iterable)
}

/**
* @return Traversable<int, array{0: TKey, 1: T}>
* @return Iterator<int, array{0: TKey, 1: T}>
*/
public function getIterator(): Traversable
public function getIterator(): Iterator
{
foreach ($this->iterable as $key => $value) {
yield [$key, $value];
Expand Down
5 changes: 2 additions & 3 deletions src/PausableIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Iterator;
use IteratorAggregate;
use loophp\iterators\Contract\PausableIteratorAggregateInterface;
use Traversable;

/**
* @template TKey
Expand Down Expand Up @@ -44,9 +43,9 @@ public function __construct(Iterator $iterator)
}

/**
* @return Traversable<TKey, T>
* @return Iterator<TKey, T>
*/
public function getIterator(): Traversable
public function getIterator(): Iterator
{
/** @var Iterator<TKey, T> $iterator */
$iterator = $this->iteratorAggregate->getIterator();
Expand Down
5 changes: 3 additions & 2 deletions src/RandomIterableAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use ArrayIterator;
use Generator;
use Iterator;
use IteratorAggregate;
use Traversable;

Expand Down Expand Up @@ -39,9 +40,9 @@ public function __construct(iterable $iterable, int $seed = 0)
}

/**
* @return Traversable<TKey, T>
* @return Iterator<TKey, T>
*/
public function getIterator(): Traversable
public function getIterator(): Iterator
{
mt_srand($this->seed);

Expand Down
5 changes: 2 additions & 3 deletions src/SimpleCachingIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use CachingIterator;
use Iterator;
use IteratorAggregate;
use Traversable;

/**
* @template TKey of array-key
Expand Down Expand Up @@ -41,9 +40,9 @@ public function __construct(Iterator $iterator)
}

/**
* @return Traversable<int|string, T>
* @return Iterator<int|string, T>
*/
public function getIterator(): Traversable
public function getIterator(): Iterator
{
if (false === $this->hasStarted) {
$this->hasStarted = true;
Expand Down

0 comments on commit c48eebf

Please sign in to comment.