sebastianbergmann/php-code-coverage — pull request #89 by fabriceb (2012-02-12 21:49:26+00:00)
Title: By-Pass Xdebug bug #331 by cleaning the filenames returned in the Xdebug.php driver

Xdebug has an old bug which makes it return corrupted filenames in the code-coverage data in certain cases. Two identified cases:
* using "assert"
* using "runkit_function_redefine"

The returned filename will then be:
"[..]/wrongreturn.php(19) : assert code"
instead of
"[..]/wrongreturn.php"

The bug is documented here: http://bugs.xdebug.org/bug_view_page.php?bug_id=0000331

The suggested solution to by-pass this Xdebug bug until it is solved in Xdebug is to clean the filenames containing the pattern /\(\d+\) :.+/ which should normally be generic enough to solve all the possible cases.

The function to clean the filenames was put in the driver class to decouple Xdebug problems from the rest of the code coverage code.

Let me know if you have any suggestion on how to improve this.