@@ -299,17 +299,13 @@ public function numberOfMethods(): int
299
299
300
300
foreach ($ this ->classes as $ class ) {
301
301
foreach ($ class ['methods ' ] as $ method ) {
302
- if ($ method ['executableLines ' ] > 0 ) {
303
- $ this ->numMethods ++;
304
- }
302
+ $ this ->numMethods ++;
305
303
}
306
304
}
307
305
308
306
foreach ($ this ->traits as $ trait ) {
309
307
foreach ($ trait ['methods ' ] as $ method ) {
310
- if ($ method ['executableLines ' ] > 0 ) {
311
- $ this ->numMethods ++;
312
- }
308
+ $ this ->numMethods ++;
313
309
}
314
310
}
315
311
}
@@ -324,17 +320,15 @@ public function numberOfTestedMethods(): int
324
320
325
321
foreach ($ this ->classes as $ class ) {
326
322
foreach ($ class ['methods ' ] as $ method ) {
327
- if ($ method ['executableLines ' ] > 0 &&
328
- $ method ['coverage ' ] === 100 ) {
323
+ if ($ method ['coverage ' ] === 100 ) {
329
324
$ this ->numTestedMethods ++;
330
325
}
331
326
}
332
327
}
333
328
334
329
foreach ($ this ->traits as $ trait ) {
335
330
foreach ($ trait ['methods ' ] as $ method ) {
336
- if ($ method ['executableLines ' ] > 0 &&
337
- $ method ['coverage ' ] === 100 ) {
331
+ if ($ method ['coverage ' ] === 100 ) {
338
332
$ this ->numTestedMethods ++;
339
333
}
340
334
}
@@ -383,7 +377,9 @@ private function calculateStatistics(array $classes, array $traits, array $funct
383
377
foreach (range (1 , $ this ->linesOfCode ->linesOfCode ()) as $ lineNumber ) {
384
378
if (isset ($ this ->lineCoverageData [$ lineNumber ])) {
385
379
foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
386
- $ codeUnit ['executableLines ' ]++;
380
+ if (isset ($ codeUnit ['executableLines ' ])) {
381
+ $ codeUnit ['executableLines ' ]++;
382
+ }
387
383
}
388
384
389
385
unset($ codeUnit );
@@ -392,7 +388,9 @@ private function calculateStatistics(array $classes, array $traits, array $funct
392
388
393
389
if (count ($ this ->lineCoverageData [$ lineNumber ]) > 0 ) {
394
390
foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
395
- $ codeUnit ['executedLines ' ]++;
391
+ if (isset ($ codeUnit ['executedLines ' ])) {
392
+ $ codeUnit ['executedLines ' ]++;
393
+ }
396
394
}
397
395
398
396
unset($ codeUnit );
@@ -404,7 +402,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
404
402
405
403
foreach ($ this ->traits as &$ trait ) {
406
404
foreach ($ trait ['methods ' ] as &$ method ) {
407
- $ methodLineCoverage = $ method ['executableLines ' ] > 0 ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 100 ;
405
+ $ methodLineCoverage = $ method ['executableLines ' ] > 0 ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 0 ;
408
406
$ methodBranchCoverage = $ method ['executableBranches ' ] > 0 ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
409
407
$ methodPathCoverage = $ method ['executablePaths ' ] > 0 ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
410
408
@@ -416,7 +414,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
416
414
417
415
unset($ method );
418
416
419
- $ traitLineCoverage = $ trait ['executableLines ' ] > 0 ? ($ trait ['executedLines ' ] / $ trait ['executableLines ' ]) * 100 : 100 ;
417
+ $ traitLineCoverage = $ trait ['executableLines ' ] > 0 ? ($ trait ['executedLines ' ] / $ trait ['executableLines ' ]) * 100 : 0 ;
420
418
$ traitBranchCoverage = $ trait ['executableBranches ' ] > 0 ? ($ trait ['executedBranches ' ] / $ trait ['executableBranches ' ]) * 100 : 0 ;
421
419
$ traitPathCoverage = $ trait ['executablePaths ' ] > 0 ? ($ trait ['executedPaths ' ] / $ trait ['executablePaths ' ]) * 100 : 0 ;
422
420
@@ -432,7 +430,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
432
430
433
431
foreach ($ this ->classes as &$ class ) {
434
432
foreach ($ class ['methods ' ] as &$ method ) {
435
- $ methodLineCoverage = $ method ['executableLines ' ] > 0 ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 100 ;
433
+ $ methodLineCoverage = $ method ['executableLines ' ] > 0 ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 0 ;
436
434
$ methodBranchCoverage = $ method ['executableBranches ' ] > 0 ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
437
435
$ methodPathCoverage = $ method ['executablePaths ' ] > 0 ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
438
436
@@ -444,7 +442,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
444
442
445
443
unset($ method );
446
444
447
- $ classLineCoverage = $ class ['executableLines ' ] > 0 ? ($ class ['executedLines ' ] / $ class ['executableLines ' ]) * 100 : 100 ;
445
+ $ classLineCoverage = $ class ['executableLines ' ] > 0 ? ($ class ['executedLines ' ] / $ class ['executableLines ' ]) * 100 : 0 ;
448
446
$ classBranchCoverage = $ class ['executableBranches ' ] > 0 ? ($ class ['executedBranches ' ] / $ class ['executableBranches ' ]) * 100 : 0 ;
449
447
$ classPathCoverage = $ class ['executablePaths ' ] > 0 ? ($ class ['executedPaths ' ] / $ class ['executablePaths ' ]) * 100 : 0 ;
450
448
@@ -459,7 +457,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
459
457
unset($ class );
460
458
461
459
foreach ($ this ->functions as &$ function ) {
462
- $ functionLineCoverage = $ function ['executableLines ' ] > 0 ? ($ function ['executedLines ' ] / $ function ['executableLines ' ]) * 100 : 100 ;
460
+ $ functionLineCoverage = $ function ['executableLines ' ] > 0 ? ($ function ['executedLines ' ] / $ function ['executableLines ' ]) * 100 : 0 ;
463
461
$ functionBranchCoverage = $ function ['executableBranches ' ] > 0 ? ($ function ['executedBranches ' ] / $ function ['executableBranches ' ]) * 100 : 0 ;
464
462
$ functionPathCoverage = $ function ['executablePaths ' ] > 0 ? ($ function ['executedPaths ' ] / $ function ['executablePaths ' ]) * 100 : 0 ;
465
463
@@ -664,6 +662,9 @@ private function newMethod(string $className, Method $method, string $link): arr
664
662
665
663
$ key = $ className . '-> ' . $ method ->name ();
666
664
665
+ // Initialize executable lines based on the method's body
666
+ // (Removed increment and debug output here)
667
+
667
668
if (isset ($ this ->functionCoverageData [$ key ]['branches ' ])) {
668
669
$ methodData ['executableBranches ' ] = count (
669
670
$ this ->functionCoverageData [$ key ]['branches ' ],
0 commit comments