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\CommandCode
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;
}