From 542694c528ecbbdbefafbaa6e1d5ec6822eb9333 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Wed, 27 Mar 2024 20:47:53 +0100 Subject: [PATCH] Use realpath for excluding and including individual files This commit makes sure that paths persisted in internal structure are always represented by the real path not relative no matter how they were discovered. This fixes issue with being unable to exclude file loaded via directories configuration or vice versa. --- src/Extension.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Extension.php b/src/Extension.php index 0b3b930..91efdf0 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -34,6 +34,7 @@ use function sprintf; use function sys_get_temp_dir; +use function realpath; class Extension implements ExtensionInterface { @@ -218,7 +219,7 @@ public function initCodeCoverage(Filter $filter, array $filterConfig, ?bool $bra foreach ($filterConfig['include']['directories'] as $directoryToInclude => $details) { foreach ((new FileIteratorFacade())->getFilesAsArray($directoryToInclude, $details['suffix'], $details['prefix']) as $fileToInclude) { - $files[$fileToInclude] = $fileToInclude; + $files[realpath($fileToInclude)] = realpath($fileToInclude); } } @@ -233,7 +234,7 @@ public function initCodeCoverage(Filter $filter, array $filterConfig, ?bool $bra } foreach ($filterConfig['exclude']['files'] as $fileToExclude) { - unset($files[$fileToExclude]); + unset($files[realpath($fileToExclude)]); } foreach ($files as $file) {