File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,41 @@ public function stop()
92
92
{
93
93
$ codeCoverage = xdebug_get_code_coverage ();
94
94
xdebug_stop_code_coverage ();
95
+ $ codeCoverage = self ::cleanFilenames ($ codeCoverage );
95
96
96
97
return $ codeCoverage ;
97
98
}
99
+
100
+ /**
101
+ * By-pass http://bugs.xdebug.org/bug_view_page.php?bug_id=0000331
102
+ *
103
+ * This Xdebug bug causes some filenames to be corrupted in the form
104
+ * "[..]/wrongreturn.php(19) : assert code"
105
+ * instead of
106
+ * "[..]/wrongreturn.php"
107
+ * The goal of this function is to by-pass the bug until it is fixed in Xdebug
108
+ * by cleaning corrupted filenames
109
+ *
110
+ * @return array
111
+ */
112
+ protected static function cleanFilenames ($ data )
113
+ {
114
+ foreach ($ data as $ file => $ lines ) {
115
+ // check the existence of the wrong pattern in filename
116
+ $ correct_file = preg_replace ('/\(\d+\) :.+/ ' , '' , $ file );
117
+ if ($ file != $ correct_file ) {
118
+ // if wrong filename found, we merge code coverage data
119
+ // with correct filename
120
+ if (!array_key_exists ($ correct_file , $ data )) {
121
+ $ data [$ correct_file ] = array ();
122
+ }
123
+ $ data [$ correct_file ] += $ lines ;
124
+ ksort ($ data [$ correct_file ]);
125
+ // and unset wrong filename data
126
+ unset($ data [$ file ]);
127
+ }
128
+ }
129
+
130
+ return $ data ;
131
+ }
98
132
}
You can’t perform that action at this time.
0 commit comments