mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Allow serializer to have a configurable line-ending
This commit is contained in:
@@ -42,6 +42,10 @@ class Serializer
|
||||
|
||||
/** @var Formatter A custom tag formatter. */
|
||||
protected $tagFormatter;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $lineEnding;
|
||||
|
||||
/**
|
||||
* Create a Serializer instance.
|
||||
@@ -51,19 +55,22 @@ class Serializer
|
||||
* @param bool $indentFirstLine Whether to indent the first line.
|
||||
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
|
||||
* @param Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
|
||||
* @param string $lineEnding Line ending used in the output, by default \n is used.
|
||||
*/
|
||||
public function __construct(
|
||||
int $indent = 0,
|
||||
string $indentString = ' ',
|
||||
bool $indentFirstLine = true,
|
||||
?int $lineLength = null,
|
||||
?Formatter $tagFormatter = null
|
||||
?Formatter $tagFormatter = null,
|
||||
string $lineEnding = "\n"
|
||||
) {
|
||||
$this->indent = $indent;
|
||||
$this->indentString = $indentString;
|
||||
$this->isFirstLineIndented = $indentFirstLine;
|
||||
$this->lineLength = $lineLength;
|
||||
$this->tagFormatter = $tagFormatter ?: new PassthroughFormatter();
|
||||
$this->lineEnding = $lineEnding;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +103,7 @@ class Serializer
|
||||
|
||||
$comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment);
|
||||
|
||||
return $comment . $indent . ' */';
|
||||
return str_replace("\n", $this->lineEnding, $comment . $indent . ' */');
|
||||
}
|
||||
|
||||
private function removeTrailingSpaces(string $indent, string $text): string
|
||||
|
||||
Reference in New Issue
Block a user