@@ -611,49 +611,51 @@ private function applyIgnoredLinesFilter(array &$data)
611
611
private function initializeFilesThatAreSeenTheFirstTime (array $ data )
612
612
{
613
613
foreach ($ data as $ file => $ fileData ) {
614
- if ($ this ->filter ->isFile ($ file ) && !isset ($ this ->data [$ file ])) {
615
- $ this ->data [$ file ] = ['lines ' => []];
616
-
617
- if ($ this ->pathCoverage ) {
618
- $ this ->data [$ file ]['branches ' ] = [];
619
- $ this ->data [$ file ]['paths ' ] = [];
620
-
621
- foreach ($ fileData ['functions ' ] as $ functionName => $ functionData ) {
622
- $ this ->data [$ file ]['branches ' ][$ functionName ] = [];
623
- $ this ->data [$ file ]['paths ' ][$ functionName ] = [];
624
-
625
- foreach ($ functionData ['branches ' ] as $ index => $ branch ) {
626
- $ this ->data [$ file ]['branches ' ][$ functionName ][$ index ] = [
627
- 'hit ' => $ branch ['hit ' ],
628
- 'line_start ' => $ branch ['line_start ' ],
629
- 'line_end ' => $ branch ['line_end ' ],
630
- 'tests ' => []
631
- ];
632
- }
614
+ if (!$ this ->filter ->isFile ($ file ) || isset ($ this ->data [$ file ])) {
615
+ continue ;
616
+ }
633
617
634
- foreach ($ functionData ['paths ' ] as $ path ) {
635
- $ this ->data [$ file ]['paths ' ][$ functionName ][] = $ path ;
636
- }
637
- }
638
- }
618
+ $ this ->data [$ file ] = ['lines ' => []];
639
619
640
- foreach ($ fileData ['lines ' ] as $ lineNumber => $ flag ) {
641
- if ($ flag === PHP_CodeCoverage_Driver::LINE_NOT_EXECUTABLE ) {
642
- $ this ->data [$ file ]['lines ' ][$ lineNumber ] = null ;
643
- } else {
644
- $ this ->data [$ file ]['lines ' ][$ lineNumber ] = [
645
- 'pathCovered ' => false ,
646
- 'tests ' => [],
620
+ if ($ this ->pathCoverage ) {
621
+ $ this ->data [$ file ]['branches ' ] = [];
622
+ $ this ->data [$ file ]['paths ' ] = [];
623
+
624
+ foreach ($ fileData ['functions ' ] as $ functionName => $ functionData ) {
625
+ $ this ->data [$ file ]['branches ' ][$ functionName ] = [];
626
+ $ this ->data [$ file ]['paths ' ][$ functionName ] = [];
627
+
628
+ foreach ($ functionData ['branches ' ] as $ index => $ branch ) {
629
+ $ this ->data [$ file ]['branches ' ][$ functionName ][$ index ] = [
630
+ 'hit ' => $ branch ['hit ' ],
631
+ 'line_start ' => $ branch ['line_start ' ],
632
+ 'line_end ' => $ branch ['line_end ' ],
633
+ 'tests ' => []
647
634
];
648
635
}
636
+
637
+ foreach ($ functionData ['paths ' ] as $ path ) {
638
+ $ this ->data [$ file ]['paths ' ][$ functionName ][] = $ path ;
639
+ }
640
+ }
641
+ }
642
+
643
+ foreach ($ fileData ['lines ' ] as $ lineNumber => $ flag ) {
644
+ if ($ flag === PHP_CodeCoverage_Driver::LINE_NOT_EXECUTABLE ) {
645
+ $ this ->data [$ file ]['lines ' ][$ lineNumber ] = null ;
646
+ } else {
647
+ $ this ->data [$ file ]['lines ' ][$ lineNumber ] = [
648
+ 'pathCovered ' => false ,
649
+ 'tests ' => [],
650
+ ];
649
651
}
652
+ }
650
653
651
- foreach ($ this ->data [$ file ]['branches ' ] as $ function ) {
652
- foreach ($ function as $ branch ) {
653
- for ($ i = $ branch ['line_start ' ]; $ i < $ branch ['line_end ' ]; $ i ++) {
654
- if (isset ($ this ->data [$ file ]['lines ' ][$ i ])) {
655
- $ this ->data [$ file ]['lines ' ][$ i ]['pathCovered ' ] = (bool ) $ branch ['hit ' ];
656
- }
654
+ foreach ($ this ->data [$ file ]['branches ' ] as $ function ) {
655
+ foreach ($ function as $ branch ) {
656
+ for ($ i = $ branch ['line_start ' ]; $ i < $ branch ['line_end ' ]; $ i ++) {
657
+ if (isset ($ this ->data [$ file ]['lines ' ][$ i ])) {
658
+ $ this ->data [$ file ]['lines ' ][$ i ]['pathCovered ' ] = (bool ) $ branch ['hit ' ];
657
659
}
658
660
}
659
661
}
0 commit comments