From aa7a3c50128ccf605c078c14a0ce45f355acfa77 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Tue, 30 Nov 2021 00:45:02 +0100 Subject: [PATCH] Clarify prevention of empty returns in array splitter --- src/MD_STD.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MD_STD.php b/src/MD_STD.php index 74af66b..afee1d4 100644 --- a/src/MD_STD.php +++ b/src/MD_STD.php @@ -770,10 +770,10 @@ final class MD_STD { * Splits an lists of integers into parts of a predefined size and returns those * as sub-lists of a superordinate list. * - * @param integer[] $input Input array. - * @param positive-int $size Size of each part of the return set. + * @param array $input Input array. + * @param positive-int $size Size of each part of the return set. * - * @return array + * @return array> */ public static function split_int_array_into_sized_parts(array $input, int $size):array { @@ -786,7 +786,8 @@ final class MD_STD { $max = count($input); $offset = 0; while ($offset < $max) { - $output[] = array_slice($input, $offset, $size - 1); + $cur = array_slice($input, $offset, $size - 1); + if (!empty($cur)) $output[] = $cur; $offset += $size; }