@@ -149,15 +149,20 @@ protected function printHeader()
149
149
protected function getFormattedHeader ()
150
150
{
151
151
$ standard = $ this ->ruleset ->name ;
152
- $ output = '<html> ' .PHP_EOL ;
153
- $ output .= ' <head> ' .PHP_EOL ;
154
- $ output .= " <title> $ standard Coding Standards</title> " .PHP_EOL ;
155
- $ output .= ' ' .str_replace ("\n" , PHP_EOL , self ::STYLESHEET ).PHP_EOL ;
156
- $ output .= ' </head> ' .PHP_EOL ;
157
- $ output .= ' <body> ' .PHP_EOL ;
158
- $ output .= " <h1> $ standard Coding Standards</h1> " .PHP_EOL ;
159
-
160
- return $ output ;
152
+ $ output = sprintf (
153
+ '<html>
154
+ <head>
155
+ <title>%1$s Coding Standards</title>
156
+ %2$s
157
+ </head>
158
+ <body>
159
+ <h1>%1$s Coding Standards</h1> ' ,
160
+ $ standard ,
161
+ self ::STYLESHEET
162
+ );
163
+
164
+ // Use the correct line endings based on the OS.
165
+ return str_replace ("\n" , PHP_EOL , $ output ).PHP_EOL ;
161
166
162
167
}//end getFormattedHeader()
163
168
@@ -197,12 +202,14 @@ protected function getFormattedToc()
197
202
$ output = ' <h2>Table of Contents</h2> ' .PHP_EOL ;
198
203
$ output .= ' <ul class="toc"> ' .PHP_EOL ;
199
204
205
+ $ listItemTemplate = ' <li><a href="#%s">%s</a></li> ' .PHP_EOL ;
206
+
200
207
foreach ($ this ->docFiles as $ file ) {
201
208
$ doc = new DOMDocument ();
202
209
$ doc ->load ($ file );
203
210
$ documentation = $ doc ->getElementsByTagName ('documentation ' )->item (0 );
204
211
$ title = $ this ->getTitle ($ documentation );
205
- $ output .= ' <li><a href="# ' . str_replace (' ' , '- ' , $ title ). ' "> ' . $ title. ' </a></li> ' . PHP_EOL ;
212
+ $ output .= sprintf ( $ listItemTemplate , str_replace (' ' , '- ' , $ title ), $ title) ;
206
213
}
207
214
208
215
$ output .= ' </ul> ' .PHP_EOL ;
@@ -240,16 +247,17 @@ protected function getFormattedFooter()
240
247
// Turn off errors so we don't get timezone warnings if people
241
248
// don't have their timezone set.
242
249
$ errorLevel = error_reporting (0 );
243
- $ output = ' <div class="tag-line"> ' ;
244
- $ output .= 'Documentation generated on ' .date ('r ' );
245
- $ output .= ' by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer ' .Config::VERSION .'</a> ' ;
246
- $ output .= '</div> ' .PHP_EOL ;
250
+ $ output = sprintf (
251
+ ' <div class="tag-line">Documentation generated on %s by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer %s</a></div>
252
+ </body>
253
+ </html> ' ,
254
+ date ('r ' ),
255
+ Config::VERSION
256
+ );
247
257
error_reporting ($ errorLevel );
248
258
249
- $ output .= ' </body> ' .PHP_EOL ;
250
- $ output .= '</html> ' .PHP_EOL ;
251
-
252
- return $ output ;
259
+ // Use the correct line endings based on the OS.
260
+ return str_replace ("\n" , PHP_EOL , $ output ).PHP_EOL ;
253
261
254
262
}//end getFormattedFooter()
255
263
0 commit comments