Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added typehints #1

Merged
merged 2 commits into from
Apr 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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