src/Tools/ComposerHelperTrait.php
protected function mergeComposerJsonFiles(string $composer_file, \stdClass $original_composer, \stdClass $new_composer, callable $callback = NULL) {
    $new_composer = $this->mergeComposerObjects($original_composer, $new_composer, $callback);
    $composer_content = file_get_contents($composer_file);
    $replace_composer = json_decode($composer_content);
    $changes = $this->calculateRequirementChanges($replace_composer, $new_composer);
    if (file_put_contents($composer_file, json_encode($new_composer, JSON_PRETTY_PRINT)) !== FALSE) {
      return $changes;
    }
  }
protected function mergeComposerJsonFiles(string $composer_file, \stdClass $original_composer, \stdClass $new_composer, callable $callback = NULL) {
    $new_composer = $this->mergeComposerObjects($original_composer, $new_composer, $callback);
    $composer_content = file_get_contents($composer_file);
    $replace_composer = json_decode($composer_content);
    $changes = $this->calculateRequirementChanges($replace_composer, $new_composer);
    if (file_put_contents($composer_file, json_encode($new_composer, JSON_PRETTY_PRINT)) !== FALSE) {
      return $changes;
    }
  }
protected function mergeComposerJsonFiles ( string $ composer_file , \ stdClass $ original_composer , \ stdClass $ new_composer , callable $ callback = NULL ) { $ new_composer = $ this -> mergeComposerObjects ( $ original_composer , $ new_composer , $ callback ) ; $ composer_content = file_get_contents ( $ composer_file ) ; $ replace_composer = json_decode ( $ composer_content ) ; $ changes = $ this -> calculateRequirementChanges ( $ replace_composer , $ new_composer ) ; if ( file_put_contents ( $ composer_file , json_encode ( $ new_composer , JSON_PRETTY_PRINT ) ) !== FALSE ) { return $ changes ; } }
Merges the original composer file with a new composer file.

This ensures that the composer.json file that is going to be installed
will have all the appropriate requirements documented by the git
repository that is kept up to date by the client.

@param string $composer_file
The absolute path to the composer file to write.
@param \stdClass $original_composer
The original composer.json file before it was removed as a php object.
@param \stdClass $new_composer
The new composer.json file as a php object.
@param callable $callback
A callback if necessary to customize the composer object further.

@return array
Merges the original composer file with a new composer file .