function PathDownloader::computeAllowedStrategies
@phpstan-return array{self::STRATEGY_*, non-empty-list<self::STRATEGY_*>}
Parameters
mixed[] $transportOptions:
2 calls to PathDownloader::computeAllowedStrategies()
- PathDownloader::getInstallOperationAppendix in vendor/
composer/ composer/ src/ Composer/ Downloader/ PathDownloader.php - @inheritDoc
- PathDownloader::install in vendor/
composer/ composer/ src/ Composer/ Downloader/ PathDownloader.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ Downloader/ PathDownloader.php, line 275
Class
- PathDownloader
- Download a package from a local path.
Namespace
Composer\DownloaderCode
private function computeAllowedStrategies(array $transportOptions) : array {
// When symlink transport option is null, both symlink and mirror are allowed
$currentStrategy = self::STRATEGY_SYMLINK;
$allowedStrategies = [
self::STRATEGY_SYMLINK,
self::STRATEGY_MIRROR,
];
$mirrorPathRepos = Platform::getEnv('COMPOSER_MIRROR_PATH_REPOS');
if ((bool) $mirrorPathRepos) {
$currentStrategy = self::STRATEGY_MIRROR;
}
$symlinkOption = $transportOptions['symlink'] ?? null;
if (true === $symlinkOption) {
$currentStrategy = self::STRATEGY_SYMLINK;
$allowedStrategies = [
self::STRATEGY_SYMLINK,
];
}
elseif (false === $symlinkOption) {
$currentStrategy = self::STRATEGY_MIRROR;
$allowedStrategies = [
self::STRATEGY_MIRROR,
];
}
// Check we can use junctions safely if we are on Windows
if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
throw new \RuntimeException('You are on an old Windows / old PHP combo which does not allow Composer to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed');
}
$currentStrategy = self::STRATEGY_MIRROR;
$allowedStrategies = [
self::STRATEGY_MIRROR,
];
}
// Check we can use symlink() otherwise
if (!Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !function_exists('symlink')) {
if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
throw new \RuntimeException('Your PHP has the symlink() function disabled which does not allow Composer to use symlinks and this path repository has symlink:true in its options so copying is not allowed');
}
$currentStrategy = self::STRATEGY_MIRROR;
$allowedStrategies = [
self::STRATEGY_MIRROR,
];
}
return [
$currentStrategy,
$allowedStrategies,
];
}