original_string: protected function updateComposerJson(array $requires, array $devRequires, int $type): void
      {
          $this->io->writeError('Updating composer.json');
  
          if ($type === self::ADD) {
              $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath()));
              $sortPackages    = $this->composer->getConfig()->get('sort-packages') ?? false;
  
              foreach ($requires as $name => $version) {
                  $jsonManipulator->addLink('require', $name, $version, $sortPackages);
              }
  
              foreach ($devRequires as $name => $version) {
                  $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages);
              }
  
              \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents());
          } elseif ($type === self::REMOVE) {
              $jsonFileContent = $this->jsonFile->read();
  
              foreach ($requires as $packageName => $version) {
                  unset($jsonFileContent['require'][$packageName]);
              }
  
              foreach ($devRequires as $packageName => $version) {
                  unset($jsonFileContent['require-dev'][$packageName]);
              }
  
              $this->jsonFile->write($jsonFileContent);
          }
      }
code: protected function updateComposerJson(array $requires, array $devRequires, int $type): void
      {
          $this->io->writeError('Updating composer.json');
  
          if ($type === self::ADD) {
              $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath()));
              $sortPackages    = $this->composer->getConfig()->get('sort-packages') ?? false;
  
              foreach ($requires as $name => $version) {
                  $jsonManipulator->addLink('require', $name, $version, $sortPackages);
              }
  
              foreach ($devRequires as $name => $version) {
                  $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages);
              }
  
              \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents());
          } elseif ($type === self::REMOVE) {
              $jsonFileContent = $this->jsonFile->read();
  
              foreach ($requires as $packageName => $version) {
                  unset($jsonFileContent['require'][$packageName]);
              }
  
              foreach ($devRequires as $packageName => $version) {
                  unset($jsonFileContent['require-dev'][$packageName]);
              }
  
              $this->jsonFile->write($jsonFileContent);
          }
      }
code_tokens: protected function updateComposerJson ( array $ requires , array $ devRequires , int $ type ) : void { $ this -> io -> writeError ( 'Updating composer.json' ) ; if ( $ type === self :: ADD ) { $ jsonManipulator = new JsonManipulator ( \ file_get_contents ( $ this -> jsonFile -> getPath ( ) ) ) ; $ sortPackages = $ this -> composer -> getConfig ( ) -> get ( 'sort-packages' ) ?? false ; foreach ( $ requires as $ name => $ version ) { $ jsonManipulator -> addLink ( 'require' , $ name , $ version , $ sortPackages ) ; } foreach ( $ devRequires as $ name => $ version ) { $ jsonManipulator -> addLink ( 'require-dev' , $ name , $ version , $ sortPackages ) ; } \ file_put_contents ( $ this -> jsonFile -> getPath ( ) , $ jsonManipulator -> getContents ( ) ) ; } elseif ( $ type === self :: REMOVE ) { $ jsonFileContent = $ this -> jsonFile -> read ( ) ; foreach ( $ requires as $ packageName => $ version ) { unset ( $ jsonFileContent [ 'require' ] [ $ packageName ] ) ; } foreach ( $ devRequires as $ packageName => $ version ) { unset ( $ jsonFileContent [ 'require-dev' ] [ $ packageName ] ) ; } $ this -> jsonFile -> write ( $ jsonFileContent ) ; } }
docstring: Manipulate root composer.json with the new packages and dump it.
  
  @param array $requires
  @param array $devRequires
  @param int   $type
  
  @throws \Exception happens in the JsonFile class
  
  @return void
docstring_tokens: Manipulate root composer . json with the new packages and dump it .