Skip to content

Commit 1576ee8

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 3f016c5 commit 1576ee8

File tree

1 file changed

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

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ protected function renderSource(PHP_CodeCoverage_Report_Node_File $node)
409409
*/
410410
protected function loadFile($file)
411411
{
412+
if (!file_exists($file)) {
413+
return array();
414+
}
415+
412416
$buffer = file_get_contents($file);
413417
$lines = explode("\n", str_replace("\t", ' ', $buffer));
414418
$result = array();

0 commit comments

Comments
 (0)