diff --git a/lib/Doctrine/Common/Annotations/Parser.php b/lib/Doctrine/Common/Annotations/Parser.php index f08248cd5..6ceba3d06 100644 --- a/lib/Doctrine/Common/Annotations/Parser.php +++ b/lib/Doctrine/Common/Annotations/Parser.php @@ -31,6 +31,7 @@ namespace Doctrine\Common\Annotations; * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel + * @author Benjamin Eberlei */ class Parser { @@ -165,7 +166,7 @@ class Parser if ($this->_lexer->lookahead === null) { $message .= 'end of string.'; } else { - $message .= "'{$token['value']}'"; + $message .= "'{$token['value']}' at position {$token['position']}."; } throw AnnotationException::syntaxError($message); @@ -357,8 +358,7 @@ class Parser return false; default: - var_dump($this->_lexer->lookahead); - throw new \Exception("Invalid value."); + $this->syntaxError('PlainValue'); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/ParserTest.php b/tests/Doctrine/Tests/Common/Annotations/ParserTest.php index 1d27be0b3..fbc66dd9e 100644 --- a/tests/Doctrine/Tests/Common/Annotations/ParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/ParserTest.php @@ -90,6 +90,24 @@ DOCBLOCK; $this->assertEquals(0, count($result)); } + + public function testAnnotationDontAcceptSingleQuotes() + { + $this->setExpectedException( + 'Doctrine\Common\Annotations\AnnotationException', + "[Syntax Error] Expected 'PlainValue', got ''' at position 10." + ); + + $parser = $this->createTestParser(); + $parser->parse("@Name(foo='bar')"); + } + + public function createTestParser() + { + $parser = new Parser(); + $parser->setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\'); + return $parser; + } } class Name extends \Doctrine\Common\Annotations\Annotation {