diff --git a/src/Configuration/ConfigurationFactory.php b/src/Configuration/ConfigurationFactory.php index 10dbdf81..e56b5bec 100644 --- a/src/Configuration/ConfigurationFactory.php +++ b/src/Configuration/ConfigurationFactory.php @@ -293,7 +293,10 @@ private function retrieveExcludedFiles(string $dirPath, array $config): array $file = $dirPath.DIRECTORY_SEPARATOR.$file; } - $excludedFiles[$index] = realpath($file); + unset( $excludedFiles[$index] ); + $fileKey = str_replace( $dirPath.DIRECTORY_SEPARATOR, '', $file ); + $file = realpath($file); + $excludedFiles[$fileKey] = $file; } return array_filter($excludedFiles); @@ -390,7 +393,7 @@ private static function retrieveFilesWithContents(iterable $files): array { $filesWithContents = []; - foreach ($files as $filePathOrFileInfo) { + foreach ($files as $fileKey => $filePathOrFileInfo) { $filePath = $filePathOrFileInfo instanceof SplFileInfo ? $filePathOrFileInfo->getRealPath() : realpath($filePathOrFileInfo); @@ -413,7 +416,7 @@ private static function retrieveFilesWithContents(iterable $files): array ); } - $filesWithContents[$filePath] = [$filePath, file_get_contents($filePath)]; + $filesWithContents[$fileKey] = [$filePath, file_get_contents($filePath)]; } return $filesWithContents; diff --git a/src/Console/ConsoleScoper.php b/src/Console/ConsoleScoper.php index a8e1a722..a32bd1f7 100644 --- a/src/Console/ConsoleScoper.php +++ b/src/Console/ConsoleScoper.php @@ -178,20 +178,22 @@ private static function getFiles(Configuration $config, string $outputDir): arra ); Assert::notNull($commonDirectoryPath); - $mapFiles = static fn (array $inputFileTuple) => [ + $mapFiles = static fn (array $inputFileTuple, string $fileKey ) => [ Path::normalize($inputFileTuple[0]), $inputFileTuple[1], - $outputDir.str_replace($commonDirectoryPath, '', Path::normalize($inputFileTuple[0])), + $outputDir.str_replace($commonDirectoryPath, '', Path::normalize($fileKey)), ]; return [ array_map( $mapFiles, $filesWithContent, + array_keys( $filesWithContent ) ), array_map( $mapFiles, $excludedFilesWithContents, + array_keys( $excludedFilesWithContents ) ), ]; }