function Application::getComposer
Return value
?Composer If $required is true then the return value is guaranteed
Throws
\InvalidArgumentException
2 calls to Application::getComposer()
- Application::getPluginCommands in vendor/
composer/ composer/ src/ Composer/ Console/ Application.php - Application::hintCommonErrors in vendor/
composer/ composer/ src/ Composer/ Console/ Application.php
File
-
vendor/
composer/ composer/ src/ Composer/ Console/ Application.php, line 533
Class
- Application
- The console application that handles the commands
Namespace
Composer\ConsoleCode
public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null) : ?Composer {
if (null === $disablePlugins) {
$disablePlugins = $this->disablePluginsByDefault;
}
if (null === $disableScripts) {
$disableScripts = $this->disableScriptsByDefault;
}
if (null === $this->composer) {
try {
$this->composer = Factory::create(Platform::isInputCompletionProcess() ? new NullIO() : $this->io, null, $disablePlugins, $disableScripts);
} catch (\InvalidArgumentException $e) {
if ($required) {
$this->io
->writeError($e->getMessage());
if ($this->areExceptionsCaught()) {
exit(1);
}
throw $e;
}
} catch (JsonValidationException $e) {
if ($required) {
throw $e;
}
} catch (RuntimeException $e) {
if ($required) {
throw $e;
}
}
}
return $this->composer;
}