diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index ce6594d45d36..b71d48286a07 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -246,8 +246,8 @@ protected function registerProperties() if (static::$discovering) { throw new ConfigException( 'During Auto-Discovery of Registrars,' - . ' "' . static::class . '" executes Auto-Discovery again.' - . ' "' . clean_path(static::$registrarFile) . '" seems to have bad code.', + . ' "' . static::class . '" executes Auto-Discovery again.' + . ' "' . clean_path(static::$registrarFile) . '" seems to have bad code.', ); } @@ -291,7 +291,7 @@ protected function registerProperties() foreach ($properties as $property => $value) { if (isset($this->{$property}) && is_array($this->{$property}) && is_array($value)) { - $this->{$property} = array_merge($this->{$property}, $value); + $this->{$property} = array_merge_recursive($this->{$property}, $value); } else { $this->{$property} = $value; } diff --git a/tests/_support/Config/TestRegistrar.php b/tests/_support/Config/TestRegistrar.php index 806fd1518402..0eceef253651 100644 --- a/tests/_support/Config/TestRegistrar.php +++ b/tests/_support/Config/TestRegistrar.php @@ -27,6 +27,9 @@ public static function RegistrarConfig() 'first', 'second', ], + 'baz' => [ + 'bar' => 'ber', + ], ]; } } diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 9158db34140f..7d6a36f9e474 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -270,6 +270,9 @@ public function testRegistrars(): void $this->assertSame('bar', $config->foo); // add to an existing array property $this->assertSame(['baz', 'first', 'second'], $config->bar); + + // add to an existing nested array property + $this->assertSame(['foo', 'bar' => ['bir', 'bur', 'ber']], $config->baz); } public function testBadRegistrar(): void diff --git a/tests/system/Config/fixtures/RegistrarConfig.php b/tests/system/Config/fixtures/RegistrarConfig.php index c2ea35927228..17e4ff05ff96 100644 --- a/tests/system/Config/fixtures/RegistrarConfig.php +++ b/tests/system/Config/fixtures/RegistrarConfig.php @@ -19,4 +19,11 @@ class RegistrarConfig extends BaseConfig public $bar = [ 'baz', ]; + public array $baz = [ + 'foo', + 'bar' => [ + 'bir', + 'bur', + ], + ]; }