Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes doctrine/common#326 #38

Merged
merged 2 commits into from
Jul 10, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions lib/Doctrine/Common/Annotations/DocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -843,16 +843,7 @@ private function MethodCall()
*/
private function Values()
{
$values = array();

// Handle the case of a single array as value, i.e. @Foo({....})
if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) {
$values['value'] = $this->Value();

return $values;
}

$values[] = $this->Value();
$values = array($this->Value());

while ($this->lexer->isNextToken(DocLexer::T_COMMA)) {
$this->match(DocLexer::T_COMMA);
Expand Down
17 changes: 17 additions & 0 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ public function testBasicAnnotations()
$this->assertEquals('value1', $annot->value[1]['key1']);
$this->assertEquals('value2', $annot->value[1]['key2']);

// Array as first value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move these assertions into a new test method?

$result = $parser->parse('@Name({"key1"="value1"})');
$annot = $result[0];

$this->assertTrue($annot instanceof Name);
$this->assertTrue(is_array($annot->value));
$this->assertEquals('value1', $annot->value['key1']);

// Array as first value and additional values
$result = $parser->parse('@Name({"key1"="value1"}, foo="bar")');
$annot = $result[0];

$this->assertTrue($annot instanceof Name);
$this->assertTrue(is_array($annot->value));
$this->assertEquals('value1', $annot->value['key1']);
$this->assertEquals('bar', $annot->foo);

// Complete docblock
$docblock = <<<DOCBLOCK
/**
Expand Down