Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yus-ham committed May 22, 2024
1 parent a4affab commit 0ec5365
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ private static function parseMixedPath(array|float|int|string $path, string $del
/**
* @param array $array The array that should be searched
* @param Closure $predicate The predicate callback to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns truthy value, the value is returned from `find()` and the callback will not be called for further elements
*
*
* @return mixed Returns the value of the first element for which the `$predicate` callback returns true. If no matching element is found the function returns `null`
*/
public static function find(array $array, Closure $predicate): mixed
Expand All @@ -1457,7 +1457,7 @@ public static function find(array $array, Closure $predicate): mixed
/**
* @param array The array that should be searched
* @param Closure $predicate The predicate callback to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns truthy value, the key is returned from `findKey()` and the callback will not be called for further elements
*
*
* @return string|int|null Returns the key of the first element for which the `$predicate` callback returns `true`. If no matching element is found the function returns `null`
*/
public static function findKey(array $array, Closure $predicate): string|int|null
Expand All @@ -1474,7 +1474,7 @@ public static function findKey(array $array, Closure $predicate): string|int|nul
/**
* @param array The array that should be searched
* @param Closure $predicate The predicate callback to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns truthy value, `true` is returned from `any()` and the callback will not be called for further elements
*
*
* @return bool Returns `true`, if one element for which predicate callback returns truthy value. Otherwise the function returns `false`
*/
public static function any(array $array, Closure $predicate): bool
Expand All @@ -1491,7 +1491,7 @@ public static function any(array $array, Closure $predicate): bool
/**
* @param array The array that should be searched
* @param Closure $predicate The predicate callback to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns falsy value, `false` is returned from `all()` and the callback will not be called for further elements
*
*
* @return bool Returns `false`, if one element for which predicate callback returns truthy value. Otherwise the function returns `false`
*/
public static function all(array $array, Closure $predicate): bool
Expand Down
20 changes: 10 additions & 10 deletions tests/ArrayHelper/FindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ final class FindTest extends TestCase
{
private array $array = [
[
"a" => 1,
"b" => 2,
"c" => 3,
"d" => 4,
"e" => 5,
'a' => 1,
'b' => 2,
'c' => 3,
'd' => 4,
'e' => 5,
],
[
1, 2, 3, 4, 5
1, 2, 3, 4, 5,
],
];

Expand All @@ -29,7 +29,7 @@ public function dataProviderFindFromArray(): array
[$this->array[0], fn ($value) => $value > 3, 4],
[$this->array[1], fn ($value) => $value > 3, 4],
[$this->array[1], fn ($value) => $value > 5, null],
[$this->array[0], fn ($value, $key) => $key === "c", 3],
[$this->array[0], fn ($value, $key) => $key === 'c', 3],
[$this->array[0], fn () => false, null],
[[], fn () => true, null],
];
Expand All @@ -49,10 +49,10 @@ public function testFind($array, $predicate, $expected): void
public function dataProviderFindKeyFromArray(): array
{
return [
[$this->array[0], fn ($value) => $value > 3, "d"],
[$this->array[0], fn ($value) => $value > 3, 'd'],
[$this->array[1], fn ($value) => $value > 3, 3],
[$this->array[1], fn ($value) => $value > 5, null],
[$this->array[0], fn ($value, $key) => $key === "c", "c"],
[$this->array[0], fn ($value, $key) => $key === 'c', 'c'],
[$this->array[0], fn () => false, null],
[[], fn () => true, null],
];
Expand All @@ -75,7 +75,7 @@ public function dataProviderAnyFromArray(): array
[$this->array[0], fn ($value) => $value > 3, true],
[$this->array[1], fn ($value) => $value > 3, true],
[$this->array[1], fn ($value) => $value > 5, false],
[$this->array[0], fn ($value, $key) => $key === "c", true],
[$this->array[0], fn ($value, $key) => $key === 'c', true],
[$this->array[0], fn () => false, false],
[[], fn () => true, false],
];
Expand Down

0 comments on commit 0ec5365

Please sign in to comment.