mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Merge pull request #357 from AydinHassan/fix-description-formatting-with-escaping
Fix rendering a description when it contains escaped chars and no tags
This commit is contained in:
@@ -94,7 +94,7 @@ class Description
|
|||||||
public function render(?Formatter $formatter = null): string
|
public function render(?Formatter $formatter = null): string
|
||||||
{
|
{
|
||||||
if ($this->tags === []) {
|
if ($this->tags === []) {
|
||||||
return $this->bodyTemplate;
|
return vsprintf($this->bodyTemplate, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($formatter === null) {
|
if ($formatter === null) {
|
||||||
|
|||||||
@@ -142,4 +142,31 @@ class DescriptionTest extends TestCase
|
|||||||
. 'inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})';
|
. 'inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})';
|
||||||
$this->assertSame($expected, (string) $fixture);
|
$this->assertSame($expected, (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::render
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testDescriptionWithEscapedCharactersAndNoTagsCanBeCastToString(): void
|
||||||
|
{
|
||||||
|
//% chars are escaped in \phpDocumentor\Reflection\DocBlock\DescriptionFactory::create
|
||||||
|
$body = <<<'EOT'
|
||||||
|
{%% for user in users %%}
|
||||||
|
{{ user.name }}
|
||||||
|
{%% endfor %%}';
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$expected = <<<'EOT'
|
||||||
|
{% for user in users %}
|
||||||
|
{{ user.name }}
|
||||||
|
{% endfor %}';
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$fixture = new Description($body, []);
|
||||||
|
|
||||||
|
$this->assertSame($expected, (string) $fixture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user