From 2f482c78b0f77cfee33ded0862c9148b8429b7f1 Mon Sep 17 00:00:00 2001 From: Chuck Burgess Date: Sun, 7 Jan 2018 08:50:54 -0600 Subject: [PATCH 1/3] add tests for bug #63; --- .../integration/InterpretingDocBlocksTest.php | 25 +++++++++++++++++++ tests/unit/DocBlockTest.php | 15 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/tests/integration/InterpretingDocBlocksTest.php b/tests/integration/InterpretingDocBlocksTest.php index b2ec5ea..6492eea 100644 --- a/tests/integration/InterpretingDocBlocksTest.php +++ b/tests/integration/InterpretingDocBlocksTest.php @@ -33,6 +33,31 @@ class InterpretingDocBlocksTest extends TestCase m::close(); } + public function testInterpretingSummaryWithEllipsis(): void + { + $docblock = <<create($docblock); + + $summary = 'This is a short (...) description.'; + $description = 'This is a long description.'; + + $this->assertInstanceOf(DocBlock::class, $phpdoc); + $this->assertSame($summary, $phpdoc->getSummary()); + $this->assertSame($description, $phpdoc->getDescription()->render()); + $this->assertCount(1, $phpdoc->getTags()); + $this->assertTrue($phpdoc->hasTag('return')); + } + public function testInterpretingASimpleDocBlock(): void { /** diff --git a/tests/unit/DocBlockTest.php b/tests/unit/DocBlockTest.php index 7374e6f..d03fb0d 100644 --- a/tests/unit/DocBlockTest.php +++ b/tests/unit/DocBlockTest.php @@ -48,6 +48,21 @@ class DocBlockTest extends TestCase $this->assertSame($summary, $fixture->getSummary()); } + /** + * @covers ::__construct + * @covers ::getSummary + * + * @uses \phpDocumentor\Reflection\DocBlock\Description + */ + public function testDocBlockCanHaveEllipsisInSummary(): void + { + $summary = 'This is a short (...) description.'; + + $fixture = new DocBlock($summary); + + $this->assertSame($summary, $fixture->getSummary()); + } + /** * @covers ::__construct * @covers ::getDescription From fb948e8a524d9a096c8e480255a39b371f448ab1 Mon Sep 17 00:00:00 2001 From: Chuck Burgess Date: Sun, 7 Jan 2018 08:51:10 -0600 Subject: [PATCH 2/3] regex fix for ellipsis in summary text; --- src/DocBlockFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocBlockFactory.php b/src/DocBlockFactory.php index ca16bf6..67c147f 100644 --- a/src/DocBlockFactory.php +++ b/src/DocBlockFactory.php @@ -166,7 +166,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface [^\n.]+ (?: (?! \. \n | \n{2} ) # End summary upon a dot followed by newline or two newlines - [\n.] (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line + [\n.]* (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line [^\n.]+ # Include anything else )* \.? From 7bd0e7e4a1dcc565b703a4bfa07f4ad81cd89640 Mon Sep 17 00:00:00 2001 From: Chuck Burgess Date: Sun, 7 Jan 2018 09:09:21 -0600 Subject: [PATCH 3/3] extra space --- tests/integration/InterpretingDocBlocksTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/InterpretingDocBlocksTest.php b/tests/integration/InterpretingDocBlocksTest.php index 6492eea..099e40a 100644 --- a/tests/integration/InterpretingDocBlocksTest.php +++ b/tests/integration/InterpretingDocBlocksTest.php @@ -45,7 +45,7 @@ class InterpretingDocBlocksTest extends TestCase */ DOCBLOCK; - $factory = DocBlockFactory::createInstance(); + $factory = DocBlockFactory::createInstance(); $phpdoc = $factory->create($docblock); $summary = 'This is a short (...) description.';