Merge pull request #9285 from naderman/transaction-define-total-order-package-sort
Transaction: Define a total order on packages to keep behavior on PHP8pull/9223/head
commit
d8490ee38f
|
@ -61,8 +61,12 @@ class Transaction
|
|||
{
|
||||
$packageSort = function (PackageInterface $a, PackageInterface $b) {
|
||||
// sort alias packages by the same name behind their non alias version
|
||||
if ($a->getName() == $b->getName() && $a instanceof AliasPackage != $b instanceof AliasPackage) {
|
||||
return $a instanceof AliasPackage ? -1 : 1;
|
||||
if ($a->getName() == $b->getName()) {
|
||||
if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
|
||||
return $a instanceof AliasPackage ? -1 : 1;
|
||||
}
|
||||
// if names are the same, compare version, e.g. to sort aliases reliably, actual order does not matter
|
||||
return strcmp($b->getVersion(), $a->getVersion());
|
||||
}
|
||||
return strcmp($b->getName(), $a->getName());
|
||||
};
|
||||
|
|
|
@ -58,8 +58,8 @@ class TransactionTest extends TestCase
|
|||
array('job' => 'update', 'from' => $packageB, 'to' => $packageBnew),
|
||||
array('job' => 'install', 'package' => $packageG),
|
||||
array('job' => 'install', 'package' => $packageF),
|
||||
array('job' => 'markAliasInstalled', 'package' => $packageFalias1),
|
||||
array('job' => 'markAliasInstalled', 'package' => $packageFalias2),
|
||||
array('job' => 'markAliasInstalled', 'package' => $packageFalias1),
|
||||
array('job' => 'install', 'package' => $packageD),
|
||||
);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ Installing double aliased package
|
|||
install
|
||||
--EXPECT--
|
||||
Installing b/b (dev-foo)
|
||||
Marking b/b (dev-master) as installed, alias of b/b (dev-foo)
|
||||
Marking b/b (1.0.x-dev) as installed, alias of b/b (dev-foo)
|
||||
Marking b/b (dev-master) as installed, alias of b/b (dev-foo)
|
||||
Installing a/a (dev-master)
|
||||
Marking a/a (9999999-dev) as installed, alias of a/a (dev-master)
|
||||
|
|
Loading…
Reference in New Issue