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