Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Configuration/ConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,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;
}

// We ignore files not found excluded file as we do not want to bail out just because a file we do not want to
Expand Down Expand Up @@ -353,7 +356,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);
Expand All @@ -366,7 +369,7 @@ private static function retrieveFilesWithContents(iterable $files): array
throw InvalidConfigurationValue::forUnreadableFile($filePath);
}

$filesWithContents[$filePath] = [$filePath, file_get_contents($filePath)];
$filesWithContents[$fileKey] = [$filePath, file_get_contents($filePath)];
}

return $filesWithContents;
Expand Down
10 changes: 6 additions & 4 deletions src/Console/ConsoleScoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,26 @@ private static function getFiles(Configuration $config, string $outputDir): arra

$commonDirectoryPath = self::getCommonDirectoryPath($config);

$mapFiles = static fn (array $inputFileTuple) => new File(
$mapFiles = static fn (array $inputFileTuple, string $fileKey ) => new File(
Path::normalize($inputFileTuple[0]),
$inputFileTuple[1],
$outputDir.str_replace($commonDirectoryPath, '', Path::normalize($inputFileTuple[0])),
$outputDir.str_replace($commonDirectoryPath, '', Path::normalize($fileKey)),
);

return [
array_values(
array_map(
$mapFiles,
$filesWithContent,
),
array_keys( $filesWithContent )
)
),
array_values(
array_map(
$mapFiles,
$excludedFilesWithContents,
),
array_keys( $excludedFilesWithContents )
)
),
];
}
Expand Down