Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Transaction.php

function Transaction::setResultPackageMaps

Parameters

PackageInterface[] $resultPackages:

1 call to Transaction::setResultPackageMaps()
Transaction::__construct in vendor/composer/composer/src/Composer/DependencyResolver/Transaction.php

File

vendor/composer/composer/src/Composer/DependencyResolver/Transaction.php, line 71

Class

Transaction
@author Nils Adermann <naderman@naderman.de> @internal

Namespace

Composer\DependencyResolver

Code

private function setResultPackageMaps(array $resultPackages) : void {
    $packageSort = static function (PackageInterface $a, PackageInterface $b) : int {
        // sort alias packages by the same name behind their non alias version
        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());
    };
    $this->resultPackageMap = [];
    foreach ($resultPackages as $package) {
        $this->resultPackageMap[spl_object_hash($package)] = $package;
        foreach ($package->getNames() as $name) {
            $this->resultPackagesByName[$name][] = $package;
        }
    }
    uasort($this->resultPackageMap, $packageSort);
    foreach ($this->resultPackagesByName as $name => $packages) {
        uasort($this->resultPackagesByName[$name], $packageSort);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal