1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 13:21:16 +01:00

Remove unnecessary indirection

Also updated some psalm params and returns.
This commit is contained in:
Aaron Piotrowski 2020-11-10 13:28:43 -06:00
parent fa31b4b3d5
commit 791885592e
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
4 changed files with 15 additions and 3 deletions

View File

@ -6,6 +6,9 @@ namespace Amp;
* @template TValue
* @template TSend
* @template TReturn
*
* @template-implements Pipeline<TValue>
* @template-implements \IteratorAggregate<int, TValue>
*/
final class AsyncGenerator implements Pipeline, \IteratorAggregate
{
@ -73,6 +76,8 @@ final class AsyncGenerator implements Pipeline, \IteratorAggregate
/**
* @inheritDoc
*
* @psalm-return TValue|null
*/
public function continue(): mixed
{
@ -135,10 +140,12 @@ final class AsyncGenerator implements Pipeline, \IteratorAggregate
/**
* @inheritDoc
*
* @paslm-return \Iterator<int, TValue>
*/
public function getIterator(): \Iterator
{
while (null !== $value = $this->continue()) {
while (null !== $value = $this->source->continue()) {
yield $value;
}
}

View File

@ -12,6 +12,7 @@ use Amp\Pipeline;
*
* @template-covariant TValue
* @template-implements Pipeline<TValue>
* @template-implements \IteratorAggregate<int, TValue>
*/
final class AutoDisposingPipeline implements Pipeline, \IteratorAggregate
{
@ -46,10 +47,12 @@ final class AutoDisposingPipeline implements Pipeline, \IteratorAggregate
/**
* @inheritDoc
*
* @psalm-return \Iterator<int, TValue>
*/
public function getIterator(): \Iterator
{
while (null !== $value = $this->continue()) {
while (null !== $value = $this->source->continue()) {
yield $value;
}
}

View File

@ -17,7 +17,7 @@ interface Pipeline extends \Traversable
*
* @return mixed Returns null if the pipeline has completed.
*
* @psalm-return TValue
* @psalm-return TValue|null
*
* @throws \Throwable The exception used to fail the pipeline.
*/

View File

@ -56,6 +56,8 @@ final class PipelineSource
*
* @param mixed $value
*
* @psalm-param TValue $value
*
* @throws DisposedException Thrown if the pipeline is disposed.
*/
public function yield(mixed $value): void