Reaching phpstan level 6 in EventDispatcher Exception and Installer folders (#10192)
parent
fa4d4e20e9
commit
a921d9b233
|
@ -95,6 +95,8 @@ class Event
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents the event from being passed to further listeners
|
* Prevents the event from being passed to further listeners
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function stopPropagation()
|
public function stopPropagation()
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,12 +106,12 @@ class EventDispatcher
|
||||||
/**
|
/**
|
||||||
* Dispatch a script event.
|
* Dispatch a script event.
|
||||||
*
|
*
|
||||||
* @param string $eventName The constant in ScriptEvents
|
* @param string $eventName The constant in ScriptEvents
|
||||||
* @param bool $devMode
|
* @param bool $devMode
|
||||||
* @param array $additionalArgs Arguments passed by the user
|
* @param array<int, mixed> $additionalArgs Arguments passed by the user
|
||||||
* @param array $flags Optional flags to pass data not as argument
|
* @param array<string, mixed> $flags Optional flags to pass data not as argument
|
||||||
* @return int return code of the executed script if any, for php scripts a false return
|
* @return int return code of the executed script if any, for php scripts a false return
|
||||||
* value is changed to 1, anything else to 0
|
* value is changed to 1, anything else to 0
|
||||||
*/
|
*/
|
||||||
public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
|
public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
|
||||||
{
|
{
|
||||||
|
@ -121,11 +121,11 @@ class EventDispatcher
|
||||||
/**
|
/**
|
||||||
* Dispatch a package event.
|
* Dispatch a package event.
|
||||||
*
|
*
|
||||||
* @param string $eventName The constant in PackageEvents
|
* @param string $eventName The constant in PackageEvents
|
||||||
* @param bool $devMode Whether or not we are in dev mode
|
* @param bool $devMode Whether or not we are in dev mode
|
||||||
* @param RepositoryInterface $localRepo The installed repository
|
* @param RepositoryInterface $localRepo The installed repository
|
||||||
* @param array $operations The list of operations
|
* @param OperationInterface[] $operations The list of operations
|
||||||
* @param OperationInterface $operation The package being installed/updated/removed
|
* @param OperationInterface $operation The package being installed/updated/removed
|
||||||
*
|
*
|
||||||
* @return int return code of the executed script if any, for php scripts a false return
|
* @return int return code of the executed script if any, for php scripts a false return
|
||||||
* value is changed to 1, anything else to 0
|
* value is changed to 1, anything else to 0
|
||||||
|
@ -338,6 +338,8 @@ class EventDispatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $exec
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function executeTty($exec)
|
protected function executeTty($exec)
|
||||||
|
@ -372,6 +374,8 @@ class EventDispatcher
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* @param string $methodName
|
* @param string $methodName
|
||||||
* @param Event $event Event invoking the PHP callable
|
* @param Event $event Event invoking the PHP callable
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function executeEventPhpScript($className, $methodName, Event $event)
|
protected function executeEventPhpScript($className, $methodName, Event $event)
|
||||||
{
|
{
|
||||||
|
@ -390,6 +394,8 @@ class EventDispatcher
|
||||||
* @param string $eventName The event name - typically a constant
|
* @param string $eventName The event name - typically a constant
|
||||||
* @param callable $listener A callable expecting an event argument
|
* @param callable $listener A callable expecting an event argument
|
||||||
* @param int $priority A higher value represents a higher priority
|
* @param int $priority A higher value represents a higher priority
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addListener($eventName, $listener, $priority = 0)
|
public function addListener($eventName, $listener, $priority = 0)
|
||||||
{
|
{
|
||||||
|
@ -398,6 +404,8 @@ class EventDispatcher
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callable|object $listener A callable or an object instance for which all listeners should be removed
|
* @param callable|object $listener A callable or an object instance for which all listeners should be removed
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeListener($listener)
|
public function removeListener($listener)
|
||||||
{
|
{
|
||||||
|
@ -418,6 +426,8 @@ class EventDispatcher
|
||||||
* @see EventSubscriberInterface
|
* @see EventSubscriberInterface
|
||||||
*
|
*
|
||||||
* @param EventSubscriberInterface $subscriber
|
* @param EventSubscriberInterface $subscriber
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addSubscriber(EventSubscriberInterface $subscriber)
|
public function addSubscriber(EventSubscriberInterface $subscriber)
|
||||||
{
|
{
|
||||||
|
@ -438,7 +448,7 @@ class EventDispatcher
|
||||||
* Retrieves all listeners for a given event
|
* Retrieves all listeners for a given event
|
||||||
*
|
*
|
||||||
* @param Event $event
|
* @param Event $event
|
||||||
* @return array All listeners: callables and scripts
|
* @return array<callable|string> All listeners: callables and scripts
|
||||||
*/
|
*/
|
||||||
protected function getListeners(Event $event)
|
protected function getListeners(Event $event)
|
||||||
{
|
{
|
||||||
|
@ -472,7 +482,7 @@ class EventDispatcher
|
||||||
* Finds all listeners defined as scripts in the package
|
* Finds all listeners defined as scripts in the package
|
||||||
*
|
*
|
||||||
* @param Event $event Event object
|
* @param Event $event Event object
|
||||||
* @return array Listeners
|
* @return string[] Listeners
|
||||||
*/
|
*/
|
||||||
protected function getScriptListeners(Event $event)
|
protected function getScriptListeners(Event $event)
|
||||||
{
|
{
|
||||||
|
@ -550,6 +560,9 @@ class EventDispatcher
|
||||||
return array_pop($this->eventStack);
|
return array_pop($this->eventStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function ensureBinDirIsInPath()
|
private function ensureBinDirIsInPath()
|
||||||
{
|
{
|
||||||
$pathStr = 'PATH';
|
$pathStr = 'PATH';
|
||||||
|
|
|
@ -51,6 +51,12 @@ class BinaryInstaller
|
||||||
$this->filesystem = $filesystem ?: new Filesystem();
|
$this->filesystem = $filesystem ?: new Filesystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $installPath
|
||||||
|
* @param bool $warnOnOverwrite
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
|
public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
|
||||||
{
|
{
|
||||||
$binaries = $this->getBinaries($package);
|
$binaries = $this->getBinaries($package);
|
||||||
|
@ -103,6 +109,9 @@ class BinaryInstaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function removeBinaries(PackageInterface $package)
|
public function removeBinaries(PackageInterface $package)
|
||||||
{
|
{
|
||||||
$this->initializeBinDir();
|
$this->initializeBinDir();
|
||||||
|
@ -127,6 +136,11 @@ class BinaryInstaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $bin
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public static function determineBinaryCaller($bin)
|
public static function determineBinaryCaller($bin)
|
||||||
{
|
{
|
||||||
if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
|
if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
|
||||||
|
@ -143,11 +157,21 @@ class BinaryInstaller
|
||||||
return 'php';
|
return 'php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
protected function getBinaries(PackageInterface $package)
|
protected function getBinaries(PackageInterface $package)
|
||||||
{
|
{
|
||||||
return $package->getBinaries();
|
return $package->getBinaries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $binPath
|
||||||
|
* @param string $link
|
||||||
|
* @param string $bin
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
|
protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
|
||||||
{
|
{
|
||||||
// add unixy support for cygwin and similar environments
|
// add unixy support for cygwin and similar environments
|
||||||
|
@ -164,6 +188,12 @@ class BinaryInstaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $binPath
|
||||||
|
* @param string $link
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function installSymlinkBinaries($binPath, $link)
|
protected function installSymlinkBinaries($binPath, $link)
|
||||||
{
|
{
|
||||||
if (!$this->filesystem->relativeSymlink($binPath, $link)) {
|
if (!$this->filesystem->relativeSymlink($binPath, $link)) {
|
||||||
|
@ -171,18 +201,33 @@ class BinaryInstaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $binPath
|
||||||
|
* @param string $link
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function installUnixyProxyBinaries($binPath, $link)
|
protected function installUnixyProxyBinaries($binPath, $link)
|
||||||
{
|
{
|
||||||
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
||||||
Silencer::call('chmod', $link, 0777 & ~umask());
|
Silencer::call('chmod', $link, 0777 & ~umask());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function initializeBinDir()
|
protected function initializeBinDir()
|
||||||
{
|
{
|
||||||
$this->filesystem->ensureDirectoryExists($this->binDir);
|
$this->filesystem->ensureDirectoryExists($this->binDir);
|
||||||
$this->binDir = realpath($this->binDir);
|
$this->binDir = realpath($this->binDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $bin
|
||||||
|
* @param string $link
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function generateWindowsProxyCode($bin, $link)
|
protected function generateWindowsProxyCode($bin, $link)
|
||||||
{
|
{
|
||||||
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
|
@ -194,6 +239,12 @@ class BinaryInstaller
|
||||||
"{$caller} \"%BIN_TARGET%\" %*\r\n";
|
"{$caller} \"%BIN_TARGET%\" %*\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $bin
|
||||||
|
* @param string $link
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function generateUnixyProxyCode($bin, $link)
|
protected function generateUnixyProxyCode($bin, $link)
|
||||||
{
|
{
|
||||||
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
|
|
|
@ -59,6 +59,9 @@ class InstallationManager
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->notifiablePackages = array();
|
$this->notifiablePackages = array();
|
||||||
|
@ -68,6 +71,8 @@ class InstallationManager
|
||||||
* Adds installer
|
* Adds installer
|
||||||
*
|
*
|
||||||
* @param InstallerInterface $installer installer instance
|
* @param InstallerInterface $installer installer instance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addInstaller(InstallerInterface $installer)
|
public function addInstaller(InstallerInterface $installer)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +84,8 @@ class InstallationManager
|
||||||
* Removes installer
|
* Removes installer
|
||||||
*
|
*
|
||||||
* @param InstallerInterface $installer installer instance
|
* @param InstallerInterface $installer installer instance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeInstaller(InstallerInterface $installer)
|
public function removeInstaller(InstallerInterface $installer)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +101,8 @@ class InstallationManager
|
||||||
* We prevent any plugins from being instantiated by simply
|
* We prevent any plugins from being instantiated by simply
|
||||||
* deactivating the installer for them. This ensure that no third-party
|
* deactivating the installer for them. This ensure that no third-party
|
||||||
* code is ever executed.
|
* code is ever executed.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function disablePlugins()
|
public function disablePlugins()
|
||||||
{
|
{
|
||||||
|
@ -153,6 +162,8 @@ class InstallationManager
|
||||||
* If the installer associated to this package doesn't handle that function, it'll do nothing.
|
* If the installer associated to this package doesn't handle that function, it'll do nothing.
|
||||||
*
|
*
|
||||||
* @param PackageInterface $package Package instance
|
* @param PackageInterface $package Package instance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function ensureBinariesPresence(PackageInterface $package)
|
public function ensureBinariesPresence(PackageInterface $package)
|
||||||
{
|
{
|
||||||
|
@ -176,6 +187,8 @@ class InstallationManager
|
||||||
* @param OperationInterface[] $operations operations to execute
|
* @param OperationInterface[] $operations operations to execute
|
||||||
* @param bool $devMode whether the install is being run in dev mode
|
* @param bool $devMode whether the install is being run in dev mode
|
||||||
* @param bool $runScripts whether to dispatch script events
|
* @param bool $runScripts whether to dispatch script events
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute(InstalledRepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
|
public function execute(InstalledRepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
|
||||||
{
|
{
|
||||||
|
@ -293,8 +306,13 @@ class InstallationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $operations List of operations to execute in this batch
|
* @param OperationInterface[] $operations List of operations to execute in this batch
|
||||||
* @param array $allOperations Complete list of operations to be executed in the install job, used for event listeners
|
* @param PromiseInterface[] $cleanupPromises
|
||||||
|
* @param bool $devMode
|
||||||
|
* @param bool $runScripts
|
||||||
|
* @param OperationInterface[] $allOperations Complete list of operations to be executed in the install job, used for event listeners
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
|
private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
|
||||||
{
|
{
|
||||||
|
@ -309,9 +327,11 @@ class InstallationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opType === 'update') {
|
if ($opType === 'update') {
|
||||||
|
/** @var UpdateOperation $operation */
|
||||||
$package = $operation->getTargetPackage();
|
$package = $operation->getTargetPackage();
|
||||||
$initialPackage = $operation->getInitialPackage();
|
$initialPackage = $operation->getInitialPackage();
|
||||||
} else {
|
} else {
|
||||||
|
/** @var InstallOperation|MarkAliasInstalledOperation|MarkAliasUninstalledOperation|UninstallOperation $operation */
|
||||||
$package = $operation->getPackage();
|
$package = $operation->getPackage();
|
||||||
$initialPackage = null;
|
$initialPackage = null;
|
||||||
}
|
}
|
||||||
|
@ -345,8 +365,8 @@ class InstallationManager
|
||||||
$batches = array();
|
$batches = array();
|
||||||
$batch = array();
|
$batch = array();
|
||||||
foreach ($operations as $index => $operation) {
|
foreach ($operations as $index => $operation) {
|
||||||
if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
|
if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) {
|
||||||
$package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
|
$package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
|
||||||
if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
|
if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
|
||||||
if ($batch) {
|
if ($batch) {
|
||||||
$batches[] = $batch;
|
$batches[] = $batch;
|
||||||
|
@ -370,8 +390,13 @@ class InstallationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $operations List of operations to execute in this batch
|
* @param OperationInterface[] $operations List of operations to execute in this batch
|
||||||
* @param array $allOperations Complete list of operations to be executed in the install job, used for event listeners
|
* @param PromiseInterface[] $cleanupPromises
|
||||||
|
* @param bool $devMode
|
||||||
|
* @param bool $runScripts
|
||||||
|
* @param OperationInterface[] $allOperations Complete list of operations to be executed in the install job, used for event listeners
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
|
private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
|
||||||
{
|
{
|
||||||
|
@ -393,9 +418,11 @@ class InstallationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opType === 'update') {
|
if ($opType === 'update') {
|
||||||
|
/** @var UpdateOperation $operation */
|
||||||
$package = $operation->getTargetPackage();
|
$package = $operation->getTargetPackage();
|
||||||
$initialPackage = $operation->getInitialPackage();
|
$initialPackage = $operation->getInitialPackage();
|
||||||
} else {
|
} else {
|
||||||
|
/** @var InstallOperation|MarkAliasInstalledOperation|MarkAliasUninstalledOperation|UninstallOperation $operation */
|
||||||
$package = $operation->getPackage();
|
$package = $operation->getPackage();
|
||||||
$initialPackage = null;
|
$initialPackage = null;
|
||||||
}
|
}
|
||||||
|
@ -448,6 +475,11 @@ class InstallationManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PromiseInterface[] $promises
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function waitOnPromises(array $promises)
|
private function waitOnPromises(array $promises)
|
||||||
{
|
{
|
||||||
$progress = null;
|
$progress = null;
|
||||||
|
@ -475,6 +507,8 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||||
* @param InstallOperation $operation operation instance
|
* @param InstallOperation $operation operation instance
|
||||||
|
*
|
||||||
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
|
public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
|
||||||
{
|
{
|
||||||
|
@ -491,6 +525,8 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||||
* @param UpdateOperation $operation operation instance
|
* @param UpdateOperation $operation operation instance
|
||||||
|
*
|
||||||
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
|
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
|
||||||
{
|
{
|
||||||
|
@ -524,6 +560,8 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||||
* @param UninstallOperation $operation operation instance
|
* @param UninstallOperation $operation operation instance
|
||||||
|
*
|
||||||
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
|
public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
|
||||||
{
|
{
|
||||||
|
@ -538,6 +576,8 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||||
* @param MarkAliasInstalledOperation $operation operation instance
|
* @param MarkAliasInstalledOperation $operation operation instance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
|
public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
|
||||||
{
|
{
|
||||||
|
@ -553,6 +593,8 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||||
* @param MarkAliasUninstalledOperation $operation operation instance
|
* @param MarkAliasUninstalledOperation $operation operation instance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
|
public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
|
||||||
{
|
{
|
||||||
|
@ -574,11 +616,19 @@ class InstallationManager
|
||||||
return $installer->getInstallPath($package);
|
return $installer->getInstallPath($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $outputProgress
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setOutputProgress($outputProgress)
|
public function setOutputProgress($outputProgress)
|
||||||
{
|
{
|
||||||
$this->outputProgress = $outputProgress;
|
$this->outputProgress = $outputProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function notifyInstalls(IOInterface $io)
|
public function notifyInstalls(IOInterface $io)
|
||||||
{
|
{
|
||||||
$promises = array();
|
$promises = array();
|
||||||
|
@ -638,6 +688,9 @@ class InstallationManager
|
||||||
$this->reset();
|
$this->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function markForNotification(PackageInterface $package)
|
private function markForNotification(PackageInterface $package)
|
||||||
{
|
{
|
||||||
if ($package->getNotificationUrl()) {
|
if ($package->getNotificationUrl()) {
|
||||||
|
|
|
@ -258,6 +258,9 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
||||||
return $installPath;
|
return $installPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return PromiseInterface|null
|
||||||
|
*/
|
||||||
protected function installCode(PackageInterface $package)
|
protected function installCode(PackageInterface $package)
|
||||||
{
|
{
|
||||||
$downloadPath = $this->getInstallPath($package);
|
$downloadPath = $this->getInstallPath($package);
|
||||||
|
@ -265,6 +268,9 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
||||||
return $this->downloadManager->install($package, $downloadPath);
|
return $this->downloadManager->install($package, $downloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return PromiseInterface|null
|
||||||
|
*/
|
||||||
protected function updateCode(PackageInterface $initial, PackageInterface $target)
|
protected function updateCode(PackageInterface $initial, PackageInterface $target)
|
||||||
{
|
{
|
||||||
$initialDownloadPath = $this->getInstallPath($initial);
|
$initialDownloadPath = $this->getInstallPath($initial);
|
||||||
|
@ -298,6 +304,9 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
||||||
return $this->downloadManager->update($initial, $target, $targetDownloadPath);
|
return $this->downloadManager->update($initial, $target, $targetDownloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return PromiseInterface|null
|
||||||
|
*/
|
||||||
protected function removeCode(PackageInterface $package)
|
protected function removeCode(PackageInterface $package)
|
||||||
{
|
{
|
||||||
$downloadPath = $this->getPackageBasePath($package);
|
$downloadPath = $this->getPackageBasePath($package);
|
||||||
|
@ -305,6 +314,9 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
||||||
return $this->downloadManager->remove($package, $downloadPath);
|
return $this->downloadManager->remove($package, $downloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function initializeVendorDir()
|
protected function initializeVendorDir()
|
||||||
{
|
{
|
||||||
$this->filesystem->ensureDirectoryExists($this->vendorDir);
|
$this->filesystem->ensureDirectoryExists($this->vendorDir);
|
||||||
|
|
|
@ -117,6 +117,8 @@ class PluginInstaller extends LibraryInstaller
|
||||||
/**
|
/**
|
||||||
* TODO v3 should make this private once we can drop PHP 5.3 support
|
* TODO v3 should make this private once we can drop PHP 5.3 support
|
||||||
* @private
|
* @private
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
|
public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,9 @@ class ProjectInstaller implements InstallerInterface
|
||||||
/** @var Filesystem */
|
/** @var Filesystem */
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $installPath
|
||||||
|
*/
|
||||||
public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
|
public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
|
||||||
{
|
{
|
||||||
$this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
|
$this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
|
||||||
|
|
|
@ -44,7 +44,7 @@ class SuggestedPackagesReporter
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array Suggested packages with source, target and reason keys.
|
* @return array<array{source: string, target: string, reason: string}> Suggested packages with source, target and reason keys.
|
||||||
*/
|
*/
|
||||||
public function getPackages()
|
public function getPackages()
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@ use Composer\DependencyResolver\Operation\UpdateOperation;
|
||||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||||
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
|
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
|
||||||
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
||||||
|
use React\Promise\PromiseInterface;
|
||||||
|
|
||||||
class InstallationManagerMock extends InstallationManager
|
class InstallationManagerMock extends InstallationManager
|
||||||
{
|
{
|
||||||
|
@ -64,13 +65,21 @@ class InstallationManagerMock extends InstallationManager
|
||||||
return $repo->hasPackage($package);
|
return $repo->hasPackage($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
|
public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
|
||||||
{
|
{
|
||||||
$this->installed[] = $operation->getPackage();
|
$this->installed[] = $operation->getPackage();
|
||||||
$this->trace[] = strip_tags((string) $operation);
|
$this->trace[] = strip_tags((string) $operation);
|
||||||
$repo->addPackage(clone $operation->getPackage());
|
$repo->addPackage(clone $operation->getPackage());
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
|
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
|
||||||
{
|
{
|
||||||
$this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
|
$this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
|
||||||
|
@ -79,13 +88,20 @@ class InstallationManagerMock extends InstallationManager
|
||||||
if (!$repo->hasPackage($operation->getTargetPackage())) {
|
if (!$repo->hasPackage($operation->getTargetPackage())) {
|
||||||
$repo->addPackage(clone $operation->getTargetPackage());
|
$repo->addPackage(clone $operation->getTargetPackage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
|
public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
|
||||||
{
|
{
|
||||||
$this->uninstalled[] = $operation->getPackage();
|
$this->uninstalled[] = $operation->getPackage();
|
||||||
$this->trace[] = strip_tags((string) $operation);
|
$this->trace[] = strip_tags((string) $operation);
|
||||||
$repo->removePackage($operation->getPackage());
|
$repo->removePackage($operation->getPackage());
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
|
public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
|
||||||
|
|
Loading…
Reference in New Issue