@@ -42,6 +42,10 @@ class Serializer
42
42
43
43
/** @var Formatter A custom tag formatter. */
44
44
protected $ tagFormatter ;
45
+ /**
46
+ * @var string
47
+ */
48
+ private $ lineEnding ;
45
49
46
50
/**
47
51
* Create a Serializer instance.
@@ -51,19 +55,22 @@ class Serializer
51
55
* @param bool $indentFirstLine Whether to indent the first line.
52
56
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
53
57
* @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.
54
59
*/
55
60
public function __construct (
56
61
int $ indent = 0 ,
57
62
string $ indentString = ' ' ,
58
63
bool $ indentFirstLine = true ,
59
64
?int $ lineLength = null ,
60
- ?Formatter $ tagFormatter = null
65
+ ?Formatter $ tagFormatter = null ,
66
+ string $ lineEnding = "\n"
61
67
) {
62
68
$ this ->indent = $ indent ;
63
69
$ this ->indentString = $ indentString ;
64
70
$ this ->isFirstLineIndented = $ indentFirstLine ;
65
71
$ this ->lineLength = $ lineLength ;
66
72
$ this ->tagFormatter = $ tagFormatter ?: new PassthroughFormatter ();
73
+ $ this ->lineEnding = $ lineEnding ;
67
74
}
68
75
69
76
/**
@@ -96,7 +103,7 @@ public function getDocComment(DocBlock $docblock): string
96
103
97
104
$ comment = $ this ->addTagBlock ($ docblock , $ wrapLength , $ indent , $ comment );
98
105
99
- return $ comment . $ indent . ' */ ' ;
106
+ return str_replace ( "\n" , $ this -> lineEnding , $ comment . $ indent . ' */ ' ) ;
100
107
}
101
108
102
109
private function removeTrailingSpaces (string $ indent , string $ text ): string
0 commit comments