original_string: public function dumpChanges($header = '')
      {
          $userSettingsFile = $this->getUserSettingsFile();
  
          $defaultSettings = $this->getMergedDefaultSettings();
          $existingMutableSettings = $this->settingsChain[$userSettingsFile];
  
          $dirty = false;
  
          $configToWrite = array();
          foreach ($this->mergedSettings as $sectionName => $changedSection) {
              if(isset($existingMutableSettings[$sectionName])){
                  $existingMutableSection = $existingMutableSettings[$sectionName];
              } else{
                  $existingMutableSection = array();
              }
  
              // remove default values from both (they should not get written to local)
              if (isset($defaultSettings[$sectionName])) {
                  $changedSection = $this->arrayUnmerge($defaultSettings[$sectionName], $changedSection);
                  $existingMutableSection = $this->arrayUnmerge($defaultSettings[$sectionName], $existingMutableSection);
              }
  
              // if either local/config have non-default values and the other doesn't,
              // OR both have values, but different values, we must write to config.ini.php
              if (empty($changedSection) xor empty($existingMutableSection)
                  || (!empty($changedSection)
                      && !empty($existingMutableSection)
                      && self::compareElements($changedSection, $existingMutableSection))
              ) {
                  $dirty = true;
              }
  
              $configToWrite[$sectionName] = $changedSection;
          }
  
          if ($dirty) {
              // sort config sections by how early they appear in the file chain
              $self = $this;
              uksort($configToWrite, function ($sectionNameLhs, $sectionNameRhs) use ($self) {
                  $lhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameLhs);
                  $rhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameRhs);
  
                  if ($lhsIndex == $rhsIndex) {
                      $lhsIndexInFile = $self->getIndexOfSectionInFile($lhsIndex, $sectionNameLhs);
                      $rhsIndexInFile = $self->getIndexOfSectionInFile($rhsIndex, $sectionNameRhs);
  
                      if ($lhsIndexInFile == $rhsIndexInFile) {
                          return 0;
                      } elseif ($lhsIndexInFile < $rhsIndexInFile) {
                          return -1;
                      } else {
                          return 1;
                      }
                  } elseif ($lhsIndex < $rhsIndex) {
                      return -1;
                  } else {
                      return 1;
                  }
              });
  
              return $this->dumpSettings($configToWrite, $header);
          } else {
              return null;
          }
      }
code: public function dumpChanges($header = '')
      {
          $userSettingsFile = $this->getUserSettingsFile();
  
          $defaultSettings = $this->getMergedDefaultSettings();
          $existingMutableSettings = $this->settingsChain[$userSettingsFile];
  
          $dirty = false;
  
          $configToWrite = array();
          foreach ($this->mergedSettings as $sectionName => $changedSection) {
              if(isset($existingMutableSettings[$sectionName])){
                  $existingMutableSection = $existingMutableSettings[$sectionName];
              } else{
                  $existingMutableSection = array();
              }
  
              // remove default values from both (they should not get written to local)
              if (isset($defaultSettings[$sectionName])) {
                  $changedSection = $this->arrayUnmerge($defaultSettings[$sectionName], $changedSection);
                  $existingMutableSection = $this->arrayUnmerge($defaultSettings[$sectionName], $existingMutableSection);
              }
  
              // if either local/config have non-default values and the other doesn't,
              // OR both have values, but different values, we must write to config.ini.php
              if (empty($changedSection) xor empty($existingMutableSection)
                  || (!empty($changedSection)
                      && !empty($existingMutableSection)
                      && self::compareElements($changedSection, $existingMutableSection))
              ) {
                  $dirty = true;
              }
  
              $configToWrite[$sectionName] = $changedSection;
          }
  
          if ($dirty) {
              // sort config sections by how early they appear in the file chain
              $self = $this;
              uksort($configToWrite, function ($sectionNameLhs, $sectionNameRhs) use ($self) {
                  $lhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameLhs);
                  $rhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameRhs);
  
                  if ($lhsIndex == $rhsIndex) {
                      $lhsIndexInFile = $self->getIndexOfSectionInFile($lhsIndex, $sectionNameLhs);
                      $rhsIndexInFile = $self->getIndexOfSectionInFile($rhsIndex, $sectionNameRhs);
  
                      if ($lhsIndexInFile == $rhsIndexInFile) {
                          return 0;
                      } elseif ($lhsIndexInFile < $rhsIndexInFile) {
                          return -1;
                      } else {
                          return 1;
                      }
                  } elseif ($lhsIndex < $rhsIndex) {
                      return -1;
                  } else {
                      return 1;
                  }
              });
  
              return $this->dumpSettings($configToWrite, $header);
          } else {
              return null;
          }
      }
