From 095cf6d37a33da2b64d45802cb81be9476a07de6 Mon Sep 17 00:00:00 2001 From: Michael Knappe Date: Tue, 30 Apr 2019 13:21:57 +0200 Subject: [PATCH 1/2] fixed generic tag to parse description with `0` as expected --- src/DocBlock/Tags/Generic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocBlock/Tags/Generic.php b/src/DocBlock/Tags/Generic.php index 06ad38db..444bad43 100644 --- a/src/DocBlock/Tags/Generic.php +++ b/src/DocBlock/Tags/Generic.php @@ -53,7 +53,7 @@ public static function create( Assert::stringNotEmpty($name); Assert::notNull($descriptionFactory); - $description = $descriptionFactory && $body ? $descriptionFactory->create($body, $context) : null; + $description = $descriptionFactory && $body !== "" ? $descriptionFactory->create($body, $context) : null; return new static($name, $description); } From 6907decc71103f95f5b93b746c1f284dafc529d2 Mon Sep 17 00:00:00 2001 From: Michael Knappe Date: Tue, 30 Apr 2019 13:22:06 +0200 Subject: [PATCH 2/2] added test for generic tag to parse description with `0` as expected --- tests/integration/DocblocksWithAnnotationsTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/integration/DocblocksWithAnnotationsTest.php b/tests/integration/DocblocksWithAnnotationsTest.php index 06e50815..139248b6 100644 --- a/tests/integration/DocblocksWithAnnotationsTest.php +++ b/tests/integration/DocblocksWithAnnotationsTest.php @@ -44,4 +44,18 @@ public function testDocblockWithAnnotations(): void $this->assertCount(3, $docblock->getTags()); } + + public function testDocblockWithAnnotationHavingZeroValue(): void + { + $docComment = <<create($docComment); + + $this->assertSame(0, printf('%i', $docblock->getTagsByName('my-tag'))); + } }