@@ -226,7 +226,8 @@ public function append(array $data, $id = NULL, array $filterGroups = array('DEF
226226 }
227227
228228 foreach (array_keys ($ data ) as $ filename ) {
229- if ((!defined ('PHP_CODECOVERAGE_TESTSUITE ' ) &&
229+ if (!$ this ->filter ->isFile ($ filename ) ||
230+ (!defined ('PHP_CODECOVERAGE_TESTSUITE ' ) &&
230231 strpos ($ filename , dirname (__FILE__ )) === 0 ) ||
231232 substr ($ filename , -17 ) == 'Text/Template.php ' ||
232233 substr ($ filename , -17 ) == 'File/Iterator.php ' ||
@@ -242,21 +243,7 @@ public function append(array $data, $id = NULL, array $filterGroups = array('DEF
242243 }
243244 }
244245
245- $ newFiles = array_diff_key ($ data , $ this ->coveredFiles );
246-
247- if (count ($ newFiles ) > 0 ) {
248- $ dead = $ this ->getLinesByStatus ($ newFiles , -2 );
249- $ executable = $ this ->getLinesByStatus ($ newFiles , array (-1 , 1 ));
250-
251- foreach (array_keys ($ newFiles ) as $ filename ) {
252- $ this ->coveredFiles [$ filename ] = TRUE ;
253- }
254- } else {
255- $ dead = array ();
256- $ executable = array ();
257- }
258-
259- unset($ newFiles );
246+ $ raw = $ data ;
260247
261248 // Apply @covers filtering.
262249 if ($ id instanceof PHPUnit_Framework_TestCase) {
@@ -288,13 +275,12 @@ public function append(array $data, $id = NULL, array $filterGroups = array('DEF
288275 $ this ->tests [$ id ] = $ status ;
289276 }
290277
291- $ this ->data [$ id ] = array (
292- 'executed ' => $ this ->getLinesByStatus ($ data , 1 ),
293- 'dead ' => $ dead ,
294- 'executable ' => $ executable
278+ $ this ->coveredFiles = array_unique (
279+ array_merge ($ this ->coveredFiles , array_keys ($ data ))
295280 );
296281
297- $ this ->summary = array ();
282+ $ this ->data [$ id ] = array ('filtered ' => $ data , 'raw ' => $ raw );
283+ $ this ->summary = array ();
298284 }
299285 }
300286
@@ -321,8 +307,8 @@ public function merge(PHP_CodeCoverage $that)
321307 }
322308 }
323309
324- $ this ->coveredFiles = array_merge (
325- $ this ->coveredFiles , $ that ->coveredFiles
310+ $ this ->coveredFiles = array_unique (
311+ array_merge ( $ this ->coveredFiles , $ that ->coveredFiles )
326312 );
327313
328314 $ this ->summary = array ();
@@ -351,37 +337,31 @@ public function getSummary()
351337 }
352338
353339 foreach ($ this ->data as $ test => $ coverage ) {
354- foreach ($ coverage ['executed ' ] as $ file => $ lines ) {
340+ foreach ($ coverage ['filtered ' ] as $ file => $ lines ) {
355341 foreach ($ lines as $ line => $ flag ) {
356- if (!isset ($ this ->summary [$ file ][$ line ][0 ])) {
357- $ this ->summary [$ file ][$ line ] = array ();
358- }
359-
360- if (isset ($ this ->tests [$ test ])) {
361- $ status = $ this ->tests [$ test ];
362- } else {
363- $ status = NULL ;
342+ if ($ flag == 1 ) {
343+ if (!isset ($ this ->summary [$ file ][$ line ][0 ])) {
344+ $ this ->summary [$ file ][$ line ] = array ();
345+ }
346+
347+ if (isset ($ this ->tests [$ test ])) {
348+ $ status = $ this ->tests [$ test ];
349+ } else {
350+ $ status = NULL ;
351+ }
352+
353+ $ this ->summary [$ file ][$ line ][] = array (
354+ 'id ' => $ test , 'status ' => $ status
355+ );
364356 }
365-
366- $ this ->summary [$ file ][$ line ][] = array (
367- 'id ' => $ test , 'status ' => $ status
368- );
369357 }
370358 }
371359
372- foreach ($ coverage ['executable ' ] as $ file => $ lines ) {
360+ foreach ($ coverage ['raw ' ] as $ file => $ lines ) {
373361 foreach ($ lines as $ line => $ flag ) {
374- if ($ flag == - 1 &&
362+ if ($ flag != 1 &&
375363 !isset ($ this ->summary [$ file ][$ line ][0 ])) {
376- $ this ->summary [$ file ][$ line ] = -1 ;
377- }
378- }
379- }
380-
381- foreach ($ coverage ['dead ' ] as $ file => $ lines ) {
382- foreach ($ lines as $ line => $ flag ) {
383- if (!isset ($ this ->summary [$ file ][$ line ][0 ])) {
384- $ this ->summary [$ file ][$ line ] = -2 ;
364+ $ this ->summary [$ file ][$ line ] = $ flag ;
385365 }
386366 }
387367 }
@@ -457,44 +437,6 @@ public function setPromoteGlobals($flag)
457437 $ this ->promoteGlobals = $ flag ;
458438 }
459439
460- /**
461- * Filters lines by status.
462- *
463- * @param array $data
464- * @param array|integer $status
465- * @return array
466- */
467- protected function getLinesByStatus (array $ data , $ status )
468- {
469- if (!is_array ($ status )) {
470- $ status = array ($ status );
471- }
472-
473- $ isFileCache = array ();
474- $ result = array ();
475- $ status = array_flip ($ status );
476-
477- foreach ($ data as $ file => $ coverage ) {
478- if (!isset ($ isFileCache [$ file ])) {
479- $ isFileCache [$ file ] = $ this ->filter ->isFile ($ file );
480- }
481-
482- if (!$ isFileCache [$ file ]) {
483- continue ;
484- }
485-
486- $ result [$ file ] = array ();
487-
488- foreach ($ coverage as $ line => $ _status ) {
489- if (isset ($ status [$ _status ])) {
490- $ result [$ file ][$ line ] = $ _status ;
491- }
492- }
493- }
494-
495- return $ result ;
496- }
497-
498440 /**
499441 * Processes whitelisted files that are not covered.
500442 */
0 commit comments