• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

azjezz / psl / 22680186990

04 Mar 2026 05:04PM UTC coverage: 97.34% (-1.0%) from 98.375%
22680186990

Pull #610

github

azjezz
perf: replace PSL calls with native PHP builtins and fix O(n2) algorithms

Signed-off-by: azjezz <azjezz@protonmail.com>
Pull Request #610: perf: replace PSL calls with native PHP builtins and fix O(n2) algorithms

319 of 355 new or added lines in 90 files covered. (89.86%)

64 existing lines in 12 files now uncovered.

9258 of 9511 relevant lines covered (97.34%)

34.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.38
/src/Psl/Vec/chunk.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Vec;
6

7
use function array_chunk;
8
use function is_array;
9

10
/**
11
 * Returns a list containing the original list split into chunks of the given
12
 * size.
13
 *
14
 * If the original list doesn't divide evenly, the final chunk will be
15
 * smaller.
16
 *
17
 * @template T
18
 *
19
 * @param iterable<T> $iterable
20
 * @param positive-int $size
21
 *
22
 * @return list<list<T>>
23
 */
24
function chunk(iterable $iterable, int $size): array
25
{
26
    if (is_array($iterable)) {
9✔
27
        return array_chunk($iterable, $size);
9✔
28
    }
29

UNCOV
30
    $result = [];
×
NEW
31
    $chunk = [];
×
UNCOV
32
    $ii = 0;
×
UNCOV
33
    foreach ($iterable as $value) {
×
NEW
34
        $chunk[] = $value;
×
NEW
35
        if ((++$ii % $size) === 0) {
×
NEW
36
            $result[] = $chunk;
×
NEW
37
            $chunk = [];
×
38
        }
39
    }
40

NEW
41
    if ($chunk !== []) {
×
NEW
42
        $result[] = $chunk;
×
43
    }
44

NEW
45
    return $result;
×
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc