From 7bd0c5abdd96ecc0ed402d95cb38d1190161986b Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Thu, 1 Oct 2015 15:05:17 +0200 Subject: [PATCH] itteratively expand key and attempt to match fixes #4459 (also) --- src/Composer/Command/ConfigCommand.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 2b7fd4846..5d3823b67 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -238,17 +238,19 @@ EOT } elseif (strpos($settingKey, '.')) { $bits = explode('.', $settingKey); $data = $data['config']; + $match = false; foreach ($bits as $bit) { - if (isset($data[$bit])) { - $data = $data[$bit]; - } elseif (isset($data[implode('.', $bits)])) { - // last bit can contain domain names and such so try to join whatever is left if it exists - $data = $data[implode('.', $bits)]; - break; - } else { - throw new \RuntimeException($settingKey.' is not defined'); + $key = isset($key) ? $key.'.'.$bit : $bit; + $match = false; + if (isset($data[$key])) { + $match = true; + $data = $data[$key]; + unset($key); } - array_shift($bits); + } + + if (!$match) { + throw new \RuntimeException($settingKey.' is not defined.'); } $value = $data;