diff --git a/src/Arr.php b/src/Arr.php index f918334..2a06616 100644 --- a/src/Arr.php +++ b/src/Arr.php @@ -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 callable $func + * @param mixed $func */ - public static function all(array $items, callable $func): bool + public static function all(array $items, $func): bool { return \count(array_filter($items, $func)) === \count($items); } @@ -19,9 +19,9 @@ public static function all(array $items, callable $func): bool * Returns true if the provided function returns true for at least one element of an array, false otherwise. * * @param array $items - * @param callable $func + * @param mixed $func */ - public static function any(array $items, callable $func): bool + public static function any(array $items, $func): bool { return \count(array_filter($items, $func)) > 0; } @@ -71,9 +71,11 @@ public static function drop(array $items, int $n = 1): array * Returns the last element for which the provided function returns a truthy value. * * @param array $items - * @param callable $func + * @param mixed $func + * + * @return mixed */ - public static function findLast(array $items, callable $func) + public static function findLast(array $items, $func) { $filteredItems = array_filter($items, $func); @@ -84,9 +86,9 @@ public static function findLast(array $items, callable $func) * Returns the index of the last element for which the provided function returns a truthy value. * * @param array $items - * @param callable $func + * @param mixed $func */ - public static function findLastIndex(array $items, callable $func) + public static function findLastIndex(array $items, $func) { $keys = array_keys(array_filter($items, $func)); @@ -116,7 +118,7 @@ public static function flatten(array $items): array * Groups the elements of an array based on the given function. * * @param array $items - * @param [type] $func + * @param mixed $func */ public static function groupBy(array $items, $func): array { @@ -139,12 +141,12 @@ public static function groupBy(array $items, $func): array * Sorts a collection of arrays or objects by key * * @param array $items - * @param [type] $attr - * @param [type] $order + * @param mixed $attr + * @param string $order * * @return array */ - public static function orderBy(array $items, $attr, $order): array + public static function orderBy(array $items, $attr, string $order): array { $sortedItems = []; foreach ($items as $item) { @@ -176,6 +178,8 @@ public static function hasDuplicates(array $items): bool * Returns the head of a list. * * @param array $items + * + * @return mixed */ public static function head(array $items) { @@ -186,6 +190,8 @@ public static function head(array $items) * Returns the last element in an array. * * @param array $items + * + * @return mixed */ public static function last(array $items) { @@ -196,7 +202,7 @@ public static function last(array $items) * Retrieves all of the values for a given key: * * @param array $items - * @param [type] $key + * @param mixed $key */ public static function pluck(array $items, $key) { @@ -209,7 +215,7 @@ public static function pluck(array $items, $key) * Mutates the original array to filter out the values specified. * * @param array $items - * @param [type] ...$params + * @param mixed ...$params */ public static function pull(&$items, ...$params) { @@ -222,9 +228,9 @@ public static function pull(&$items, ...$params) * Filters the collection using the given callback. * * @param array $items - * @param callable $func + * @param mixed $func */ - public static function reject(array $items, callable $func) + public static function reject(array $items, $func) { return array_values(array_diff($items, array_filter($items, $func))); } @@ -233,9 +239,9 @@ public static function reject(array $items, callable $func) * Removes elements from an array for which the given function returns false. * * @param array $items - * @param callable $func + * @param mixed $func */ - public static function remove(array $items, callable $func) + public static function remove(array $items, $func) { $filtered = array_filter($items, $func); @@ -267,7 +273,7 @@ public static function take(array $items, int $n = 1): array * Filters out the elements of an array, that have one of the specified values. * * @param array $items - * @param [type] ...$params + * @param mixed ...$params */ public static function without(array $items, ...$params) { diff --git a/src/Str.php b/src/Str.php index 32aa72b..3924cc3 100644 --- a/src/Str.php +++ b/src/Str.php @@ -82,7 +82,7 @@ public static function isAnagram(string $string1, string $string2): bool /** * Returns true if the given string is lower case, false otherwise. * - * @param [type] $string + * @param string $string * * @return bool */ @@ -94,11 +94,11 @@ public static function isLowerCase(string $string): bool /** * Returns true if the given string is upper case, false otherwise. * - * @param [type] $string + * @param string $string * * @return bool */ - public static function isUpperCase($string): bool + public static function isUpperCase(string $string): bool { return $string === mb_strtoupper($string); } @@ -106,11 +106,11 @@ public static function isUpperCase($string): bool /** * Returns true if the given string is a palindrome, false otherwise. * - * @param [type] $string + * @param string $string * * @return bool */ - public static function palindrome($string): bool + public static function palindrome(string $string): bool { return strrev($string) === $string; } @@ -147,12 +147,12 @@ public static function countVowels(string $string): int * Decapitalizes the first letter of the sring and then adds it with rest of the string. Omit the upperRest parameter to keep the * rest of the string intact, or set it to true to convert to uppercase. * - * @param [type] $string + * @param string $string * @param bool $upperRest * * @return string */ - public static function decapitalize($string, $upperRest = false): string + public static function decapitalize(string $string, bool $upperRest = false): string { return mb_strtolower(mb_substr($string, 0, 1)) . ($upperRest ? mb_strtoupper(mb_substr($string, 1)) : mb_substr($string, 1)); } @@ -161,7 +161,7 @@ public static function decapitalize($string, $upperRest = false): string * Substring a string to specific lenght, but removing whole words * * @param string $string - * @param string $to + * @param int $to * * @return string */ @@ -189,6 +189,6 @@ public static function letterPlusNumber(string $letter, int $number): string ++$letter; } - return $letter; + return (string) $letter; } }