Skip to content

Commit 5a9ab08

Browse files
committed
avoid file_get_contents error if file does not exist any more
Our tests generate some PHP files which are executed and later deleted. PHPCodeCoverage then fails with an error because it tries to open it with file_get_contents. (The file is created in a directory that is in filter/blacklist but that does not seem to help, I did not investigate further). The extra `file_exists` call may be too costly, I do not know if you will accept the change, but I will propose it just in case.
1 parent 630f56d commit 5a9ab08

File tree

1 file changed

+3
-0
lines changed
  • PHP/CodeCoverage/Report/HTML/Renderer

1 file changed

+3
-0
lines changed

PHP/CodeCoverage/Report/HTML/Renderer/File.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ protected function renderSource(PHP_CodeCoverage_Report_Node_File $node)
424424
*/
425425
protected function loadFile($file)
426426
{
427+
if (!file_exists($file)) {
428+
return array();
429+
}
427430
$buffer = file_get_contents($file);
428431
$lines = explode("\n", str_replace("\t", ' ', $buffer));
429432
$result = array();

0 commit comments

Comments
 (0)