Skip to content

Commit a40d9d4

Browse files
authored
Merge pull request #15 from samsonasik/numeric-check
[Finder] Check numeric type as same with int on Finder::rows()
2 parents 79e3107 + a2d80da commit a40d9d4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Finder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use function current;
1313
use function end;
14-
use function is_string;
14+
use function is_numeric;
1515
use function iterator_to_array;
1616
use function key;
1717
use function prev;
@@ -138,7 +138,7 @@ public static function rows(iterable $data, callable $filter, bool $preserveKey
138138
continue;
139139
}
140140

141-
if (is_string($key)) {
141+
if (! is_numeric($key)) {
142142
$rowKey = $key;
143143
} else {
144144
$rowKey = $preserveKey ? $key : $newKey;

tests/FinderTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ public static function rowsDataProvider(): array
286286
static fn($datum): bool => $datum > 7,
287287
['foo' => 8, 9],
288288
],
289+
// @see https://3v4l.org/0KWZ7Y
290+
[
291+
[6, 7, '0' => 8, 9],
292+
static fn($datum): bool => $datum > 7,
293+
[8, 9],
294+
],
289295
];
290296
}
291297

0 commit comments

Comments
 (0)