Skip to content

Commit 382d7cd

Browse files
committed
Removes space after tag without description
fixes #86
1 parent 7c33776 commit 382d7cd

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/DocBlock/Tags/Formatter/PassthroughFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ class PassthroughFormatter implements Formatter
2626
*/
2727
public function format(Tag $tag)
2828
{
29-
return '@' . $tag->getName() . ' ' . (string)$tag;
29+
return trim('@' . $tag->getName() . ' ' . (string)$tag);
3030
}
3131
}

tests/unit/DocBlock/DescriptionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DescriptionTest extends \PHPUnit_Framework_TestCase
3131
public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags()
3232
{
3333
$body = 'This is a %1$s body.';
34-
$expected = 'This is a {@internal significant } body.';
34+
$expected = 'This is a {@internal significant} body.';
3535
$tags = [new Generic('internal', new Description('significant '))];
3636

3737
$fixture = new Description($body, $tags);
@@ -41,7 +41,7 @@ public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags()
4141

4242
// with a custom formatter
4343
$formatter = m::mock(PassthroughFormatter::class);
44-
$formatter->shouldReceive('format')->with($tags[0])->andReturn('@internal significant ');
44+
$formatter->shouldReceive('format')->with($tags[0])->andReturn('@internal significant');
4545
$this->assertSame($expected, $fixture->render($formatter));
4646
}
4747

@@ -56,7 +56,7 @@ public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags()
5656
public function testDescriptionCanBeCastToString()
5757
{
5858
$body = 'This is a %1$s body.';
59-
$expected = 'This is a {@internal significant } body.';
59+
$expected = 'This is a {@internal significant} body.';
6060
$tags = [new Generic('internal', new Description('significant '))];
6161

6262
$fixture = new Description($body, $tags);

tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,21 @@ public function testFormatterCallsToStringAndReturnsAStandardRepresentation()
3838
$fixture->format(new Generic('unknown-tag', new Description('This is a description')))
3939
);
4040
}
41+
42+
/**
43+
* @covers ::format
44+
* @uses \phpDocumentor\Reflection\DocBlock\Description
45+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
46+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
47+
*/
48+
public function testFormatterToStringWitoutDescription()
49+
{
50+
$expected = '@unknown-tag';
51+
$fixture = new PassthroughFormatter();
52+
53+
$this->assertSame(
54+
$expected,
55+
$fixture->format(new Generic('unknown-tag'))
56+
);
57+
}
4158
}

0 commit comments

Comments
 (0)