From b5bb2139dc0f3e14a3341946e803247844dcab2f Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Fri, 1 May 2026 12:57:12 +0100 Subject: [PATCH] wqdqwd --- src/Plugins/Tia/Recorder.php | 44 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/Plugins/Tia/Recorder.php b/src/Plugins/Tia/Recorder.php index 2bb1a410..0a63410f 100644 --- a/src/Plugins/Tia/Recorder.php +++ b/src/Plugins/Tia/Recorder.php @@ -149,7 +149,10 @@ final class Recorder if ($this->driver === 'pcov') { \pcov\stop(); /** @var array $data */ - $data = \pcov\collect(\pcov\all); + $filesToCollectCoverageFor = \pcov\waiting(); + + /** @var array $data */ + $data = \pcov\collect(\pcov\inclusive, $filesToCollectCoverageFor); // pcov returns every executable line in every file it // tracked: positive values for executed lines, `-1` for @@ -160,7 +163,9 @@ final class Recorder // at framework boot. Including those attributes every // globally-bootstrapped class to whichever test triggered // the boot, blowing up the affected set on edits to those - // files. + // files. We further narrow to phpunit.xml's `` + // scope so files outside the configured include set never + // become edges. $coveredFiles = self::filesWithExecutedLines($data); } else { /** @var array $data */ @@ -656,11 +661,16 @@ final class Recorder } /** - * Filters pcov's `file => line => executionCount` map to the files - * that actually had at least one executed line. pcov reports `-1` - * for "executable but not run" and a positive count for executed - * lines; a file with no positives was loaded but contributed no - * executed code to this test. + * Filters pcov's `file => line => executionCount` map to files that + * actually had executed code AND live inside the configured source + * scope (`phpunit.xml`'s `` block, or the project root with + * vendor/etc. excluded as fallback). + * + * pcov reports `-1` for "executable but not run" and a positive + * count for executed lines. We also skip files where the *only* + * positive line is the implicit `ZEND_RETURN` at end-of-file: pcov + * surfaces that as a one-line artifact for files that were merely + * included (autoloaded) without any real code running. * * @param array $data * @return list @@ -674,13 +684,25 @@ final class Recorder continue; } - foreach ($lines as $count) { + $covered = []; + foreach ($lines as $line => $count) { if (is_int($count) && $count > 0) { - $out[] = $file; - - continue 2; + $covered[] = $line; } } + + if ($covered === []) { + continue; + } + + // Skip files where the only "executed" line is the implicit + // ZEND_RETURN at end-of-file (pcov artifact from being included + // but never actually run). + if (count($covered) === 1 && max($covered) === max(array_keys($lines))) { + continue; + } + + $out[] = $file; } return $out;