mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Merge pull request #30 from cebe/preserve-newlines
Preserve newlines in docblock tags
This commit is contained in:
@@ -209,20 +209,16 @@ class DocBlock implements \Reflector
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach (explode("\n", $tags) as $tag_line) {
|
foreach (explode("\n", $tags) as $tag_line) {
|
||||||
if (trim($tag_line) === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||||
$result[] = $tag_line;
|
$result[] = $tag_line;
|
||||||
} else {
|
} else {
|
||||||
$result[count($result) - 1] .= PHP_EOL . $tag_line;
|
$result[count($result) - 1] .= "\n" . $tag_line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create proper Tag objects
|
// create proper Tag objects
|
||||||
foreach ($result as $key => $tag_line) {
|
foreach ($result as $key => $tag_line) {
|
||||||
$result[$key] = Tag::createInstance($tag_line, $this);
|
$result[$key] = Tag::createInstance(trim($tag_line), $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace phpDocumentor\Reflection;
|
|||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Context;
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
use phpDocumentor\Reflection\DocBlock\Location;
|
use phpDocumentor\Reflection\DocBlock\Location;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor\Reflection\DocBlock
|
* Test class for phpDocumentor\Reflection\DocBlock
|
||||||
@@ -272,7 +273,10 @@ DOCBLOCK;
|
|||||||
*/
|
*/
|
||||||
DOCBLOCK;
|
DOCBLOCK;
|
||||||
$object = new DocBlock($fixture);
|
$object = new DocBlock($fixture);
|
||||||
$this->assertCount(1, $object->getTags());
|
$this->assertCount(1, $tags = $object->getTags());
|
||||||
|
/** @var ReturnTag $tag */
|
||||||
|
$tag = reset($tags);
|
||||||
|
$this->assertEquals("Content on\n multiple lines.\n\n One more, after the break.", $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user