Skip to content

Commit

Permalink
[DependencyInjection] fixed conversion of DOM to array when DOM inclu…
Browse files Browse the repository at this point in the history
…des multiple elements with the same name
  • Loading branch information
kriswallsmith authored and fabpot committed Jul 8, 2010
1 parent 7e8d0d2 commit e63ff6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -374,7 +374,7 @@ static public function convertDomElementToArray(\DomElement $element)
}
} elseif (!$node instanceof \DOMComment) {
if (isset($config[$node->localName])) {
if (!is_array($config[$node->localName])) {
if (!is_array($config[$node->localName]) || !is_int(key($config[$node->localName]))) {
$config[$node->localName] = array($config[$node->localName]);
}
$config[$node->localName][] = static::convertDomElementToArray($node);
Expand Down
Expand Up @@ -159,6 +159,10 @@ public function testConvertDomElementToArray()
$doc = new \DOMDocument("1.0");
$doc->loadXML('<foo><foo><!-- foo --></foo></foo>');
$this->assertEquals(array('foo' => null), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');

$doc = new \DOMDocument("1.0");
$doc->loadXML('<foo><foo foo="bar"/><foo foo="bar"/></foo>');
$this->assertEquals(array('foo' => array(array('foo' => 'bar'), array('foo' => 'bar'))), ProjectLoader2::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
}

public function testExtensions()
Expand Down

0 comments on commit e63ff6e

Please sign in to comment.