diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index a1093a1660..51721afa4b 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -149,15 +149,20 @@ protected function printHeader() protected function getFormattedHeader() { $standard = $this->ruleset->name; - $output = ''.PHP_EOL; - $output .= ' '.PHP_EOL; - $output .= " $standard Coding Standards".PHP_EOL; - $output .= ' '.str_replace("\n", PHP_EOL, self::STYLESHEET).PHP_EOL; - $output .= ' '.PHP_EOL; - $output .= ' '.PHP_EOL; - $output .= "

$standard Coding Standards

".PHP_EOL; - - return $output; + $output = sprintf( + ' + + %1$s Coding Standards + %2$s + + +

%1$s Coding Standards

', + $standard, + self::STYLESHEET + ); + + // Use the correct line endings based on the OS. + return str_replace("\n", PHP_EOL, $output).PHP_EOL; }//end getFormattedHeader() @@ -197,12 +202,14 @@ protected function getFormattedToc() $output = '

Table of Contents

'.PHP_EOL; $output .= ' '.PHP_EOL; @@ -240,16 +247,17 @@ protected function getFormattedFooter() // Turn off errors so we don't get timezone warnings if people // don't have their timezone set. $errorLevel = error_reporting(0); - $output = '
'; - $output .= 'Documentation generated on '.date('r'); - $output .= ' by PHP_CodeSniffer '.Config::VERSION.''; - $output .= '
'.PHP_EOL; + $output = sprintf( + '
Documentation generated on %s by PHP_CodeSniffer %s
+ +', + date('r'), + Config::VERSION + ); error_reporting($errorLevel); - $output .= ' '.PHP_EOL; - $output .= ''.PHP_EOL; - - return $output; + // Use the correct line endings based on the OS. + return str_replace("\n", PHP_EOL, $output).PHP_EOL; }//end getFormattedFooter() diff --git a/tests/Core/Generators/Fixtures/HTMLDouble.php b/tests/Core/Generators/Fixtures/HTMLDouble.php index e3d797c118..8b737fb7c4 100644 --- a/tests/Core/Generators/Fixtures/HTMLDouble.php +++ b/tests/Core/Generators/Fixtures/HTMLDouble.php @@ -20,14 +20,12 @@ class HTMLDouble extends HTML */ protected function getFormattedFooter() { - $output = '
'; - $output .= 'Documentation generated on #REDACTED#'; - $output .= ' by PHP_CodeSniffer #VERSION#'; - $output .= '
'.PHP_EOL; - $output .= ' '.PHP_EOL; - $output .= ''.PHP_EOL; + $output ='
Documentation generated on #REDACTED# by PHP_CodeSniffer #VERSION#
+ +'; - return $output; + // Use the correct line endings based on the OS. + return str_replace("\n", PHP_EOL, $output).PHP_EOL; } /**