From fd1ca32d27c8fc9bef6621a0c1d896e4f0976d10 Mon Sep 17 00:00:00 2001 From: Yevhen Sidelnyk Date: Wed, 11 Dec 2024 08:13:13 +0200 Subject: [PATCH] chore(sa): fix psalm type infer for Chunk operation --- src/Operation/Chunk.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Operation/Chunk.php b/src/Operation/Chunk.php index 60b0a84d..aea472ed 100644 --- a/src/Operation/Chunk.php +++ b/src/Operation/Chunk.php @@ -44,19 +44,15 @@ static function (iterable $iterable) use ($sizes): Generator { return; } - if (count($chunk) !== $size) { - $chunk[] = $value; + $chunk[] = $value; - continue; - } - - ++$chunkIndex; + if (count($chunk) >= $size) { + ++$chunkIndex; - /** @psalm-var non-empty-list $chunk */ + yield $chunk; - yield $chunk; - - $chunk = [$value]; + $chunk = []; + } } if ([] !== $chunk) {