diff --git a/lib/AsyncGenerator.php b/lib/AsyncGenerator.php index 2daed23..6d3b4c3 100644 --- a/lib/AsyncGenerator.php +++ b/lib/AsyncGenerator.php @@ -6,6 +6,9 @@ namespace Amp; * @template TValue * @template TSend * @template TReturn + * + * @template-implements Pipeline + * @template-implements \IteratorAggregate */ 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 */ public function getIterator(): \Iterator { - while (null !== $value = $this->continue()) { + while (null !== $value = $this->source->continue()) { yield $value; } } diff --git a/lib/Internal/AutoDisposingPipeline.php b/lib/Internal/AutoDisposingPipeline.php index a8fa28c..e5d5edb 100644 --- a/lib/Internal/AutoDisposingPipeline.php +++ b/lib/Internal/AutoDisposingPipeline.php @@ -12,6 +12,7 @@ use Amp\Pipeline; * * @template-covariant TValue * @template-implements Pipeline + * @template-implements \IteratorAggregate */ final class AutoDisposingPipeline implements Pipeline, \IteratorAggregate { @@ -46,10 +47,12 @@ final class AutoDisposingPipeline implements Pipeline, \IteratorAggregate /** * @inheritDoc + * + * @psalm-return \Iterator */ public function getIterator(): \Iterator { - while (null !== $value = $this->continue()) { + while (null !== $value = $this->source->continue()) { yield $value; } } diff --git a/lib/Pipeline.php b/lib/Pipeline.php index d44f903..e5fdb9b 100644 --- a/lib/Pipeline.php +++ b/lib/Pipeline.php @@ -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. */ diff --git a/lib/PipelineSource.php b/lib/PipelineSource.php index 4cd3f9c..6562f90 100644 --- a/lib/PipelineSource.php +++ b/lib/PipelineSource.php @@ -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