Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for symlinks #865

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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 @@ -293,7 +293,10 @@
$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);
Expand Down Expand Up @@ -390,7 +393,7 @@
{
$filesWithContents = [];

foreach ($files as $filePathOrFileInfo) {
foreach ($files as $fileKey => $filePathOrFileInfo) {
$filePath = $filePathOrFileInfo instanceof SplFileInfo
? $filePathOrFileInfo->getRealPath()
: realpath($filePathOrFileInfo);
Expand All @@ -413,10 +416,10 @@
);
}

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

return $filesWithContents;

Check failure on line 422 in src/Configuration/ConfigurationFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Humbug\PhpScoper\Configuration\ConfigurationFactory::retrieveFilesWithContents() should return array<string, array{string, string}> but returns array<int|string, array{non-falsy-string, string}>.
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Console/ConsoleScoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
),
];
}
Expand Down
Loading