function InstallationManager::update
Executes update operation.
@phpstan-return PromiseInterface<void|null>|null
Parameters
InstalledRepositoryInterface $repo repository in which to check:
UpdateOperation $operation operation instance:
File
-
vendor/
composer/ composer/ src/ Composer/ Installer/ InstallationManager.php, line 480
Class
- InstallationManager
- Package operation manager.
Namespace
Composer\InstallerCode
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation) : ?PromiseInterface {
$initial = $operation->getInitialPackage();
$target = $operation->getTargetPackage();
$initialType = $initial->getType();
$targetType = $target->getType();
if ($initialType === $targetType) {
$installer = $this->getInstaller($initialType);
$promise = $installer->update($repo, $initial, $target);
$this->markForNotification($target);
}
else {
$promise = $this->getInstaller($initialType)
->uninstall($repo, $initial);
if (!$promise instanceof PromiseInterface) {
$promise = \React\Promise\resolve(null);
}
$installer = $this->getInstaller($targetType);
$promise = $promise->then(static function () use ($installer, $repo, $target) : PromiseInterface {
$promise = $installer->install($repo, $target);
if ($promise instanceof PromiseInterface) {
return $promise;
}
return \React\Promise\resolve(null);
});
}
return $promise;
}