Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #343 from tighten/v9.52.0-changes
Browse files Browse the repository at this point in the history
v9.52.0 changes
  • Loading branch information
jamisonvalenta authored Feb 17, 2023
2 parents c9ffe0f + 2fcca63 commit d4772fe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
4 changes: 1 addition & 3 deletions src/Collect/Support/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
24 changes: 7 additions & 17 deletions src/Collect/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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));
}
Expand Down
8 changes: 2 additions & 6 deletions src/Collect/Support/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d4772fe

Please sign in to comment.