From 2fcca632d9eb6c59022bfed8492b3a5040e7ca73 Mon Sep 17 00:00:00 2001 From: Jamison Valenta Date: Fri, 17 Feb 2023 14:34:55 -0700 Subject: [PATCH] v9.52.0 changes --- src/Collect/Support/Arr.php | 4 +--- src/Collect/Support/Collection.php | 24 +++++++----------------- src/Collect/Support/LazyCollection.php | 8 ++------ upgrade.sh | 2 +- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/Collect/Support/Arr.php b/src/Collect/Support/Arr.php index 52c9a6b..f3a4b04 100644 --- a/src/Collect/Support/Arr.php +++ b/src/Collect/Support/Arr.php @@ -838,9 +838,7 @@ public static function where($array, callable $callback) */ public static function whereNotNull($array) { - return static::where($array, function ($value) { - return ! is_null($value); - }); + return static::where($array, fn ($value) => ! is_null($value)); } /** diff --git a/src/Collect/Support/Collection.php b/src/Collect/Support/Collection.php index c9045f7..e705ee0 100644 --- a/src/Collect/Support/Collection.php +++ b/src/Collect/Support/Collection.php @@ -84,11 +84,9 @@ public function avg($callback = null) { $callback = $this->valueRetriever($callback); - $items = $this->map(function ($value) use ($callback) { - return $callback($value); - })->filter(function ($value) { - return ! is_null($value); - }); + $items = $this + ->map(fn ($value) => $callback($value)) + ->filter(fn ($value) => ! is_null($value)); if ($count = $items->count()) { return $items->sum() / $count; @@ -349,14 +347,10 @@ public function duplicatesStrict($callback = null) protected function duplicateComparator($strict) { if ($strict) { - return function ($a, $b) { - return $a === $b; - }; + return fn ($a, $b) => $a === $b; } - return function ($a, $b) { - return $a == $b; - }; + return fn ($a, $b) => $a == $b; } /** @@ -1633,13 +1627,9 @@ public function values() */ public function zip($items) { - $arrayableItems = array_map(function ($items) { - return $this->getArrayableItems($items); - }, func_get_args()); + $arrayableItems = array_map(fn ($items) => $this->getArrayableItems($items), func_get_args()); - $params = array_merge([function () { - return new static(func_get_args()); - }, $this->items], $arrayableItems); + $params = array_merge([fn () => new static(func_get_args()), $this->items], $arrayableItems); return new static(array_map(...$params)); } diff --git a/src/Collect/Support/LazyCollection.php b/src/Collect/Support/LazyCollection.php index f438ef4..07327cb 100644 --- a/src/Collect/Support/LazyCollection.php +++ b/src/Collect/Support/LazyCollection.php @@ -430,9 +430,7 @@ public function except($keys) public function filter(callable $callback = null) { if (is_null($callback)) { - $callback = function ($value) { - return (bool) $value; - }; + $callback = fn ($value) => (bool) $value; } return new static(function () use ($callback) { @@ -1500,9 +1498,7 @@ public function takeWhile($value) /** @var callable(TValue, TKey): bool $callback */ $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - return $this->takeUntil(function ($item, $key) use ($callback) { - return ! $callback($item, $key); - }); + return $this->takeUntil(fn ($item, $key) => ! $callback($item, $key)); } /** diff --git a/upgrade.sh b/upgrade.sh index 291cc2f..f74bf4d 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -382,7 +382,7 @@ function getCurrentVersionFromGitHub() echo Getting current version from $repository... if [ -z "$requestedVersion" ]; then - collectionVersion=$(git ls-remote $repository --tags v9.51\* | grep tags/ | grep -v {} | cut -d \/ -f 3 | cut -d v -f 2 | grep -v RC | grep -vi beta | sort -t. -k 1,1n -k 2,2n -k 3,3n| tail -1) + collectionVersion=$(git ls-remote $repository --tags v9.52\* | grep tags/ | grep -v {} | cut -d \/ -f 3 | cut -d v -f 2 | grep -v RC | grep -vi beta | sort -t. -k 1,1n -k 2,2n -k 3,3n| tail -1) else collectionVersion=$requestedVersion fi