From 51d78a90778360a2ad959f749014dcb429205e71 Mon Sep 17 00:00:00 2001 From: Paul Oldridge Date: Wed, 13 Jan 2016 19:41:12 -0800 Subject: [PATCH 1/5] Allow tab character before first annotation in DocBlock --- lib/Doctrine/Common/Annotations/DocParser.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Common/Annotations/DocParser.php b/lib/Doctrine/Common/Annotations/DocParser.php index cf4cd9c83..b128b93a9 100644 --- a/lib/Doctrine/Common/Annotations/DocParser.php +++ b/lib/Doctrine/Common/Annotations/DocParser.php @@ -368,8 +368,9 @@ private function findInitialTokenPosition($input) // search for first valid annotation while (($pos = strpos($input, '@', $pos)) !== false) { $preceding = substr($input, $pos - 1, 1); - // if the @ is preceded by a space or * it is valid - if ($pos === 0 || $preceding === ' ' || $preceding === '*') { + + // if the @ is preceded by a space, a tab or * it is valid + if ($pos === 0 || $preceding === ' ' || $preceding === '*' || $preceding === "\t") { return $pos; } From 7e7826c6a1665cbdb66cf537e374bf90cf27a994 Mon Sep 17 00:00:00 2001 From: Paul Oldridge Date: Wed, 13 Jan 2016 20:25:46 -0800 Subject: [PATCH 2/5] Added test for tab prefix --- .../Tests/Common/Annotations/DocParserTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 661682276..610cfa9e5 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1282,6 +1282,21 @@ public function testTrailingCommaIsAllowed() $this->assertEquals(array('Foo', 'Bar'), $annots[0]->value); } + public function testTabPrefixIsAllowed() + { + $docblock = <<createTestParser(); + $result = $parser->parse($docblock); + $this->assertEquals(1, count($result)); + $annot = $result[0]; + $this->assertTrue($annot instanceof Name); + } + public function testDefaultAnnotationValueIsNotOverwritten() { $parser = $this->createTestParser(); From 8707629cef7aaca63059f9d24cb12e954208e32a Mon Sep 17 00:00:00 2001 From: Paul Oldridge Date: Sun, 24 Jan 2016 16:17:05 -0800 Subject: [PATCH 3/5] Updated assertion style --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 610cfa9e5..ae26a7dc3 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1292,9 +1292,9 @@ public function testTabPrefixIsAllowed() $parser = $this->createTestParser(); $result = $parser->parse($docblock); - $this->assertEquals(1, count($result)); + $this->assertCount(1, $result); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf('Name', $annot); } public function testDefaultAnnotationValueIsNotOverwritten() From 390bd1ffeb602bad1d0c081a96886ab9cdddf8ee Mon Sep 17 00:00:00 2001 From: Paul Oldridge Date: Sun, 24 Jan 2016 16:19:14 -0800 Subject: [PATCH 4/5] Updated assertion style --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index ae26a7dc3..398495003 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1294,7 +1294,7 @@ public function testTabPrefixIsAllowed() $result = $parser->parse($docblock); $this->assertCount(1, $result); $annot = $result[0]; - $this->assertInstanceOf('Name', $annot); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annot); } public function testDefaultAnnotationValueIsNotOverwritten() From ae368268a1426c9a4b4c98ef3a1235a2b7b3a36a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 24 Oct 2016 13:21:43 +0200 Subject: [PATCH 5/5] #70 removed unused assignment --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 398495003..f171e4773 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1293,8 +1293,7 @@ public function testTabPrefixIsAllowed() $parser = $this->createTestParser(); $result = $parser->parse($docblock); $this->assertCount(1, $result); - $annot = $result[0]; - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annot); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $result[0]); } public function testDefaultAnnotationValueIsNotOverwritten()