Skip to content

Commit

Permalink
Use realpath for excluding and including individual files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kadet1090 committed Apr 3, 2024
1 parent 2a04dc0 commit 542694c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

use function sprintf;
use function sys_get_temp_dir;
use function realpath;

class Extension implements ExtensionInterface
{
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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) {
Expand Down

0 comments on commit 542694c

Please sign in to comment.