File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
src/CodeCoverage/Report/HTML/Renderer Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -423,10 +423,14 @@ protected function renderSource(PHP_CodeCoverage_Report_Node_File $node)
423423 */
424424 protected function loadFile ($ file )
425425 {
426- $ tokens = token_get_all (file_get_contents ($ file ));
427- $ result = array ('' );
428- $ i = 0 ;
429- $ stringFlag = false ;
426+ $ buffer = file_get_contents ($ file );
427+ $ tokens = token_get_all ($ buffer );
428+ $ result = array ('' );
429+ $ i = 0 ;
430+ $ stringFlag = false ;
431+ $ fileEndsWithNewLine = substr ($ buffer , -1 ) == "\n" ;
432+
433+ unset($ buffer );
430434
431435 foreach ($ tokens as $ j => $ token ) {
432436 if (is_string ($ token )) {
@@ -562,7 +566,9 @@ protected function loadFile($file)
562566 }
563567 }
564568
565- unset($ result [count ($ result )-1 ]);
569+ if ($ fileEndsWithNewLine ) {
570+ unset($ result [count ($ result )-1 ]);
571+ }
566572
567573 return $ result ;
568574 }
You can’t perform that action at this time.
0 commit comments