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:
parent
fa31b4b3d5
commit
791885592e
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user