Skip to content

Commit

Permalink
Merge pull request #1 from SidRoberts/patch-1
Browse files Browse the repository at this point in the history
Added typehints
  • Loading branch information
gabbanaesteban authored Apr 11, 2019
2 parents 28e09c4 + 34a2bde commit d3f62f7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class Arr
*Returns true if the provided function returns true for all elements of an array, false otherwise.
*
* @param array $items
* @param [type] $func
* @param callable $func
*/
public static function all(array $items, $func): bool
public static function all(array $items, callable $func): bool
{
return count(array_filter($items, $func)) === count($items);
}
Expand All @@ -19,9 +19,9 @@ public static function all(array $items, $func): bool
* Returns true if the provided function returns true for at least one element of an array, false otherwise.
*
* @param array $items
* @param [type] $func
* @param callable $func
*/
public static function any(array $items, $func): bool
public static function any(array $items, callable $func): bool
{
return count(array_filter($items, $func)) > 0;
}
Expand All @@ -30,9 +30,9 @@ public static function any(array $items, $func): bool
* Chunks an array into smaller arrays of a specified size.
*
* @param array $items
* @param [type] $size
* @param int $size
*/
public static function chunk(array $items, $size): array
public static function chunk(array $items, int $size): array
{
return array_chunk($items, $size);
}
Expand Down Expand Up @@ -62,7 +62,7 @@ public static function deepFlatten(array $items): array
* @param array $items
* @param int $n
*/
public static function drop(array $items, $n = 1): array
public static function drop(array $items, int $n = 1): array
{
return array_slice($items, $n);
}
Expand All @@ -71,9 +71,9 @@ public static function drop(array $items, $n = 1): array
* Returns the last element for which the provided function returns a truthy value.
*
* @param array $items
* @param [type] $func
* @param callable $func
*/
public static function findLast(array $items, $func)
public static function findLast(array $items, callable $func)
{
$filteredItems = array_filter($items, $func);

Expand All @@ -84,9 +84,9 @@ public static function findLast(array $items, $func)
* Returns the index of the last element for which the provided function returns a truthy value.
*
* @param array $items
* @param [type] $func
* @param callable $func
*/
public static function findLastIndex(array $items, $func)
public static function findLastIndex(array $items, callable $func)
{
$keys = array_keys(array_filter($items, $func));

Expand Down Expand Up @@ -222,9 +222,9 @@ public static function pull(&$items, ...$params)
* Filters the collection using the given callback.
*
* @param array $items
* @param [type] $func
* @param callable $func
*/
public static function reject(array $items, $func)
public static function reject(array $items, callable $func)
{
return array_values(array_diff($items, array_filter($items, $func)));
}
Expand All @@ -233,9 +233,9 @@ public static function reject(array $items, $func)
* Removes elements from an array for which the given function returns false.
*
* @param array $items
* @param [type] $func
* @param callable $func
*/
public static function remove(array $items, $func)
public static function remove(array $items, callable $func)
{
$filtered = array_filter($items, $func);

Expand All @@ -258,7 +258,7 @@ public static function tail(array $items)
* @param array $items
* @param int $n
*/
public static function take(array $items, $n = 1): array
public static function take(array $items, int $n = 1): array
{
return array_slice($items, 0, $n);
}
Expand Down

0 comments on commit d3f62f7

Please sign in to comment.