From 64dd9da8714dde03e25048c1da5136464e85933a Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Fri, 4 Jul 2025 20:19:17 +0100 Subject: [PATCH 1/3] Formatting --- tests/Foundation/Bootstrap/LoadConfigurationTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Foundation/Bootstrap/LoadConfigurationTest.php b/tests/Foundation/Bootstrap/LoadConfigurationTest.php index f8d3f387c1d2..413cd4e6a6d8 100644 --- a/tests/Foundation/Bootstrap/LoadConfigurationTest.php +++ b/tests/Foundation/Bootstrap/LoadConfigurationTest.php @@ -12,7 +12,7 @@ public function testLoadsBaseConfiguration() { $app = new Application(); - (new LoadConfiguration())->bootstrap($app); + (new LoadConfiguration)->bootstrap($app); $this->assertSame('Laravel', $app['config']['app.name']); } @@ -22,7 +22,7 @@ public function testDontLoadBaseConfiguration() $app = new Application(); $app->dontMergeFrameworkConfiguration(); - (new LoadConfiguration())->bootstrap($app); + (new LoadConfiguration)->bootstrap($app); $this->assertNull($app['config']['app.name']); } @@ -32,7 +32,7 @@ public function testLoadsConfigurationInIsolation() $app = new Application(__DIR__.'/../fixtures'); $app->useConfigPath(__DIR__.'/../fixtures/config'); - (new LoadConfiguration())->bootstrap($app); + (new LoadConfiguration)->bootstrap($app); $this->assertNull($app['config']['bar.foo']); $this->assertSame('bar', $app['config']['custom.foo']); From b99bdf860345b7d7981b2202106fcf69bc0710ca Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Fri, 4 Jul 2025 20:42:38 +0100 Subject: [PATCH 2/3] Add breaking test to demo config array has been incorrectly keyed with numbers --- .../Bootstrap/LoadConfigurationTest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Foundation/Bootstrap/LoadConfigurationTest.php b/tests/Foundation/Bootstrap/LoadConfigurationTest.php index 413cd4e6a6d8..bc5e89f54bf3 100644 --- a/tests/Foundation/Bootstrap/LoadConfigurationTest.php +++ b/tests/Foundation/Bootstrap/LoadConfigurationTest.php @@ -2,6 +2,7 @@ namespace Illuminate\Tests\Foundation\Bootstrap; +use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Application; use Illuminate\Foundation\Bootstrap\LoadConfiguration; use PHPUnit\Framework\TestCase; @@ -37,4 +38,23 @@ public function testLoadsConfigurationInIsolation() $this->assertNull($app['config']['bar.foo']); $this->assertSame('bar', $app['config']['custom.foo']); } + + public function testConfigurationArrayKeysMatchLoadedFilenames() + { + $baseConfigPath = __DIR__.'/../../../config'; + $customConfigPath = __DIR__.'/../fixtures/config'; + + $app = new Application(); + $app->useConfigPath($customConfigPath); + + (new LoadConfiguration)->bootstrap($app); + + $this->assertEqualsCanonicalizing( + array_keys($app['config']->all()), + collect((new Filesystem)->files([ + $baseConfigPath, + $customConfigPath, + ]))->map(fn ($file) => $file->getBaseName('.php'))->unique()->values()->toArray() + ); + } } From 5995b916368b02daf930e8ceb9f8856bf1dc9b82 Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Sat, 5 Jul 2025 08:35:03 +0100 Subject: [PATCH 3/3] Correct how base options for missing config files are preloaded --- src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php b/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php index 2fa429f83034..4771d5d10505 100644 --- a/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php +++ b/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php @@ -5,6 +5,7 @@ use Illuminate\Config\Repository; use Illuminate\Contracts\Config\Repository as RepositoryContract; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Support\Collection; use SplFileInfo; use Symfony\Component\Finder\Finder; @@ -69,7 +70,7 @@ protected function loadConfigurationFiles(Application $app, RepositoryContract $ ? $this->getBaseConfiguration() : []; - foreach (array_diff(array_keys($base), array_keys($files)) as $name => $config) { + foreach ((new Collection($base))->diffKeys($files) as $name => $config) { $repository->set($name, $config); }