Skip to content
Snippets Groups Projects

Issue #3261847: Add helpful methods to compute the difference between two ComposerUtility objects

Merged Issue #3261847: Add helpful methods to compute the difference between two ComposerUtility objects
All threads resolved!
All threads resolved!
3 files
+ 22
37
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -155,48 +155,34 @@ class ComposerUtility {
}
/**
* Returns the packages added in another directory.
* Returns the packages that are in the current project, but not in another.
*
* @param self $that
* @param self $other
* A Composer utility wrapper around a different directory.
*
* @return \Composer\Package\PackageInterface[]
* The packages that were added in the other directory, keyed by name.
* The packages which are installed in the current project, but not in the
* other one, keyed by name.
*/
public function getPackagesAddedBy(self $that): array {
// Return the packages that are there, but not here.
return array_diff_key($that->getInstalledPackages(), $this->getInstalledPackages());
public function getPackagesNotIn(self $other): array {
return array_diff_key($this->getInstalledPackages(), $other->getInstalledPackages());
}
/**
* Returns the packages that were removed in another directory.
* Returns the packages which have a different version in another project.
*
* @param self $that
* A Composer utility wrapper around a different directory.
*
* @return \Composer\Package\PackageInterface[]
* The packages that were removed in the other directory, keyed by name.
*/
public function getPackagesRemovedBy(self $that): array {
// Return the packages that are here, but not there.
return array_diff_key($this->getInstalledPackages(), $that->getInstalledPackages());
}
/**
* Returns the packages that were updated in another directory.
*
* A package will be considered "updated" if its version in the other
* directory has changed *at all*.
* This compares the current project with another one, and returns packages
* which are present in both, but in different versions.
*
* @param self $that
* @param self $other
* A Composer utility wrapper around a different directory.
*
* @return \Composer\Package\PackageInterface[]
* The packages in the current directory that were updated in the other
* directory, keyed by name.
* The packages which are present in both the current project and the other
* one, but in different versions, keyed by name.
*/
public function getPackagesUpdatedBy(self $that): array {
$theirs = $that->getInstalledPackages();
public function getPackagesWithDifferentVersionsIn(self $other): array {
$theirs = $other->getInstalledPackages();
// Only compare packages that are both here and there.
$packages = array_intersect_key($this->getInstalledPackages(), $theirs);
Loading