1
0
mirror of synced 2024-12-13 22:56:04 +03:00

[2.0][DDC-483] Fixed.

This commit is contained in:
romanb 2010-03-31 17:19:32 +00:00
parent 5aa14ab373
commit c4a9ce1cd3
2 changed files with 16 additions and 7 deletions

View File

@ -410,12 +410,11 @@ class Parser
$this->match(Lexer::T_CLOSE_CURLY_BRACES);
foreach ($values as $value) {
$key = key($value);
if (is_string($key)) {
$array[$key] = $value[$key];
list ($key, $val) = $value;
if ($key !== null) {
$array[$key] = $val;
} else {
$array[] = $value[$key];
$array[] = $val;
}
}
@ -441,9 +440,9 @@ class Parser
$key = $this->_lexer->token['value'];
$this->match(Lexer::T_EQUALS);
return array($key => $this->PlainValue());
return array($key, $this->PlainValue());
}
return array($this->Value());
return array(null, $this->Value());
}
}

View File

@ -25,6 +25,16 @@ class ParserTest extends \Doctrine\Tests\DoctrineTestCase
$this->assertNull($annot->value);
$this->assertTrue(is_array($annot->foo));
$this->assertTrue(isset($annot->foo['key1']));
// Numerical arrays
$result = $parser->parse('@Name({2="foo", 4="bar"})');
$annot = $result['Doctrine\Tests\Common\Annotations\Name'];
$this->assertTrue(is_array($annot->value));
$this->assertEquals('foo', $annot->value[2]);
$this->assertEquals('bar', $annot->value[4]);
$this->assertFalse(isset($annot->value[0]));
$this->assertFalse(isset($annot->value[1]));
$this->assertFalse(isset($annot->value[3]));
// Nested arrays with nested annotations
$result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})');