@@ -299,17 +299,13 @@ public function numberOfMethods(): int
299299
300300 foreach ($ this ->classes as $ class ) {
301301 foreach ($ class ['methods ' ] as $ method ) {
302- if ($ method ['executableLines ' ] > 0 ) {
303- $ this ->numMethods ++;
304- }
302+ $ this ->numMethods ++;
305303 }
306304 }
307305
308306 foreach ($ this ->traits as $ trait ) {
309307 foreach ($ trait ['methods ' ] as $ method ) {
310- if ($ method ['executableLines ' ] > 0 ) {
311- $ this ->numMethods ++;
312- }
308+ $ this ->numMethods ++;
313309 }
314310 }
315311 }
@@ -324,17 +320,15 @@ public function numberOfTestedMethods(): int
324320
325321 foreach ($ this ->classes as $ class ) {
326322 foreach ($ class ['methods ' ] as $ method ) {
327- if ($ method ['executableLines ' ] > 0 &&
328- $ method ['coverage ' ] === 100 ) {
323+ if ($ method ['coverage ' ] === 100 ) {
329324 $ this ->numTestedMethods ++;
330325 }
331326 }
332327 }
333328
334329 foreach ($ this ->traits as $ trait ) {
335330 foreach ($ trait ['methods ' ] as $ method ) {
336- if ($ method ['executableLines ' ] > 0 &&
337- $ method ['coverage ' ] === 100 ) {
331+ if ($ method ['coverage ' ] === 100 ) {
338332 $ this ->numTestedMethods ++;
339333 }
340334 }
@@ -383,7 +377,9 @@ private function calculateStatistics(array $classes, array $traits, array $funct
383377 foreach (range (1 , $ this ->linesOfCode ->linesOfCode ()) as $ lineNumber ) {
384378 if (isset ($ this ->lineCoverageData [$ lineNumber ])) {
385379 foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
386- $ codeUnit ['executableLines ' ]++;
380+ if (isset ($ codeUnit ['executableLines ' ])) {
381+ $ codeUnit ['executableLines ' ]++;
382+ }
387383 }
388384
389385 unset($ codeUnit );
@@ -392,7 +388,9 @@ private function calculateStatistics(array $classes, array $traits, array $funct
392388
393389 if (count ($ this ->lineCoverageData [$ lineNumber ]) > 0 ) {
394390 foreach ($ this ->codeUnitsByLine [$ lineNumber ] as &$ codeUnit ) {
395- $ codeUnit ['executedLines ' ]++;
391+ if (isset ($ codeUnit ['executedLines ' ])) {
392+ $ codeUnit ['executedLines ' ]++;
393+ }
396394 }
397395
398396 unset($ codeUnit );
@@ -404,7 +402,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
404402
405403 foreach ($ this ->traits as &$ trait ) {
406404 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 ;
408406 $ methodBranchCoverage = $ method ['executableBranches ' ] > 0 ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
409407 $ methodPathCoverage = $ method ['executablePaths ' ] > 0 ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
410408
@@ -416,7 +414,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
416414
417415 unset($ method );
418416
419- $ traitLineCoverage = $ trait ['executableLines ' ] > 0 ? ($ trait ['executedLines ' ] / $ trait ['executableLines ' ]) * 100 : 100 ;
417+ $ traitLineCoverage = $ trait ['executableLines ' ] > 0 ? ($ trait ['executedLines ' ] / $ trait ['executableLines ' ]) * 100 : 0 ;
420418 $ traitBranchCoverage = $ trait ['executableBranches ' ] > 0 ? ($ trait ['executedBranches ' ] / $ trait ['executableBranches ' ]) * 100 : 0 ;
421419 $ traitPathCoverage = $ trait ['executablePaths ' ] > 0 ? ($ trait ['executedPaths ' ] / $ trait ['executablePaths ' ]) * 100 : 0 ;
422420
@@ -432,7 +430,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
432430
433431 foreach ($ this ->classes as &$ class ) {
434432 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 ;
436434 $ methodBranchCoverage = $ method ['executableBranches ' ] > 0 ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
437435 $ methodPathCoverage = $ method ['executablePaths ' ] > 0 ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
438436
@@ -444,7 +442,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
444442
445443 unset($ method );
446444
447- $ classLineCoverage = $ class ['executableLines ' ] > 0 ? ($ class ['executedLines ' ] / $ class ['executableLines ' ]) * 100 : 100 ;
445+ $ classLineCoverage = $ class ['executableLines ' ] > 0 ? ($ class ['executedLines ' ] / $ class ['executableLines ' ]) * 100 : 0 ;
448446 $ classBranchCoverage = $ class ['executableBranches ' ] > 0 ? ($ class ['executedBranches ' ] / $ class ['executableBranches ' ]) * 100 : 0 ;
449447 $ classPathCoverage = $ class ['executablePaths ' ] > 0 ? ($ class ['executedPaths ' ] / $ class ['executablePaths ' ]) * 100 : 0 ;
450448
@@ -459,7 +457,7 @@ private function calculateStatistics(array $classes, array $traits, array $funct
459457 unset($ class );
460458
461459 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 ;
463461 $ functionBranchCoverage = $ function ['executableBranches ' ] > 0 ? ($ function ['executedBranches ' ] / $ function ['executableBranches ' ]) * 100 : 0 ;
464462 $ functionPathCoverage = $ function ['executablePaths ' ] > 0 ? ($ function ['executedPaths ' ] / $ function ['executablePaths ' ]) * 100 : 0 ;
465463
@@ -664,6 +662,9 @@ private function newMethod(string $className, Method $method, string $link): arr
664662
665663 $ key = $ className . '-> ' . $ method ->name ();
666664
665+ // Initialize executable lines based on the method's body
666+ // (Removed increment and debug output here)
667+
667668 if (isset ($ this ->functionCoverageData [$ key ]['branches ' ])) {
668669 $ methodData ['executableBranches ' ] = count (
669670 $ this ->functionCoverageData [$ key ]['branches ' ],
0 commit comments