@@ -42,6 +42,10 @@ class Serializer
4242
4343 /** @var Formatter A custom tag formatter. */
4444 protected $ tagFormatter ;
45+ /**
46+ * @var string
47+ */
48+ private $ lineEnding ;
4549
4650 /**
4751 * Create a Serializer instance.
@@ -51,19 +55,22 @@ class Serializer
5155 * @param bool $indentFirstLine Whether to indent the first line.
5256 * @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
5357 * @param Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
58+ * @param string $lineEnding Line ending used in the output, by default \n is used.
5459 */
5560 public function __construct (
5661 int $ indent = 0 ,
5762 string $ indentString = ' ' ,
5863 bool $ indentFirstLine = true ,
5964 ?int $ lineLength = null ,
60- ?Formatter $ tagFormatter = null
65+ ?Formatter $ tagFormatter = null ,
66+ string $ lineEnding = "\n"
6167 ) {
6268 $ this ->indent = $ indent ;
6369 $ this ->indentString = $ indentString ;
6470 $ this ->isFirstLineIndented = $ indentFirstLine ;
6571 $ this ->lineLength = $ lineLength ;
6672 $ this ->tagFormatter = $ tagFormatter ?: new PassthroughFormatter ();
73+ $ this ->lineEnding = $ lineEnding ;
6774 }
6875
6976 /**
@@ -96,7 +103,7 @@ public function getDocComment(DocBlock $docblock): string
96103
97104 $ comment = $ this ->addTagBlock ($ docblock , $ wrapLength , $ indent , $ comment );
98105
99- return $ comment . $ indent . ' */ ' ;
106+ return str_replace ( "\n" , $ this -> lineEnding , $ comment . $ indent . ' */ ' ) ;
100107 }
101108
102109 private function removeTrailingSpaces (string $ indent , string $ text ): string
0 commit comments