Skip to content

Commit

Permalink
Merge pull request #15 from samsonasik/numeric-check
Browse files Browse the repository at this point in the history
[Finder] Check numeric type as same with int on Finder::rows()
  • Loading branch information
samsonasik authored Mar 6, 2024
2 parents 79e3107 + a2d80da commit a40d9d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions tests/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
],
];
}

Expand Down

0 comments on commit a40d9d4

Please sign in to comment.