Skip to content

Commit

Permalink
Reduce PSALM warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 9, 2020
1 parent affab6c commit 7ffef09
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
6 changes: 4 additions & 2 deletions spec/loophp/collection/Iterator/ClosureIteratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function it_can_rewind()
->shouldReturn('foo');

$this
->next()
->next();

$this
->current()
->shouldReturn(null);

Expand All @@ -67,7 +69,7 @@ public function it_can_use_next(): void

$this
->next()
->shouldReturn($this);
->shouldBeNull();

$this
->current()
Expand Down
10 changes: 7 additions & 3 deletions spec/loophp/collection/Iterator/IterableIteratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ public function it_can_rewind()
->shouldReturn('foo');

$this
->next()
->next();

$this
->current()
->shouldReturn(null);

$this
->rewind()
->rewind();

$this
->current()
->shouldReturn('foo');
}
Expand All @@ -54,7 +58,7 @@ public function it_can_use_next(): void

$this
->next()
->shouldReturn($this);
->shouldBeNull();

$this
->current()
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Transformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Transformation
/**
* @param iterable<mixed> $collection
*
* @return iterable|mixed
* @return mixed
*/
public function __invoke(iterable $collection);
}
2 changes: 1 addition & 1 deletion src/Contract/Transformation/Transformable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Transformable
/**
* @param \loophp\collection\Contract\Transformation ...$transformers
*
* @return mixed
* @return \loophp\collection\Iterator\ClosureIterator|mixed
*/
public function transform(Transformation ...$transformers);
}
4 changes: 1 addition & 3 deletions src/Iterator/ClosureIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ public function key()
/**
* {@inheritdoc}
*
* @return \loophp\collection\Iterator\ClosureIterator
* @return void
*/
public function next()
{
$this->getGenerator()->next();

return $this;
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/Iterator/IterableIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,21 @@ public function key()
/**
* {@inheritdoc}
*
* @return \loophp\collection\Iterator\IterableIterator
* @return void
*/
public function next()
{
$this->iterator->next();

return $this;
}

/**
* {@inheritdoc}
*
* @return \loophp\collection\Iterator\IterableIterator
* @return void
*/
public function rewind()
{
$this->iterator->rewind();

return $this;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Transformation/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ final class All implements Transformation
{
/**
* {@inheritdoc}
*
* @return mixed[]
*/
public function __invoke(iterable $collection)
public function __invoke(iterable $collection): array
{
return iterator_to_array(new IterableIterator($collection));
}
Expand Down

0 comments on commit 7ffef09

Please sign in to comment.