@@ -140,21 +140,28 @@ final class File extends AbstractNode
140140 */
141141 private array $ codeUnitsByLine = [];
142142
143+ /**
144+ * @var array<int, int>
145+ */
146+ private array $ executableLinesGroupedByBranch = [];
147+
143148 /**
144149 * @param array<int, ?list<non-empty-string>> $lineCoverageData
145150 * @param array<string, TestType> $testData
146151 * @param array<string, Class_> $classes
147152 * @param array<string, Trait_> $traits
148153 * @param array<string, Function_> $functions
154+ * @param array<int, int> $executableLinesGroupedByBranch
149155 */
150- public function __construct (string $ name , AbstractNode $ parent , array $ lineCoverageData , array $ functionCoverageData , array $ testData , array $ classes , array $ traits , array $ functions , LinesOfCode $ linesOfCode )
156+ public function __construct (string $ name , AbstractNode $ parent , array $ lineCoverageData , array $ functionCoverageData , array $ testData , array $ classes , array $ traits , array $ functions , LinesOfCode $ linesOfCode, array $ executableLinesGroupedByBranch )
151157 {
152158 parent ::__construct ($ name , $ parent );
153159
154- $ this ->lineCoverageData = $ lineCoverageData ;
160+ $ this ->lineCoverageData = $ lineCoverageData ;
155161 $ this ->functionCoverageData = $ functionCoverageData ;
156- $ this ->testData = $ testData ;
157- $ this ->linesOfCode = $ linesOfCode ;
162+ $ this ->testData = $ testData ;
163+ $ this ->linesOfCode = $ linesOfCode ;
164+ $ this ->executableLinesGroupedByBranch = $ executableLinesGroupedByBranch ;
158165
159166 $ this ->calculateStatistics ($ classes , $ traits , $ functions );
160167 }
@@ -374,8 +381,11 @@ private function calculateStatistics(array $classes, array $traits, array $funct
374381 $ this ->processTraits ($ traits );
375382 $ this ->processFunctions ($ functions );
376383
384+ // Get executable lines from the ExecutableLinesFindingVisitor
385+ $ executableLines = $ this ->executableLinesGroupedByBranch ();
386+
377387 foreach (range (1 , $ this ->linesOfCode ->linesOfCode ()) as $ lineNumber ) {
378- if (isset ($ this -> lineCoverageData [$ lineNumber ])) {
388+ if (isset ($ executableLines [$ lineNumber ])) {
379389 foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
380390 if (isset ($ codeUnit ['executableLines ' ])) {
381391 $ codeUnit ['executableLines ' ]++;
@@ -386,7 +396,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
386396
387397 $ this ->numExecutableLines ++;
388398
389- if (count ($ this ->lineCoverageData [$ lineNumber ]) > 0 ) {
399+ if (isset ( $ this -> lineCoverageData [ $ lineNumber ]) && count ($ this ->lineCoverageData [$ lineNumber] ?? [ ]) > 0 ) {
390400 foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
391401 if (isset ($ codeUnit ['executedLines ' ])) {
392402 $ codeUnit ['executedLines ' ]++;
@@ -699,4 +709,12 @@ static function (array $path)
699709
700710 return $ methodData ;
701711 }
712+
713+ /**
714+ * @return array<int, int>
715+ */
716+ private function executableLinesGroupedByBranch (): array
717+ {
718+ return $ this ->executableLinesGroupedByBranch ;
719+ }
702720}
0 commit comments