Browse Source

Merge pull request #802 from stof/lock_sorting

Made the order of aliases deterministic in the locker
Jordi Boggiano 12 years ago
parent
commit
94791aba73
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/Composer/Package/Locker.php

+ 11 - 1
src/Composer/Package/Locker.php

@@ -234,7 +234,17 @@ class Locker
         }
 
         usort($locked, function ($a, $b) {
-            return strcmp($a['package'], $b['package']);
+            $comparison = strcmp($a['package'], $b['package']);
+
+            if (0 !== $comparison) {
+                return $comparison;
+            }
+
+            // If it is the same package, compare the versions to make the order deterministic
+            $aVersion = isset($a['alias-version']) ? $a['alias-version'] : $a['version'];
+            $bVersion = isset($b['alias-version']) ? $b['alias-version'] : $b['version'];
+
+            return strcmp($aVersion, $bVersion);
         });
 
         return $locked;