Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'hotfix/3236' into develop

Forward port #3236
  • Loading branch information...
commit 0de645c622197de02194e429a58d639048212e97 2 parents e044281 + b2b7486
@weierophinney weierophinney authored
View
25 library/Zend/Config/Reader/Ini.php
@@ -131,8 +131,8 @@ protected function process(array $data)
foreach ($data as $section => $value) {
if (is_array($value)) {
if (strpos($section, $this->nestSeparator) !== false) {
- $section = explode($this->nestSeparator, $section, 2);
- $config[$section[0]][$section[1]] = $this->processSection($value);
+ $sections = explode($this->nestSeparator, $section);
+ $config = array_merge_recursive($config, $this->buildNestedSection($sections, $value));
} else {
$config[$section] = $this->processSection($value);
}
@@ -145,6 +145,27 @@ protected function process(array $data)
}
/**
+ * Process a nested section
+ *
+ * @param array $sections
+ * @param mixed $value
+ * @return array
+ */
+ private function buildNestedSection($sections, $value)
+ {
+ if(count($sections) == 0) {
+ return $this->processSection($value);
+ }
+
+ $nestedSection = array();
+
+ $first = array_shift($sections);
+ $nestedSection[$first] = $this->buildNestedSection($sections, $value);
+
+ return $nestedSection;
+ }
+
+ /**
* Process a section.
*
* @param array $section
View
16 tests/ZendTest/Config/Reader/IniTest.php
@@ -87,17 +87,17 @@ public function testFromStringWithSection()
public function testFromStringNested()
{
$ini = <<<ECS
-foo.bar = foobar
-foobar[] = foobarArray
-foo.baz[] = foobaz1
-foo.baz[] = foobaz2
+bla.foo.bar = foobar
+bla.foobar[] = foobarArray
+bla.foo.baz[] = foobaz1
+bla.foo.baz[] = foobaz2
ECS;
$arrayIni = $this->reader->fromString($ini);
- $this->assertEquals($arrayIni['foo']['bar'], 'foobar');
- $this->assertEquals($arrayIni['foobar'][0], 'foobarArray');
- $this->assertEquals($arrayIni['foo']['baz'][0], 'foobaz1');
- $this->assertEquals($arrayIni['foo']['baz'][1], 'foobaz2');
+ $this->assertEquals($arrayIni['bla']['foo']['bar'], 'foobar');
+ $this->assertEquals($arrayIni['bla']['foobar'][0], 'foobarArray');
+ $this->assertEquals($arrayIni['bla']['foo']['baz'][0], 'foobaz1');
+ $this->assertEquals($arrayIni['bla']['foo']['baz'][1], 'foobaz2');
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.