diff --git a/lib/Doctrine/Common/Annotations/DocLexer.php b/lib/Doctrine/Common/Annotations/DocLexer.php index 29c504ccd..d864540e0 100644 --- a/lib/Doctrine/Common/Annotations/DocLexer.php +++ b/lib/Doctrine/Common/Annotations/DocLexer.php @@ -84,7 +84,7 @@ protected function getCatchablePatterns() return array( '[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*', '(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?', - '"(?:[^"])*"', + '"(?:""|[^"])*+"', ); } diff --git a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php index c09d7bbb3..b9fe007f3 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -161,8 +161,57 @@ public function testWithinDoubleQuotesVeryVeryLongStringWillNotOverflowPregSplit { $lexer = new DocLexer(); - $lexer->setInput('"' . str_repeat('.', 10240) . '"'); + $lexer->setInput('"' . str_repeat('.', 20240) . '"'); $this->assertInternalType('array', $lexer->glimpse()); } + + /** + * @group 44 + */ + public function testRecognizesDoubleQuotesEscapeSequence() + { + $lexer = new DocLexer(); + $docblock = '@Foo("""' . "\n" . '""")'; + + $tokens = array ( + array( + 'value' => '@', + 'position' => 0, + 'type' => DocLexer::T_AT, + ), + array( + 'value' => 'Foo', + 'position' => 1, + 'type' => DocLexer::T_IDENTIFIER, + ), + array( + 'value' => '(', + 'position' => 4, + 'type' => DocLexer::T_OPEN_PARENTHESIS, + ), + array( + 'value' => "\"\n\"", + 'position' => 5, + 'type' => DocLexer::T_STRING, + ), + array( + 'value' => ')', + 'position' => 12, + 'type' => DocLexer::T_CLOSE_PARENTHESIS, + ), + ); + + $lexer->setInput($docblock); + + foreach ($tokens as $expected) { + $lexer->moveNext(); + $lookahead = $lexer->lookahead; + $this->assertEquals($expected['value'], $lookahead['value']); + $this->assertEquals($expected['type'], $lookahead['type']); + $this->assertEquals($expected['position'], $lookahead['position']); + } + + $this->assertFalse($lexer->moveNext()); + } } diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 7d670a99e..d2511f018 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1282,6 +1282,19 @@ public function testKeyHasNumber() $this->assertEquals(1, count($annots)); $this->assertEquals(array('foo' => 'test', 'bar2' => 'test'), $annots[0]->settings); } + + /** + * @group 44 + */ + public function testSupportsEscapedQuotedValues() + { + $result = $this->createTestParser()->parse('@Doctrine\Tests\Common\Annotations\Name(foo="""bar""")'); + + $this->assertCount(1, $result); + + $this->assertTrue($result[0] instanceof Name); + $this->assertEquals('"bar"', $result[0]->foo); + } } /** @Annotation */