From acb6d8fe3805b6be531053812bea2aea68458750 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 20 Feb 2024 17:33:31 +0100 Subject: [PATCH] refactor: minor SA update `Tails` operation --- phpstan-baseline.neon | 7 +------ src/Operation/Tails.php | 10 +++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9b8106ff..8b734f11 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -102,7 +102,7 @@ parameters: - message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(mixed \\.\\.\\.\\)\\: iterable\\\\>, Closure\\(iterable\\)\\: Generator\\, mixed, mixed\\> given\\.$#" - count: 1 + count: 2 path: src/Collection.php - @@ -110,11 +110,6 @@ parameters: count: 1 path: src/Collection.php - - - message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(mixed \\.\\.\\.\\)\\: iterable\\\\>, Closure\\(iterable\\\\)\\: Generator\\, mixed, mixed\\> given\\.$#" - count: 1 - path: src/Collection.php - - message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(mixed \\.\\.\\.\\)\\: iterable\\\\>, Closure\\(iterable\\)\\: Generator\\, mixed, mixed\\> given\\.$#" count: 1 diff --git a/src/Operation/Tails.php b/src/Operation/Tails.php index ddb0c755..638cd52a 100644 --- a/src/Operation/Tails.php +++ b/src/Operation/Tails.php @@ -19,18 +19,18 @@ final class Tails extends AbstractOperation { /** - * @return Closure(iterable): Generator> + * @return Closure(iterable): Generator> */ public function __invoke(): Closure { return /** - * @param iterable $iterable + * @param iterable $iterable * * @return Generator> */ static function (iterable $iterable): Generator { - $generator = iterator_to_array( + $initial = iterator_to_array( (new IterableIteratorAggregate($iterable))->getIterator() ); @@ -42,9 +42,9 @@ static function (iterable $iterable): Generator { */ static fn (array $stack): array => array_slice($stack, 1); - /** @var Closure(iterable): Generator> $pipe */ + /** @var Closure(iterable): Generator> $pipe */ $pipe = (new Pipe())()( - (new Reduction())()($reduction)($generator), + (new Reduction())()($reduction)($initial), (new Normalize())(), );