function BaseCommand::getPreferredInstallOptions
Returns preferSource and preferDist values based on the configuration.
Return value
bool[] An array composed of the preferSource and preferDist values
6 calls to BaseCommand::getPreferredInstallOptions()
- CreateProjectCommand::execute in vendor/
composer/ composer/ src/ Composer/ Command/ CreateProjectCommand.php - Executes the current command.
- CreateProjectCommand::installProject in vendor/
composer/ composer/ src/ Composer/ Command/ CreateProjectCommand.php - InstallCommand::execute in vendor/
composer/ composer/ src/ Composer/ Command/ InstallCommand.php - Executes the current command.
- ReinstallCommand::execute in vendor/
composer/ composer/ src/ Composer/ Command/ ReinstallCommand.php - Executes the current command.
- RequireCommand::doUpdate in vendor/
composer/ composer/ src/ Composer/ Command/ RequireCommand.php
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ BaseCommand.php, line 320
Class
- BaseCommand
- Base class for Composer commands
Namespace
Composer\CommandCode
protected function getPreferredInstallOptions(Config $config, InputInterface $input, bool $keepVcsRequiresPreferSource = false) {
$preferSource = false;
$preferDist = false;
switch ($config->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if (!$input->hasOption('prefer-dist') || !$input->hasOption('prefer-source')) {
return [
$preferSource,
$preferDist,
];
}
if ($input->hasOption('prefer-install') && is_string($input->getOption('prefer-install'))) {
if ($input->getOption('prefer-source')) {
throw new \InvalidArgumentException('--prefer-source can not be used together with --prefer-install');
}
if ($input->getOption('prefer-dist')) {
throw new \InvalidArgumentException('--prefer-dist can not be used together with --prefer-install');
}
switch ($input->getOption('prefer-install')) {
case 'dist':
$input->setOption('prefer-dist', true);
break;
case 'source':
$input->setOption('prefer-source', true);
break;
case 'auto':
$preferDist = false;
$preferSource = false;
break;
default:
throw new \UnexpectedValueException('--prefer-install accepts one of "dist", "source" or "auto", got ' . $input->getOption('prefer-install'));
}
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || $keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs')) {
$preferSource = $input->getOption('prefer-source') || $keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs');
$preferDist = $input->getOption('prefer-dist');
}
return [
$preferSource,
$preferDist,
];
}