diff --git a/src/DocBlock/Tags/Formatter/PassthroughFormatter.php b/src/DocBlock/Tags/Formatter/PassthroughFormatter.php index aa97572..4e2c576 100644 --- a/src/DocBlock/Tags/Formatter/PassthroughFormatter.php +++ b/src/DocBlock/Tags/Formatter/PassthroughFormatter.php @@ -26,6 +26,6 @@ class PassthroughFormatter implements Formatter */ public function format(Tag $tag) { - return '@' . $tag->getName() . ' ' . (string)$tag; + return trim('@' . $tag->getName() . ' ' . (string)$tag); } } diff --git a/tests/unit/DocBlock/DescriptionTest.php b/tests/unit/DocBlock/DescriptionTest.php index b5917a9..9d9a4e9 100644 --- a/tests/unit/DocBlock/DescriptionTest.php +++ b/tests/unit/DocBlock/DescriptionTest.php @@ -31,7 +31,7 @@ class DescriptionTest extends \PHPUnit_Framework_TestCase public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags() { $body = 'This is a %1$s body.'; - $expected = 'This is a {@internal significant } body.'; + $expected = 'This is a {@internal significant} body.'; $tags = [new Generic('internal', new Description('significant '))]; $fixture = new Description($body, $tags); @@ -41,7 +41,7 @@ class DescriptionTest extends \PHPUnit_Framework_TestCase // with a custom formatter $formatter = m::mock(PassthroughFormatter::class); - $formatter->shouldReceive('format')->with($tags[0])->andReturn('@internal significant '); + $formatter->shouldReceive('format')->with($tags[0])->andReturn('@internal significant'); $this->assertSame($expected, $fixture->render($formatter)); } @@ -56,7 +56,7 @@ class DescriptionTest extends \PHPUnit_Framework_TestCase public function testDescriptionCanBeCastToString() { $body = 'This is a %1$s body.'; - $expected = 'This is a {@internal significant } body.'; + $expected = 'This is a {@internal significant} body.'; $tags = [new Generic('internal', new Description('significant '))]; $fixture = new Description($body, $tags); diff --git a/tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php b/tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php index 045a197..461fb47 100644 --- a/tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php +++ b/tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php @@ -38,4 +38,21 @@ class PassthroughFormatterTest extends \PHPUnit_Framework_TestCase $fixture->format(new Generic('unknown-tag', new Description('This is a description'))) ); } + + /** + * @covers ::format + * @uses \phpDocumentor\Reflection\DocBlock\Description + * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic + */ + public function testFormatterToStringWitoutDescription() + { + $expected = '@unknown-tag'; + $fixture = new PassthroughFormatter(); + + $this->assertSame( + $expected, + $fixture->format(new Generic('unknown-tag')) + ); + } }