From 90eb2b7c88a05e10f4a52cb99b77706d815792d2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 3 Dec 2013 16:27:58 +0100 Subject: [PATCH 1/3] Adding failing test for DCOM-179 Constants ending with `_` are not considered by the parser --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 4 ++++ .../Tests/Common/Annotations/Fixtures/ClassWithConstants.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 5b99787ae..2b6c08448 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -742,6 +742,10 @@ public function getConstantsProvider() '@AnnotationWithConstants(ClassWithConstants::SOME_VALUE)', ClassWithConstants::SOME_VALUE ); + $provider[] = array( + '@AnnotationWithConstants(ClassWithConstants::OTHER_KEY_)', + ClassWithConstants::OTHER_KEY_ + ); $provider[] = array( '@AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_VALUE)', ClassWithConstants::SOME_VALUE diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php index 055e245c0..0918534e5 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php @@ -4,7 +4,7 @@ class ClassWithConstants { - const SOME_VALUE = 'ClassWithConstants.SOME_VALUE'; const SOME_KEY = 'ClassWithConstants.SOME_KEY'; + const OTHER_KEY_ = 'ClassWithConstants.OTHER_KEY_'; } \ No newline at end of file From c3ab9b47ff900c58ddae4f59c6c3b689cb46154c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 3 Dec 2013 16:45:28 +0100 Subject: [PATCH 2/3] Hotfix for DCOM-179 - matching trailing underscore in constant/property names --- lib/Doctrine/Common/Annotations/DocLexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Common/Annotations/DocLexer.php b/lib/Doctrine/Common/Annotations/DocLexer.php index ddc84d699..bb88b08fe 100644 --- a/lib/Doctrine/Common/Annotations/DocLexer.php +++ b/lib/Doctrine/Common/Annotations/DocLexer.php @@ -76,7 +76,7 @@ final class DocLexer extends AbstractLexer protected function getCatchablePatterns() { return array( - '[a-z_\\\][a-z0-9_\:\\\]*[a-z]{1}', + '[a-z_\\\][a-z0-9_\:\\\]*[a-z_]{1}', '(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?', '"(?:[^"]|"")*"', ); From 43ddba43d6807923d72ffafa8286cd51afcbf7e2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 3 Dec 2013 16:51:13 +0100 Subject: [PATCH 3/3] Adding test for the doc-lexer to harden the DCOM-179 hotfix --- .../Tests/Common/Annotations/DocLexerTest.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php index 03a55c805..beb37a00e 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -28,7 +28,7 @@ public function testMarkerAnnotation() public function testScannerTokenizesDocBlockWhitConstants() { $lexer = new DocLexer(); - $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)'; + $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, ClassWithConstants::CONSTANT_, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)'; $tokens = array ( array( @@ -67,13 +67,23 @@ public function testScannerTokenizesDocBlockWhitConstants() 'type' => DocLexer::T_COMMA, ), array( - 'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE', + 'value' => 'ClassWithConstants::CONSTANT_', 'position' => 66, 'type' => DocLexer::T_IDENTIFIER, ), + array( + 'value' => ',', + 'position' => 95, + 'type' => DocLexer::T_COMMA, + ), + array( + 'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE', + 'position' => 97, + 'type' => DocLexer::T_IDENTIFIER, + ), array( 'value' => ')', - 'position' => 143, + 'position' => 174, 'type' => DocLexer::T_CLOSE_PARENTHESIS, )