@@ -174,11 +174,11 @@ public function set($key, $value = null)
174174 * Load the configuration group for the key.
175175 *
176176 * @param string $group
177- * @param string $namespace
177+ * @param string|null $namespace
178178 * @param string $collection
179179 * @return void
180180 */
181- protected function load ($ group , $ namespace , $ collection )
181+ protected function load ($ group , ? string $ namespace , $ collection )
182182 {
183183 $ env = $ this ->environment ;
184184
@@ -191,10 +191,10 @@ protected function load($group, $namespace, $collection)
191191
192192 $ items = $ this ->loader ->load ($ env , $ group , $ namespace );
193193
194- // If we've already loaded this collection, we will just bail out since we do
195- // not want to load it again. Once items are loaded a first time they will
196- // stay kept in memory within this class and not loaded from disk again .
197- if (isset ($ this ->afterLoad [$ namespace ])) {
194+ // After load callbacks are only ever registered against a real namespace, so
195+ // the global namespace (null) can never have one. Guarding here also avoids
196+ // using null as an array offset, which is deprecated as of PHP 8.5 .
197+ if ($ namespace !== null && isset ($ this ->afterLoad [$ namespace ])) {
198198 $ items = $ this ->callAfterLoad ($ namespace , $ group , $ items );
199199 }
200200
@@ -209,7 +209,7 @@ protected function load($group, $namespace, $collection)
209209 * @param array $items
210210 * @return array
211211 */
212- protected function callAfterLoad ($ namespace , $ group , $ items )
212+ protected function callAfterLoad (string $ namespace , $ group , $ items )
213213 {
214214 $ callback = $ this ->afterLoad [$ namespace ];
215215
@@ -312,7 +312,7 @@ public function package($namespace, $hint)
312312 * @param \Closure $callback
313313 * @return void
314314 */
315- public function afterLoading ($ namespace , Closure $ callback )
315+ public function afterLoading (string $ namespace , Closure $ callback )
316316 {
317317 $ this ->afterLoad [$ namespace ] = $ callback ;
318318 }
0 commit comments