[2.0][DDC-483] Fixed.
This commit is contained in:
parent
5aa14ab373
commit
c4a9ce1cd3
@ -410,12 +410,11 @@ class Parser
|
|||||||
$this->match(Lexer::T_CLOSE_CURLY_BRACES);
|
$this->match(Lexer::T_CLOSE_CURLY_BRACES);
|
||||||
|
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$key = key($value);
|
list ($key, $val) = $value;
|
||||||
|
if ($key !== null) {
|
||||||
if (is_string($key)) {
|
$array[$key] = $val;
|
||||||
$array[$key] = $value[$key];
|
|
||||||
} else {
|
} else {
|
||||||
$array[] = $value[$key];
|
$array[] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,9 +440,9 @@ class Parser
|
|||||||
$key = $this->_lexer->token['value'];
|
$key = $this->_lexer->token['value'];
|
||||||
$this->match(Lexer::T_EQUALS);
|
$this->match(Lexer::T_EQUALS);
|
||||||
|
|
||||||
return array($key => $this->PlainValue());
|
return array($key, $this->PlainValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($this->Value());
|
return array(null, $this->Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,16 @@ class ParserTest extends \Doctrine\Tests\DoctrineTestCase
|
|||||||
$this->assertNull($annot->value);
|
$this->assertNull($annot->value);
|
||||||
$this->assertTrue(is_array($annot->foo));
|
$this->assertTrue(is_array($annot->foo));
|
||||||
$this->assertTrue(isset($annot->foo['key1']));
|
$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
|
// Nested arrays with nested annotations
|
||||||
$result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})');
|
$result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user