diff --git a/src/Illuminate/Config/Repository.php b/src/Illuminate/Config/Repository.php index 9788056c..2a8922d2 100755 --- a/src/Illuminate/Config/Repository.php +++ b/src/Illuminate/Config/Repository.php @@ -154,7 +154,7 @@ protected function load($group, $namespace, $collection) // If we've already loaded this collection, we will just bail out since we do // not want to load it again. Once items are loaded a first time they will // stay kept in memory within this class and not loaded from disk again. - if (isset($this->afterLoad[$namespace])) + if ( ! is_null($namespace) && isset($this->afterLoad[$namespace])) { $items = $this->callAfterLoad($namespace, $group, $items); } diff --git a/src/Illuminate/Database/Eloquent/Collection.php b/src/Illuminate/Database/Eloquent/Collection.php index 96dbbbeb..6ca90d91 100755 --- a/src/Illuminate/Database/Eloquent/Collection.php +++ b/src/Illuminate/Database/Eloquent/Collection.php @@ -1,5 +1,6 @@ getKey(); } - return array_first($this->items, function($model, $itemKey) use ($key) + return Arr::first($this->items, function($model, $itemKey) use ($key) { return $model->getKey() == $key; diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index da9551a1..d677bf60 100755 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -6,6 +6,7 @@ use Carbon\Carbon; use Exception; use Illuminate\Database\Connection; +use Illuminate\Support\Arr; use Illuminate\Support\Str; use LogicException; use JsonSerializable; @@ -294,7 +295,7 @@ public static function hasGlobalScope($scope): bool */ public static function getGlobalScope($scope): ?ScopeInterface { - return array_first(static::$globalScopes[get_called_class()], function($value, $key) use ($scope) + return Arr::first(static::$globalScopes[get_called_class()], function($value, $key) use ($scope) { return $scope instanceof $value; }); @@ -991,7 +992,7 @@ protected function getBelongsToManyCaller():?string { $self = __FUNCTION__; - $caller = array_first(debug_backtrace(false), function($trace, $key) use ($self) + $caller = Arr::first(debug_backtrace(false), function($trace, $key) use ($self) { $caller = $trace['function']; diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 55e3790b..928bc0ba 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -1,6 +1,7 @@ loadedProviders)) { - return array_first($this->serviceProviders, function($value, $key) use ($name) + return Arr::first($this->serviceProviders, function($value, $key) use ($name) { return get_class($value) == $name; }); diff --git a/src/Illuminate/Foundation/EnvironmentDetector.php b/src/Illuminate/Foundation/EnvironmentDetector.php index 8ce8ccc3..859e1947 100644 --- a/src/Illuminate/Foundation/EnvironmentDetector.php +++ b/src/Illuminate/Foundation/EnvironmentDetector.php @@ -1,5 +1,6 @@ matches($request, $includingMethod); }); diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index d3a4e496..f7359001 100755 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -149,7 +149,7 @@ public function first(?Closure $callback = null, $default = null) return count($this->items) > 0 ? reset($this->items) : null; } - return array_first($this->items, $callback, $default); + return Arr::first($this->items, $callback, $default); } /** @@ -212,7 +212,7 @@ public function groupBy($groupBy) foreach ($this->items as $key => $value) { - $results[$this->getGroupByKey($groupBy, $key, $value)][] = $value; + $results[$this->getGroupByKey($groupBy, $key, $value) ?? ''][] = $value; } return new static($results); diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index 953e2008..3fbc00b5 100755 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -177,6 +177,8 @@ function array_fetch($array, $key) * @param \Closure $callback * @param mixed $default * @return mixed + * + * @deprecated Use \Illuminate\Support\Arr::first() instead. */ function array_first($array, $callback, $default = null) { @@ -193,6 +195,8 @@ function array_first($array, $callback, $default = null) * @param \Closure $callback * @param mixed $default * @return mixed + * + * @deprecated Use \Illuminate\Support\Arr::last() instead. */ function array_last($array, $callback, $default = null) { diff --git a/src/Illuminate/View/Factory.php b/src/Illuminate/View/Factory.php index 325bd457..f72c7e5f 100755 --- a/src/Illuminate/View/Factory.php +++ b/src/Illuminate/View/Factory.php @@ -3,6 +3,7 @@ use Closure; use Illuminate\Events\Dispatcher; use Illuminate\Container\Container; +use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\View\Engines\EngineResolver; use Illuminate\Support\Contracts\ArrayableInterface as Arrayable; @@ -272,7 +273,7 @@ protected function getExtension($path) { $extensions = array_keys($this->extensions); - return array_first($extensions, function($value, $key) use ($path) + return Arr::first($extensions, function($value, $key) use ($path) { return ends_with($path, $value); });