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

Breadcrumb

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

function BumpCommand::updateFileCleanly

Parameters

array<'require'|'require-dev', array<string, string>> $updates:

1 call to BumpCommand::updateFileCleanly()
BumpCommand::doBump in vendor/composer/composer/src/Composer/Command/BumpCommand.php

File

vendor/composer/composer/src/Composer/Command/BumpCommand.php, line 233

Class

BumpCommand
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Command

Code

private function updateFileCleanly(JsonFile $json, array $updates) : bool {
    $contents = file_get_contents($json->getPath());
    if (false === $contents) {
        throw new \RuntimeException('Unable to read ' . $json->getPath() . ' contents.');
    }
    $manipulator = new JsonManipulator($contents);
    foreach ($updates as $key => $packages) {
        foreach ($packages as $package => $version) {
            if (!$manipulator->addLink($key, $package, $version)) {
                return false;
            }
        }
    }
    if (false === file_put_contents($json->getPath(), $manipulator->getContents())) {
        throw new \RuntimeException('Unable to write new ' . $json->getPath() . ' contents.');
    }
    return true;
}

API Navigation

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