From a833d783eeb4246b6e70bb0b32c6e068077c3bf1 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 2 Oct 2026 19:37:43 +0400 Subject: [PATCH] fix(codecov): leave `eval()`'d code out of coverage Xdebug reports code run through `eval()` under the calling file's path with a suffix, so it passed the path-prefix filter and every report listed a source file that does not exist: on Windows its name turns into an NTFS alternate data stream, and Infection fails to resolve it from coverage-xml. Both drivers now drop the same pseudo-file names php-code-coverage skips. Assisted-By: Claude Opus 5.5 --- .../src/Internal/Driver/PcovDriver.php | 2 +- .../src/Internal/Driver/PseudoFile.php | 62 +++++++++++++++++++ .../src/Internal/Driver/XdebugDriver.php | 2 +- 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 plugin/codecov/src/Internal/Driver/PseudoFile.php diff --git a/plugin/codecov/src/Internal/Driver/PcovDriver.php b/plugin/codecov/src/Internal/Driver/PcovDriver.php index 6cb67685..9b304320 100644 --- a/plugin/codecov/src/Internal/Driver/PcovDriver.php +++ b/plugin/codecov/src/Internal/Driver/PcovDriver.php @@ -79,7 +79,7 @@ public function collect(): CoverageResult \pcov\clear(); - return CoverageResult::fromRawData($data); + return CoverageResult::fromRawData(PseudoFile::remove($data)); } #[\Override] diff --git a/plugin/codecov/src/Internal/Driver/PseudoFile.php b/plugin/codecov/src/Internal/Driver/PseudoFile.php new file mode 100644 index 00000000..426d3e69 --- /dev/null +++ b/plugin/codecov/src/Internal/Driver/PseudoFile.php @@ -0,0 +1,62 @@ + $data Raw coverage keyed by file path. + * @return array + */ + public static function remove(array $data): array + { + return \array_filter($data, static fn(string $path): bool => !self::is($path), \ARRAY_FILTER_USE_KEY); + } +} diff --git a/plugin/codecov/src/Internal/Driver/XdebugDriver.php b/plugin/codecov/src/Internal/Driver/XdebugDriver.php index 92174248..b43b7192 100644 --- a/plugin/codecov/src/Internal/Driver/XdebugDriver.php +++ b/plugin/codecov/src/Internal/Driver/XdebugDriver.php @@ -106,7 +106,7 @@ public function collect(): CoverageResult } } - return CoverageResult::fromRawData($data); + return CoverageResult::fromRawData(PseudoFile::remove($data)); } #[\Override]