7373use const T_YIELD ;
7474use function array_key_exists ;
7575use function array_pop ;
76+ use function array_unique ;
7677use function count ;
7778use function explode ;
7879use function file_get_contents ;
@@ -560,24 +561,24 @@ private function renderSourceWithPathCoverage(FileNode $node): string
560561 /** @var int $line */
561562 foreach (array_keys ($ codeLines ) as $ line ) {
562563 $ lineData [$ line + 1 ] = [
563- 'includedInPaths ' => 0 ,
564- 'includedInHitPaths ' => 0 ,
564+ 'includedInPaths ' => [] ,
565+ 'includedInHitPaths ' => [] ,
565566 'tests ' => [],
566567 ];
567568 }
568569
569570 foreach ($ functionCoverageData as $ method ) {
570- foreach ($ method ['paths ' ] as $ path ) {
571+ foreach ($ method ['paths ' ] as $ pathId => $ path ) {
571572 foreach ($ path ['path ' ] as $ branchTaken ) {
572573 foreach (range ($ method ['branches ' ][$ branchTaken ]['line_start ' ], $ method ['branches ' ][$ branchTaken ]['line_end ' ]) as $ line ) {
573574 if (!isset ($ lineData [$ line ])) {
574575 continue ;
575576 }
576- $ lineData [$ line ]['includedInPaths ' ]++ ;
577+ $ lineData [$ line ]['includedInPaths ' ][] = $ pathId ;
577578
578579 if ($ path ['hit ' ]) {
579- $ lineData [$ line ]['includedInHitPaths ' ]++ ;
580- $ lineData [$ line ]['tests ' ] = array_unique (array_merge ($ lineData [$ line ]['tests ' ], $ path ['hit ' ]));
580+ $ lineData [$ line ]['includedInHitPaths ' ][] = $ pathId ;
581+ $ lineData [$ line ]['tests ' ] = array_unique (array_merge ($ lineData [$ line ]['tests ' ], $ path ['hit ' ]));
581582 }
582583 }
583584 }
@@ -589,15 +590,17 @@ private function renderSourceWithPathCoverage(FileNode $node): string
589590
590591 /** @var string $line */
591592 foreach ($ codeLines as $ line ) {
592- $ trClass = '' ;
593- $ popover = '' ;
593+ $ trClass = '' ;
594+ $ popover = '' ;
595+ $ includedInPathsCount = count (array_unique ($ lineData [$ i ]['includedInPaths ' ]));
596+ $ includedInHitPathsCount = count (array_unique ($ lineData [$ i ]['includedInHitPaths ' ]));
594597
595- if ($ lineData [ $ i ][ ' includedInPaths ' ] > 0 ) {
598+ if ($ includedInPathsCount > 0 ) {
596599 $ lineCss = 'success ' ;
597600
598- if ($ lineData [ $ i ][ ' includedInHitPaths ' ] === 0 ) {
601+ if ($ includedInHitPathsCount === 0 ) {
599602 $ lineCss = 'danger ' ;
600- } elseif ($ lineData [ $ i ][ ' includedInHitPaths ' ] !== $ lineData [ $ i ][ ' includedInPaths ' ] ) {
603+ } elseif ($ includedInHitPathsCount !== $ includedInPathsCount ) {
601604 $ lineCss = 'warning ' ;
602605 }
603606
@@ -608,7 +611,7 @@ private function renderSourceWithPathCoverage(FileNode $node): string
608611 } else {
609612 $ popoverTitle = count ($ lineData [$ i ]['tests ' ]) . ' tests cover line ' . $ i ;
610613 }
611- $ popoverTitle .= '. These are covering ' . $ lineData [ $ i ][ ' includedInHitPaths ' ] . ' out of the ' . $ lineData [ $ i ][ ' includedInPaths ' ] . ' code paths. ' ;
614+ $ popoverTitle .= '. These are covering ' . $ includedInHitPathsCount . ' out of the ' . $ includedInPathsCount . ' code paths. ' ;
612615
613616 foreach ($ lineData [$ i ]['tests ' ] as $ test ) {
614617 $ popoverContent .= $ this ->createPopoverContentForTest ($ test , $ testData [$ test ]);
0 commit comments