@@ -377,16 +377,21 @@ private function calculateStatistics(): void
377
377
unset($ tokens );
378
378
379
379
foreach (\range (1 , $ this ->linesOfCode ['loc ' ]) as $ lineNumber ) {
380
- if (isset ($ this ->coverageData ['lines ' ][$ lineNumber ])) {
381
- foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
382
- $ codeUnit ['executableLines ' ]++;
383
- }
380
+ // Check to see if we've identified this line as executed, not executed, or not executable
381
+ if (\array_key_exists ($ lineNumber , $ this ->coverageData ['lines ' ])) {
382
+ // If the element is null, that indicates this line is not executable
383
+ if ($ this ->coverageData ['lines ' ][$ lineNumber ] !== null ) {
384
+ foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
385
+ $ codeUnit ['executableLines ' ]++;
386
+ }
387
+
388
+ unset($ codeUnit );
384
389
385
- unset($ codeUnit );
390
+ $ this ->numExecutableLines ++;
391
+ }
386
392
387
- $ this ->numExecutableLines ++;
388
393
389
- if (\count ( $ this ->coverageData ['lines ' ][$ lineNumber ]) > 0 ) {
394
+ if ($ this ->coverageData ['lines ' ][$ lineNumber ][ ' pathCovered ' ] === true ) {
390
395
foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
391
396
$ codeUnit ['executedLines ' ]++;
392
397
}
@@ -472,6 +477,19 @@ private function calcAndApplyClassAggregate(
472
477
foreach ($ classOrTrait ['methods ' ] as &$ method ) {
473
478
$ methodName = $ method ['methodName ' ];
474
479
480
+ if ($ method ['executableLines ' ] > 0 ) {
481
+ $ method ['coverage ' ] = ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 ;
482
+ } else {
483
+ $ method ['coverage ' ] = 100 ;
484
+ }
485
+
486
+ $ method ['crap ' ] = $ this ->crap (
487
+ $ method ['ccn ' ],
488
+ $ method ['coverage ' ]
489
+ );
490
+
491
+ $ classOrTrait ['ccn ' ] += $ method ['ccn ' ];
492
+
475
493
if (isset ($ this ->coverageData ['paths ' ])) {
476
494
$ methodCoveragePath = $ methodName ;
477
495
@@ -499,19 +517,6 @@ private function calcAndApplyClassAggregate(
499
517
$ this ->numTestedPaths += $ numExexutedPaths ;
500
518
}
501
519
502
- if ($ method ['executableLines ' ] > 0 ) {
503
- $ method ['coverage ' ] = ($ method ['executedLines ' ] /
504
- $ method ['executableLines ' ]) * 100 ;
505
- } else {
506
- $ method ['coverage ' ] = 100 ;
507
- }
508
-
509
- $ method ['crap ' ] = $ this ->crap (
510
- $ method ['ccn ' ],
511
- $ method ['coverage ' ]
512
- );
513
-
514
- $ classOrTrait ['ccn ' ] += $ method ['ccn ' ];
515
520
}
516
521
517
522
if (isset ($ this ->coverageData ['branches ' ])) {
0 commit comments