Make use of the proper interface
parent
a5e00a9e96
commit
bf6fd10a8a
|
@ -16,6 +16,7 @@ use Composer\Package\PackageInterface;
|
|||
use Composer\Package\AliasPackage;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Repository\NotifiableRepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\DependencyResolver\Operation\InstallOperation;
|
||||
use Composer\DependencyResolver\Operation\UpdateOperation;
|
||||
|
@ -96,12 +97,12 @@ class InstallationManager
|
|||
/**
|
||||
* Checks whether provided package is installed in one of the registered installers.
|
||||
*
|
||||
* @param RepositoryInterface $repo repository in which to check
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $package package instance
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isPackageInstalled(RepositoryInterface $repo, PackageInterface $package)
|
||||
public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
return $this->getInstaller($package->getType())->isInstalled($repo, $package);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Installer;
|
|||
use Composer\IO\IOInterface;
|
||||
use Composer\Autoload\AutoloadGenerator;
|
||||
use Composer\Downloader\DownloadManager;
|
||||
use Composer\Repository\WritableRepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
|
@ -35,7 +35,7 @@ class InstallerInstaller extends LibraryInstaller
|
|||
* @param DownloadManager $dm download manager
|
||||
* @param IOInterface $io io instance
|
||||
* @param InstallationManager $im installation manager
|
||||
* @param array $localRepositories array of WritableRepositoryInterface
|
||||
* @param array $localRepositories array of InstalledRepositoryInterface
|
||||
*/
|
||||
public function __construct($vendorDir, $binDir, DownloadManager $dm, IOInterface $io, InstallationManager $im, array $localRepositories)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ class InstallerInstaller extends LibraryInstaller
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function install(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
$extra = $package->getExtra();
|
||||
if (empty($extra['class'])) {
|
||||
|
@ -68,7 +68,7 @@ class InstallerInstaller extends LibraryInstaller
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
{
|
||||
$extra = $target->getExtra();
|
||||
if (empty($extra['class'])) {
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Composer\Installer;
|
|||
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\WritableRepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Interface for the package installation manager.
|
||||
|
@ -35,39 +35,39 @@ interface InstallerInterface
|
|||
/**
|
||||
* Checks that provided package is installed.
|
||||
*
|
||||
* @param WritableRepositoryInterface $repo repository in which to check
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $package package instance
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
function isInstalled(WritableRepositoryInterface $repo, PackageInterface $package);
|
||||
function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
|
||||
|
||||
/**
|
||||
* Installs specific package.
|
||||
*
|
||||
* @param WritableRepositoryInterface $repo repository in which to check
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $package package instance
|
||||
*/
|
||||
function install(WritableRepositoryInterface $repo, PackageInterface $package);
|
||||
function install(InstalledRepositoryInterface $repo, PackageInterface $package);
|
||||
|
||||
/**
|
||||
* Updates specific package.
|
||||
*
|
||||
* @param WritableRepositoryInterface $repo repository in which to check
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $initial already installed package version
|
||||
* @param PackageInterface $target updated version
|
||||
*
|
||||
* @throws InvalidArgumentException if $from package is not installed
|
||||
*/
|
||||
function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
|
||||
function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
|
||||
|
||||
/**
|
||||
* Uninstalls specific package.
|
||||
*
|
||||
* @param WritableRepositoryInterface $repo repository in which to check
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $package package instance
|
||||
*/
|
||||
function uninstall(WritableRepositoryInterface $repo, PackageInterface $package);
|
||||
function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
|
||||
|
||||
/**
|
||||
* Returns the installation path of a package
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Composer\Installer;
|
|||
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Downloader\DownloadManager;
|
||||
use Composer\Repository\WritableRepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Util\Filesystem;
|
||||
|
@ -65,7 +65,7 @@ class LibraryInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isInstalled(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
return $repo->hasPackage($package) && is_readable($this->getInstallPath($package));
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class LibraryInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function install(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
$this->initializeVendorDir();
|
||||
$downloadPath = $this->getInstallPath($package);
|
||||
|
@ -93,7 +93,7 @@ class LibraryInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
{
|
||||
if (!$repo->hasPackage($initial)) {
|
||||
throw new \InvalidArgumentException('Package is not installed: '.$initial);
|
||||
|
@ -114,7 +114,7 @@ class LibraryInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function uninstall(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
if (!$repo->hasPackage($package)) {
|
||||
// TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Composer\Installer;
|
||||
|
||||
use Composer\Repository\WritableRepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ class MetapackageInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isInstalled(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
return $repo->hasPackage($package);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class MetapackageInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function install(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
$repo->addPackage(clone $package);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class MetapackageInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
{
|
||||
if (!$repo->hasPackage($initial)) {
|
||||
throw new \InvalidArgumentException('Package is not installed: '.$initial);
|
||||
|
@ -62,7 +62,7 @@ class MetapackageInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function uninstall(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
if (!$repo->hasPackage($package)) {
|
||||
// TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Installer;
|
|||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Downloader\DownloadManager;
|
||||
use Composer\Repository\WritableRepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Project Installer is used to install a single package into a directory as
|
||||
|
@ -48,7 +48,7 @@ class ProjectInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isInstalled(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ProjectInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function install(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
$installPath = $this->installPath;
|
||||
if (file_exists($installPath)) {
|
||||
|
@ -72,7 +72,7 @@ class ProjectInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
{
|
||||
throw new \InvalidArgumentException("not supported");
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class ProjectInstaller implements InstallerInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function uninstall(WritableRepositoryInterface $repo, PackageInterface $package)
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
throw new \InvalidArgumentException("not supported");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue