@@ -114,27 +114,40 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
114
114
115
115
// The maximum amount of space an error message can use.
116
116
$ maxErrorSpace = ($ width - $ paddingLength - 1 );
117
- if ($ showSources === true ) {
118
- // Account for the chars used to print colors.
119
- $ maxErrorSpace += 8 ;
120
- }
121
117
122
118
foreach ($ report ['messages ' ] as $ line => $ lineErrors ) {
123
119
foreach ($ lineErrors as $ column => $ colErrors ) {
124
120
foreach ($ colErrors as $ error ) {
125
- $ message = $ error ['message ' ];
126
- $ message = str_replace ("\n" , "\n" .$ paddingLine2 , $ message );
127
- if ($ showSources === true ) {
128
- $ message = "\033[1m " .$ message ."\033[0m " .' ( ' .$ error ['source ' ].') ' ;
121
+ $ message = $ error ['message ' ];
122
+ $ msgLines = [$ message ];
123
+ if (strpos ($ message , "\n" ) !== false ) {
124
+ $ msgLines = explode ("\n" , $ message );
125
+ }
126
+
127
+ $ errorMsg = '' ;
128
+ $ lastLine = (count ($ msgLines ) - 1 );
129
+ foreach ($ msgLines as $ k => $ msgLine ) {
130
+ if ($ k === 0 ) {
131
+ if ($ showSources === true ) {
132
+ $ errorMsg .= "\033[1m " ;
133
+ }
134
+ } else {
135
+ $ errorMsg .= PHP_EOL .$ paddingLine2 ;
136
+ }
137
+
138
+ if ($ k === $ lastLine && $ showSources === true ) {
139
+ $ msgLine .= "\033[0m " .' ( ' .$ error ['source ' ].') ' ;
140
+ }
141
+
142
+ $ errorMsg .= wordwrap (
143
+ $ msgLine ,
144
+ $ maxErrorSpace ,
145
+ PHP_EOL .$ paddingLine2
146
+ );
129
147
}
130
148
131
149
// The padding that goes on the front of the line.
132
- $ padding = ($ maxLineNumLength - strlen ($ line ));
133
- $ errorMsg = wordwrap (
134
- $ message ,
135
- $ maxErrorSpace ,
136
- PHP_EOL .$ paddingLine2
137
- );
150
+ $ padding = ($ maxLineNumLength - strlen ($ line ));
138
151
139
152
echo ' ' .str_repeat (' ' , $ padding ).$ line .' | ' ;
140
153
if ($ error ['type ' ] === 'ERROR ' ) {
0 commit comments