From 8d0596163cabca4f9729a6e92adc14f044777dae Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 14 Oct 2020 17:51:03 +0200 Subject: [PATCH] Rename abstract class back to the previously present SolverOperation, mark it internal, reintroduce some duplication --- .../Operation/InstallOperation.php | 22 ++++++++++++++- .../Operation/MarkAliasInstalledOperation.php | 20 ++++++++++---- .../MarkAliasUninstalledOperation.php | 20 ++++++++++---- .../{Operation.php => SolverOperation.php} | 27 +------------------ .../Operation/UninstallOperation.php | 22 ++++++++++++++- .../Operation/UpdateOperation.php | 18 ++++++++----- 6 files changed, 85 insertions(+), 44 deletions(-) rename src/Composer/DependencyResolver/Operation/{Operation.php => SolverOperation.php} (60%) diff --git a/src/Composer/DependencyResolver/Operation/InstallOperation.php b/src/Composer/DependencyResolver/Operation/InstallOperation.php index 4e04485fb..6eefbd5bb 100644 --- a/src/Composer/DependencyResolver/Operation/InstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/InstallOperation.php @@ -19,10 +19,30 @@ use Composer\Package\PackageInterface; * * @author Konstantin Kudryashov */ -class InstallOperation extends Operation implements OperationInterface +class InstallOperation extends SolverOperation implements OperationInterface { const TYPE = 'install'; + /** + * @var PackageInterface + */ + protected $package; + + public function __construct(PackageInterface $package) + { + $this->package = $package; + } + + /** + * Returns package instance. + * + * @return PackageInterface + */ + public function getPackage() + { + return $this->package; + } + /** * {@inheritDoc} */ diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php index 5a3378e3e..4c70257a3 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php @@ -20,18 +20,28 @@ use Composer\Package\PackageInterface; * * @author Nils Adermann */ -class MarkAliasInstalledOperation extends Operation implements OperationInterface +class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface { const TYPE = 'markAliasInstalled'; /** - * Initializes operation. - * - * @param AliasPackage $package package instance + * @var AliasPackage */ + protected $package; + public function __construct(AliasPackage $package) { - parent::__construct($package); + $this->package = $package; + } + + /** + * Returns package instance. + * + * @return AliasPackage + */ + public function getPackage() + { + return $this->package; } /** diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php index 08a9e9087..08ed93ac3 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php @@ -20,18 +20,28 @@ use Composer\Package\PackageInterface; * * @author Nils Adermann */ -class MarkAliasUninstalledOperation extends Operation implements OperationInterface +class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface { const TYPE = 'markAliasUninstalled'; /** - * Initializes operation. - * - * @param AliasPackage $package package instance + * @var AliasPackage */ + protected $package; + public function __construct(AliasPackage $package) { - parent::__construct($package); + $this->package = $package; + } + + /** + * Returns package instance. + * + * @return AliasPackage + */ + public function getPackage() + { + return $this->package; } /** diff --git a/src/Composer/DependencyResolver/Operation/Operation.php b/src/Composer/DependencyResolver/Operation/SolverOperation.php similarity index 60% rename from src/Composer/DependencyResolver/Operation/Operation.php rename to src/Composer/DependencyResolver/Operation/SolverOperation.php index c7ccce803..e1a78da84 100644 --- a/src/Composer/DependencyResolver/Operation/Operation.php +++ b/src/Composer/DependencyResolver/Operation/SolverOperation.php @@ -19,35 +19,10 @@ use Composer\Package\PackageInterface; * * @author Aleksandr Bezpiatov */ -abstract class Operation implements OperationInterface +abstract class SolverOperation implements OperationInterface { const TYPE = null; - /** - * @var PackageInterface - */ - protected $package; - - /** - * Initializes operation. - * - * @param PackageInterface $package package instance - */ - public function __construct(PackageInterface $package) - { - $this->package = $package; - } - - /** - * Returns package instance. - * - * @return PackageInterface - */ - public function getPackage() - { - return $this->package; - } - /** * Returns operation type. * diff --git a/src/Composer/DependencyResolver/Operation/UninstallOperation.php b/src/Composer/DependencyResolver/Operation/UninstallOperation.php index 2f82389f5..585fdb1e5 100644 --- a/src/Composer/DependencyResolver/Operation/UninstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/UninstallOperation.php @@ -19,10 +19,30 @@ use Composer\Package\PackageInterface; * * @author Konstantin Kudryashov */ -class UninstallOperation extends Operation implements OperationInterface +class UninstallOperation extends SolverOperation implements OperationInterface { const TYPE = 'uninstall'; + /** + * @var PackageInterface + */ + protected $package; + + public function __construct(PackageInterface $package) + { + $this->package = $package; + } + + /** + * Returns package instance. + * + * @return PackageInterface + */ + public function getPackage() + { + return $this->package; + } + /** * {@inheritDoc} */ diff --git a/src/Composer/DependencyResolver/Operation/UpdateOperation.php b/src/Composer/DependencyResolver/Operation/UpdateOperation.php index d73f00d7a..543c8e783 100644 --- a/src/Composer/DependencyResolver/Operation/UpdateOperation.php +++ b/src/Composer/DependencyResolver/Operation/UpdateOperation.php @@ -20,22 +20,28 @@ use Composer\Package\Version\VersionParser; * * @author Konstantin Kudryashov */ -class UpdateOperation extends Operation implements OperationInterface +class UpdateOperation extends SolverOperation implements OperationInterface { const TYPE = 'update'; + /** + * @var PackageInterface + */ protected $initialPackage; /** - * Initializes update operation. - * + * @var PackageInterface + */ + protected $targetPackage; + + /** * @param PackageInterface $initial initial package * @param PackageInterface $target target package (updated) */ public function __construct(PackageInterface $initial, PackageInterface $target) { $this->initialPackage = $initial; - parent::__construct($target); + $this->targetPackage = $target; } /** @@ -55,7 +61,7 @@ class UpdateOperation extends Operation implements OperationInterface */ public function getTargetPackage() { - return $this->getPackage(); + return $this->targetPackage; } /** @@ -63,7 +69,7 @@ class UpdateOperation extends Operation implements OperationInterface */ public function show($lock) { - return self::format($this->initialPackage, $this->package, $lock); + return self::format($this->initialPackage, $this->targetPackage, $lock); } public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)