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

Breadcrumb

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

function RequireCommand::updateFileCleanly

Parameters

array<string, string> $new:

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

File

vendor/composer/composer/src/Composer/Command/RequireCommand.php, line 595

Class

RequireCommand
@author Jérémy Romey <jeremy@free-agent.fr> @author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Command

Code

private function updateFileCleanly(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages) : bool {
    $contents = file_get_contents($json->getPath());
    $manipulator = new JsonManipulator($contents);
    foreach ($new as $package => $constraint) {
        if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
            return false;
        }
        if (!$manipulator->removeSubNode($removeKey, $package)) {
            return false;
        }
    }
    $manipulator->removeMainKeyIfEmpty($removeKey);
    file_put_contents($json->getPath(), $manipulator->getContents());
    return true;
}

API Navigation

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