diff --git a/Command/ConfigDebugCommand.php b/Command/ConfigDebugCommand.php index 50c8dddf5..93b3b9068 100644 --- a/Command/ConfigDebugCommand.php +++ b/Command/ConfigDebugCommand.php @@ -161,7 +161,7 @@ private function getConfigForPath(array $config, string $path, string $alias): m $steps = explode('.', $path); foreach ($steps as $step) { - if (!\array_key_exists($step, $config)) { + if (!\is_array($config) || !\array_key_exists($step, $config)) { throw new LogicException(\sprintf('Unable to find configuration for "%s.%s".', $alias, $path)); } diff --git a/Tests/Functional/ConfigDebugCommandTest.php b/Tests/Functional/ConfigDebugCommandTest.php index ea4ee0788..259a9e738 100644 --- a/Tests/Functional/ConfigDebugCommandTest.php +++ b/Tests/Functional/ConfigDebugCommandTest.php @@ -233,6 +233,16 @@ public static function provideCompletionSuggestions(): \Generator yield 'option --format, debug' => [true, ['--format', ''], ['yaml', 'json']]; } + public function testDumpPathDeepIntoScalar() + { + $tester = $this->createCommandTester(true); + + $tester->execute(['name' => 'framework', 'path' => 'secret.foo']); + + $this->assertSame(1, $tester->getStatusCode()); + $this->assertStringContainsString('Unable to find configuration for "framework.secret.foo"', $tester->getDisplay()); + } + private function createCommandTester(bool $debug): CommandTester { $command = $this->createApplication($debug)->find('debug:config');