From 09ef026d43fc5ac032d083241e2cab0320ddd325 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 12 Oct 2020 12:31:54 +0200 Subject: [PATCH] Remove OperationInterface::getReason, closes #9230, closes #9263 --- UPGRADE-2.0.md | 1 + .../Operation/InstallOperation.php | 7 +-- .../Operation/MarkAliasInstalledOperation.php | 7 +-- .../MarkAliasUninstalledOperation.php | 7 +-- .../Operation/OperationInterface.php | 7 --- .../Operation/SolverOperation.php | 45 ------------------- .../Operation/UninstallOperation.php | 7 +-- .../Operation/UpdateOperation.php | 7 +-- .../DependencyResolver/Transaction.php | 4 +- .../Installer/InstallationManagerTest.php | 8 ++-- 10 files changed, 17 insertions(+), 83 deletions(-) delete mode 100644 src/Composer/DependencyResolver/Operation/SolverOperation.php diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md index e9897eb26..a31106583 100644 --- a/UPGRADE-2.0.md +++ b/UPGRADE-2.0.md @@ -28,6 +28,7 @@ - packages are now wrapped into a `"packages"` top level key instead of the whole file being the package array - packages now contain an `"installed-path"` key which lists where they were installed - there is a top level `"dev"` key which stores whether dev requirements were installed or not +- Removed `OperationInterface::getReason` as it the data was not accurate. There is no replacement available. - `PreFileDownloadEvent` now receives an `HttpDownloader` instance instead of `RemoteFilesystem`, and that instance cannot be overridden by listeners anymore - `VersionSelector::findBestCandidate`'s third argument (phpVersion) was removed in favor of passing in a complete PlatformRepository instance into the constructor - `InitCommand::determineRequirements`'s fourth argument (phpVersion) should now receive a complete PlatformRepository instance or null if platform requirements are to be ignored diff --git a/src/Composer/DependencyResolver/Operation/InstallOperation.php b/src/Composer/DependencyResolver/Operation/InstallOperation.php index 822d0ab69..a9f808101 100644 --- a/src/Composer/DependencyResolver/Operation/InstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/InstallOperation.php @@ -19,7 +19,7 @@ use Composer\Package\PackageInterface; * * @author Konstantin Kudryashov */ -class InstallOperation extends SolverOperation +class InstallOperation implements OperationInterface { protected $package; @@ -27,12 +27,9 @@ class InstallOperation extends SolverOperation * Initializes operation. * * @param PackageInterface $package package instance - * @param string $reason operation reason */ - public function __construct(PackageInterface $package, $reason = null) + public function __construct(PackageInterface $package) { - parent::__construct($reason); - $this->package = $package; } diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php index e770d5b57..9e3a9f17d 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php @@ -20,7 +20,7 @@ use Composer\Package\PackageInterface; * * @author Nils Adermann */ -class MarkAliasInstalledOperation extends SolverOperation +class MarkAliasInstalledOperation implements OperationInterface { protected $package; @@ -28,12 +28,9 @@ class MarkAliasInstalledOperation extends SolverOperation * Initializes operation. * * @param AliasPackage $package package instance - * @param string $reason operation reason */ - public function __construct(AliasPackage $package, $reason = null) + public function __construct(AliasPackage $package) { - parent::__construct($reason); - $this->package = $package; } diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php index 0803fbb86..16ca62ad9 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php @@ -20,7 +20,7 @@ use Composer\Package\PackageInterface; * * @author Nils Adermann */ -class MarkAliasUninstalledOperation extends SolverOperation +class MarkAliasUninstalledOperation implements OperationInterface { protected $package; @@ -28,12 +28,9 @@ class MarkAliasUninstalledOperation extends SolverOperation * Initializes operation. * * @param AliasPackage $package package instance - * @param string $reason operation reason */ - public function __construct(AliasPackage $package, $reason = null) + public function __construct(AliasPackage $package) { - parent::__construct($reason); - $this->package = $package; } diff --git a/src/Composer/DependencyResolver/Operation/OperationInterface.php b/src/Composer/DependencyResolver/Operation/OperationInterface.php index be5e8f7af..dc61c3a94 100644 --- a/src/Composer/DependencyResolver/Operation/OperationInterface.php +++ b/src/Composer/DependencyResolver/Operation/OperationInterface.php @@ -26,13 +26,6 @@ interface OperationInterface */ public function getOperationType(); - /** - * Returns operation reason. - * - * @return string - */ - public function getReason(); - /** * Serializes the operation in a human readable format * diff --git a/src/Composer/DependencyResolver/Operation/SolverOperation.php b/src/Composer/DependencyResolver/Operation/SolverOperation.php deleted file mode 100644 index 5839cbd64..000000000 --- a/src/Composer/DependencyResolver/Operation/SolverOperation.php +++ /dev/null @@ -1,45 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\DependencyResolver\Operation; - -use Composer\Package\PackageInterface; - -/** - * Abstract solver operation class. - * - * @author Konstantin Kudryashov - */ -abstract class SolverOperation implements OperationInterface -{ - protected $reason; - - /** - * Initializes operation. - * - * @param string $reason operation reason - */ - public function __construct($reason = null) - { - $this->reason = $reason; - } - - /** - * Returns operation reason. - * - * @return string - */ - public function getReason() - { - return $this->reason; - } -} diff --git a/src/Composer/DependencyResolver/Operation/UninstallOperation.php b/src/Composer/DependencyResolver/Operation/UninstallOperation.php index 13c0d4831..4fb39a6f6 100644 --- a/src/Composer/DependencyResolver/Operation/UninstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/UninstallOperation.php @@ -19,7 +19,7 @@ use Composer\Package\PackageInterface; * * @author Konstantin Kudryashov */ -class UninstallOperation extends SolverOperation +class UninstallOperation implements OperationInterface { protected $package; @@ -27,12 +27,9 @@ class UninstallOperation extends SolverOperation * Initializes operation. * * @param PackageInterface $package package instance - * @param string $reason operation reason */ - public function __construct(PackageInterface $package, $reason = null) + public function __construct(PackageInterface $package) { - parent::__construct($reason); - $this->package = $package; } diff --git a/src/Composer/DependencyResolver/Operation/UpdateOperation.php b/src/Composer/DependencyResolver/Operation/UpdateOperation.php index 37fd78892..9e2fa99e5 100644 --- a/src/Composer/DependencyResolver/Operation/UpdateOperation.php +++ b/src/Composer/DependencyResolver/Operation/UpdateOperation.php @@ -20,7 +20,7 @@ use Composer\Package\Version\VersionParser; * * @author Konstantin Kudryashov */ -class UpdateOperation extends SolverOperation +class UpdateOperation implements OperationInterface { protected $initialPackage; protected $targetPackage; @@ -30,12 +30,9 @@ class UpdateOperation extends SolverOperation * * @param PackageInterface $initial initial package * @param PackageInterface $target target package (updated) - * @param string $reason update reason */ - public function __construct(PackageInterface $initial, PackageInterface $target, $reason = null) + public function __construct(PackageInterface $initial, PackageInterface $target) { - parent::__construct($reason); - $this->initialPackage = $initial; $this->targetPackage = $target; } diff --git a/src/Composer/DependencyResolver/Transaction.php b/src/Composer/DependencyResolver/Transaction.php index 6d17d98cb..ed925d8f4 100644 --- a/src/Composer/DependencyResolver/Transaction.php +++ b/src/Composer/DependencyResolver/Transaction.php @@ -158,10 +158,10 @@ class Transaction } foreach ($removeMap as $name => $package) { - array_unshift($operations, new Operation\UninstallOperation($package, null)); + array_unshift($operations, new Operation\UninstallOperation($package)); } foreach ($removeAliasMap as $nameVersion => $package) { - $operations[] = new Operation\MarkAliasUninstalledOperation($package, null); + $operations[] = new Operation\MarkAliasUninstalledOperation($package); } $operations = $this->movePluginsToFront($operations); diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index 9f9bf5572..c7256fe8b 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -124,7 +124,7 @@ class InstallationManagerTest extends TestCase $manager->addInstaller($installer); $package = $this->createPackageMock(); - $operation = new InstallOperation($package, 'test'); + $operation = new InstallOperation($package); $package ->expects($this->once()) @@ -153,7 +153,7 @@ class InstallationManagerTest extends TestCase $initial = $this->createPackageMock(); $target = $this->createPackageMock(); - $operation = new UpdateOperation($initial, $target, 'test'); + $operation = new UpdateOperation($initial, $target); $initial ->expects($this->once()) @@ -221,7 +221,7 @@ class InstallationManagerTest extends TestCase ->method('install') ->with($this->repository, $target); - $operation = new UpdateOperation($initial, $target, 'test'); + $operation = new UpdateOperation($initial, $target); $manager->update($this->repository, $operation); } @@ -232,7 +232,7 @@ class InstallationManagerTest extends TestCase $manager->addInstaller($installer); $package = $this->createPackageMock(); - $operation = new UninstallOperation($package, 'test'); + $operation = new UninstallOperation($package); $package ->expects($this->once())