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

Breadcrumb

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

function PoolOptimizer::calculateDependencyHash

1 call to PoolOptimizer::calculateDependencyHash()
PoolOptimizer::optimizeByIdenticalDependencies in vendor/composer/composer/src/Composer/DependencyResolver/PoolOptimizer.php

File

vendor/composer/composer/src/Composer/DependencyResolver/PoolOptimizer.php, line 263

Class

PoolOptimizer
Optimizes a given pool

Namespace

Composer\DependencyResolver

Code

private function calculateDependencyHash(BasePackage $package) : string {
    $hash = '';
    $hashRelevantLinks = [
        'requires' => $package->getRequires(),
        'conflicts' => $package->getConflicts(),
        'replaces' => $package->getReplaces(),
        'provides' => $package->getProvides(),
    ];
    foreach ($hashRelevantLinks as $key => $links) {
        if (0 === \count($links)) {
            continue;
        }
        // start new hash section
        $hash .= $key . ':';
        $subhash = [];
        foreach ($links as $link) {
            // To get the best dependency hash matches we should use Intervals::compactConstraint() here.
            // However, the majority of projects are going to specify their constraints already pretty
            // much in the best variant possible. In other words, we'd be wasting time here and it would actually hurt
            // performance more than the additional few packages that could be filtered out would benefit the process.
            $subhash[$link->getTarget()] = (string) $link->getConstraint();
        }
        // Sort for best result
        ksort($subhash);
        foreach ($subhash as $target => $constraint) {
            $hash .= $target . '@' . $constraint;
        }
    }
    return $hash;
}

API Navigation

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