diff --git a/src/Finder.php b/src/Finder.php index e753306..646eda8 100644 --- a/src/Finder.php +++ b/src/Finder.php @@ -11,7 +11,7 @@ use function current; use function end; -use function is_string; +use function is_numeric; use function iterator_to_array; use function key; use function prev; @@ -138,7 +138,7 @@ public static function rows(iterable $data, callable $filter, bool $preserveKey continue; } - if (is_string($key)) { + if (! is_numeric($key)) { $rowKey = $key; } else { $rowKey = $preserveKey ? $key : $newKey; diff --git a/tests/FinderTest.php b/tests/FinderTest.php index 13511ad..a36ab12 100644 --- a/tests/FinderTest.php +++ b/tests/FinderTest.php @@ -286,6 +286,12 @@ public static function rowsDataProvider(): array static fn($datum): bool => $datum > 7, ['foo' => 8, 9], ], + // @see https://3v4l.org/0KWZ7Y + [ + [6, 7, '0' => 8, 9], + static fn($datum): bool => $datum > 7, + [8, 9], + ], ]; }