From 665f03c2c36403988131d570b0d5b4bec1295e48 Mon Sep 17 00:00:00 2001 From: agis Date: Tue, 21 Jul 2026 17:14:08 +0700 Subject: [PATCH 1/3] refactor: deprecate array_first/array_last helpers in favor of Arr::first/Arr::last Replace all internal usages with Arr::first/Arr::last. The helper functions remain available but are marked @deprecated. Co-Authored-By: Claude Fable 5 --- src/Illuminate/Database/Eloquent/Collection.php | 3 ++- src/Illuminate/Database/Eloquent/Model.php | 5 +++-- src/Illuminate/Foundation/Application.php | 3 ++- src/Illuminate/Foundation/EnvironmentDetector.php | 3 ++- src/Illuminate/Routing/Route.php | 3 ++- src/Illuminate/Routing/RouteCollection.php | 3 ++- src/Illuminate/Support/Collection.php | 2 +- src/Illuminate/Support/helpers.php | 4 ++++ src/Illuminate/View/Factory.php | 3 ++- 9 files changed, 20 insertions(+), 9 deletions(-) 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..de27a3c7 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); } /** 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); }); From eb7c8989f8bedf832cb9a94ae8080e2c7b371cf7 Mon Sep 17 00:00:00 2001 From: agis Date: Tue, 21 Jul 2026 17:31:57 +0700 Subject: [PATCH 2/3] fix(config): avoid null array offset deprecation in Repository::load PHP 8.5 deprecates using null as an array offset. $namespace is null for non-namespaced config keys, so guard the afterLoad lookup. Co-Authored-By: Claude Fable 5 --- src/Illuminate/Config/Repository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } From 239c576911656e0debfdf2fa44e23fbfedb2a7d6 Mon Sep 17 00:00:00 2001 From: agis Date: Tue, 21 Jul 2026 17:48:28 +0700 Subject: [PATCH 3/3] fix(support): avoid null array offset in Collection::groupBy PHP 8.5 deprecates using null as an array offset. groupBy's key can resolve to null (closure or data_get returning null), so coalesce to an empty string. Co-Authored-By: Claude Fable 5 --- src/Illuminate/Support/Collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index de27a3c7..f7359001 100755 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -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);