diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php
index 5a07cee8b..4eaddda5c 100644
--- a/src/Composer/Command/StatusCommand.php
+++ b/src/Composer/Command/StatusCommand.php
@@ -59,7 +59,7 @@ EOT
if ($downloader instanceof ChangeReportInterface) {
$targetDir = $im->getInstallPath($package);
- if ($changes = $downloader->getLocalChanges($targetDir, $package)) {
+ if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
$errors[$targetDir] = $changes;
}
}
diff --git a/src/Composer/Downloader/ChangeReportInterface.php b/src/Composer/Downloader/ChangeReportInterface.php
index 1d770ec8e..e60615431 100644
--- a/src/Composer/Downloader/ChangeReportInterface.php
+++ b/src/Composer/Downloader/ChangeReportInterface.php
@@ -24,9 +24,9 @@ interface ChangeReportInterface
/**
* Checks for changes to the local copy
*
- * @param string $path package directory
* @param PackageInterface $package package instance
+ * @param string $path package directory
* @return string|null changes or null
*/
- public function getLocalChanges($path, PackageInterface $package);
+ public function getLocalChanges(PackageInterface $package, $path);
}
diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php
index e25da3ee6..f320cf931 100644
--- a/src/Composer/Downloader/GitDownloader.php
+++ b/src/Composer/Downloader/GitDownloader.php
@@ -78,7 +78,7 @@ class GitDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
- public function getLocalChanges($path, PackageInterface $package)
+ public function getLocalChanges(PackageInterface $package, $path)
{
$this->cleanEnv();
$path = $this->normalizePath($path);
@@ -97,11 +97,11 @@ class GitDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
- protected function cleanChanges($path, $update, $package)
+ protected function cleanChanges(PackageInterface $package, $path, $update)
{
$this->cleanEnv();
$path = $this->normalizePath($path);
- if (!$changes = $this->getLocalChanges($path, $package)) {
+ if (!$changes = $this->getLocalChanges($package, $path)) {
return;
}
@@ -112,13 +112,13 @@ class GitDownloader extends VcsDownloader
}
if ('stash' === $discardChanges) {
if (!$update) {
- return parent::cleanChanges($path, $update, $package);
+ return parent::cleanChanges($package, $path, $update);
}
return $this->stashChanges($path);
}
- return parent::cleanChanges($path, $update, $package);
+ return parent::cleanChanges($package, $path, $update);
}
$changes = array_map(function ($elem) {
diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php
index 011b401a7..ed3fd74d9 100644
--- a/src/Composer/Downloader/HgDownloader.php
+++ b/src/Composer/Downloader/HgDownloader.php
@@ -59,7 +59,7 @@ class HgDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
- public function getLocalChanges($path, PackageInterface $package)
+ public function getLocalChanges(PackageInterface $package, $path)
{
if (!is_dir($path.'/.hg')) {
return;
diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php
index 4fca4949a..ec789c92a 100644
--- a/src/Composer/Downloader/SvnDownloader.php
+++ b/src/Composer/Downloader/SvnDownloader.php
@@ -52,7 +52,7 @@ class SvnDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
- public function getLocalChanges($path, PackageInterface $package)
+ public function getLocalChanges(PackageInterface $package, $path)
{
if (!is_dir($path.'/.svn')) {
return;
@@ -90,9 +90,9 @@ class SvnDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
- protected function cleanChanges($path, $update, $package)
+ protected function cleanChanges(PackageInterface $package, $path, $update)
{
- if (!$changes = $this->getLocalChanges($path, $package)) {
+ if (!$changes = $this->getLocalChanges($package, $path)) {
return;
}
@@ -101,7 +101,7 @@ class SvnDownloader extends VcsDownloader
return $this->discardChanges($path);
}
- return parent::cleanChanges($path, $update, $package);
+ return parent::cleanChanges($package, $path, $update);
}
$changes = array_map(function ($elem) {
diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php
index 7adfbb65d..d3253d956 100644
--- a/src/Composer/Downloader/VcsDownloader.php
+++ b/src/Composer/Downloader/VcsDownloader.php
@@ -86,7 +86,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
$this->io->write(" - Updating " . $name . " (" . $from . " => " . $to . ")");
- $this->cleanChanges($path, true, $initial);
+ $this->cleanChanges($initial, $path, true);
try {
$this->doUpdate($initial, $target, $path);
} catch (\Exception $e) {
@@ -126,7 +126,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
public function remove(PackageInterface $package, $path)
{
$this->io->write(" - Removing " . $package->getName() . " (" . $package->getPrettyVersion() . ")");
- $this->cleanChanges($path, false, $package);
+ $this->cleanChanges($package, $path, false);
if (!$this->filesystem->removeDirectory($path)) {
// retry after a bit on windows since it tends to be touchy with mass removals
if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(250) && !$this->filesystem->removeDirectory($path))) {
@@ -144,19 +144,19 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
return $this;
}
- /**
- * Prompt the user to check if changes should be stashed/removed or the operation aborted
- *
- * @param string $path
- * @param bool $update if true (update) the changes can be stashed and reapplied after an update,
- * if false (remove) the changes should be assumed to be lost if the operation is not aborted
- * @param PackageInterface $package
- * @throws \RuntimeException in case the operation must be aborted
- */
- protected function cleanChanges($path, $update, $package)
+ /**
+ * Prompt the user to check if changes should be stashed/removed or the operation aborted
+ *
+ * @param PackageInterface $package
+ * @param string $path
+ * @param bool $update if true (update) the changes can be stashed and reapplied after an update,
+ * if false (remove) the changes should be assumed to be lost if the operation is not aborted
+ * @throws \RuntimeException in case the operation must be aborted
+ */
+ protected function cleanChanges(PackageInterface $package, $path, $update)
{
// the default implementation just fails if there are any changes, override in child classes to provide stash-ability
- if (null !== $this->getLocalChanges($path, $package)) {
+ if (null !== $this->getLocalChanges($package, $path)) {
throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
}
}