code_tokens: public function dumpChanges ( $ header = '' ) { $ userSettingsFile = $ this -> getUserSettingsFile ( ) ; $ defaultSettings = $ this -> getMergedDefaultSettings ( ) ; $ existingMutableSettings = $ this -> settingsChain [ $ userSettingsFile ] ; $ dirty = false ; $ configToWrite = array ( ) ; foreach ( $ this -> mergedSettings as $ sectionName => $ changedSection ) { if ( isset ( $ existingMutableSettings [ $ sectionName ] ) ) { $ existingMutableSection = $ existingMutableSettings [ $ sectionName ] ; } else { $ existingMutableSection = array ( ) ; } // remove default values from both (they should not get written to local) if ( isset ( $ defaultSettings [ $ sectionName ] ) ) { $ changedSection = $ this -> arrayUnmerge ( $ defaultSettings [ $ sectionName ] , $ changedSection ) ; $ existingMutableSection = $ this -> arrayUnmerge ( $ defaultSettings [ $ sectionName ] , $ existingMutableSection ) ; } // if either local/config have non-default values and the other doesn't, // OR both have values, but different values, we must write to config.ini.php if ( empty ( $ changedSection ) xor empty ( $ existingMutableSection ) || ( ! empty ( $ changedSection ) && ! empty ( $ existingMutableSection ) && self :: compareElements ( $ changedSection , $ existingMutableSection ) ) ) { $ dirty = true ; } $ configToWrite [ $ sectionName ] = $ changedSection ; } if ( $ dirty ) { // sort config sections by how early they appear in the file chain $ self = $ this ; uksort ( $ configToWrite , function ( $ sectionNameLhs , $ sectionNameRhs ) use ( $ self ) { $ lhsIndex = $ self -> findIndexOfFirstFileWithSection ( $ sectionNameLhs ) ; $ rhsIndex = $ self -> findIndexOfFirstFileWithSection ( $ sectionNameRhs ) ; if ( $ lhsIndex == $ rhsIndex ) { $ lhsIndexInFile = $ self -> getIndexOfSectionInFile ( $ lhsIndex , $ sectionNameLhs ) ; $ rhsIndexInFile = $ self -> getIndexOfSectionInFile ( $ rhsIndex , $ sectionNameRhs ) ; if ( $ lhsIndexInFile == $ rhsIndexInFile ) { return 0 ; } elseif ( $ lhsIndexInFile < $ rhsIndexInFile ) { return - 1 ; } else { return 1 ; } } elseif ( $ lhsIndex < $ rhsIndex ) { return - 1 ; } else { return 1 ; } } ) ; return $ this -> dumpSettings ( $ configToWrite , $ header ) ; } else { return null ; } }
docstring: Writes the difference of the in-memory setting values and the on-disk user settings file setting
  values to a string in INI format, and returns it.
  
  If a config section is identical to the default settings section (as computed by merging
  all default setting files), it is not written to the user settings file.
  
  @param string $header The header of the INI output.
  @return string The dumped INI contents.
docstring_tokens: Writes the difference of the in - memory setting values and the on - disk user settings file setting values to a string in INI format and returns it .