Skip to content

Commit

Permalink
Fix annotations and static analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 20, 2021
1 parent b898474 commit 4a653b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/CachingIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function __construct(Iterator $iterator)
}

/**
* @return Traversable<TKey, T>
* @return Iterator<TKey, T>
*/
public function getIterator(): Traversable
public function getIterator(): Iterator
{
yield from new UnpackIterableAggregate($this->iterator->getIterator());
}
Expand Down
6 changes: 3 additions & 3 deletions src/Contract/PausableIteratorAggregateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace loophp\iterators\Contract;

use IteratorAggregate;
use Traversable;
use Iterator;

/**
* @template TKey
Expand All @@ -21,7 +21,7 @@
interface PausableIteratorAggregateInterface extends IteratorAggregate
{
/**
* @return Traversable<TKey, T>
* @return Iterator<TKey, T>
*/
public function rest(): Traversable;
public function rest(): Iterator;
}
12 changes: 8 additions & 4 deletions src/PausableIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace loophp\iterators;

use ArrayIterator;
use Generator;
use Iterator;
use IteratorAggregate;
use loophp\iterators\Contract\PausableIteratorAggregateInterface;
Expand All @@ -19,7 +20,7 @@
* @template TKey
* @template T
*
* @implements IteratorAggregate<TKey, T>
* @implements PausableIteratorAggregateInterface<TKey, T>
*/
final class PausableIteratorAggregate implements PausableIteratorAggregateInterface
{
Expand Down Expand Up @@ -47,15 +48,18 @@ public function __construct(Iterator $iterator)
*/
public function getIterator(): Traversable
{
$this->iterator = $this->iteratorAggregate->getIterator();
/** @var Iterator<TKey, T> $iterator */
$iterator = $this->iteratorAggregate->getIterator();

$this->iterator = $iterator;

yield from $this->iterator;
}

/**
* @return Traversable<TKey, T>
* @return Generator<TKey, T>
*/
public function rest(): Traversable
public function rest(): Generator
{
$this->iterator->next();

Expand Down

0 comments on commit 4a653b0

Please sign in to comment.