Skip to content

Commit

Permalink
Merge pull request #167 from michbeck/master
Browse files Browse the repository at this point in the history
Fix for generic tag description properly parsing 0
  • Loading branch information
jaapio committed Apr 30, 2019
2 parents 90ae750 + 6907dec commit 4835166
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DocBlock/Tags/Generic.php
Expand Up @@ -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);
}
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/DocblocksWithAnnotationsTest.php
Expand Up @@ -44,4 +44,18 @@ public function testDocblockWithAnnotations(): void

$this->assertCount(3, $docblock->getTags());
}

public function testDocblockWithAnnotationHavingZeroValue(): void
{
$docComment = <<<DOCCOMMENT
/**
* @my-tag 0
*/
DOCCOMMENT;

$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);

$this->assertSame(0, printf('%i', $docblock->getTagsByName('my-tag')));
}
}

0 comments on commit 4835166

Please sign in to comment.