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

Breadcrumb

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

function Locker::getContentHash

Returns the md5 hash of the sorted content of the composer file.

Parameters

string $composerFileContents The contents of the composer file.:

3 calls to Locker::getContentHash()
Locker::updateHash in vendor/composer/composer/src/Composer/Package/Locker.php
Updates the lock file's hash in-place from a given composer.json's JsonFile
Locker::__construct in vendor/composer/composer/src/Composer/Package/Locker.php
Initializes packages locker.
Plugin::updateComposerLock in vendor/php-http/discovery/src/Composer/Plugin.php

File

vendor/composer/composer/src/Composer/Package/Locker.php, line 89

Class

Locker
Reads/writes project lockfile (composer.lock).

Namespace

Composer\Package

Code

public static function getContentHash(string $composerFileContents) : string {
    $content = JsonFile::parseJson($composerFileContents, 'composer.json');
    $relevantKeys = [
        'name',
        'version',
        'require',
        'require-dev',
        'conflict',
        'replace',
        'provide',
        'minimum-stability',
        'prefer-stable',
        'repositories',
        'extra',
    ];
    $relevantContent = [];
    foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
        $relevantContent[$key] = $content[$key];
    }
    if (isset($content['config']['platform'])) {
        $relevantContent['config']['platform'] = $content['config']['platform'];
    }
    ksort($relevantContent);
    return hash('md5', JsonFile::encode($relevantContent, 0));
}

API Navigation

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