original_string: protected function writeTwoPhases(string $filename, string $data): void
    {
      $write_flag = true;
      if (file_exists($filename))
      {
        $old_data = file_get_contents($filename);
        if ($data==$old_data) $write_flag = false;
      }
  
      if ($write_flag)
      {
        $tmp_filename = $filename.'.tmp';
        file_put_contents($tmp_filename, $data);
        rename($tmp_filename, $filename);
  
        $this->io->text(sprintf('Wrote <fso>%s</fso>', OutputFormatter::escape($filename)));
      }
      else
      {
        $this->io->text(sprintf('File <fso>%s</fso> is up to date', OutputFormatter::escape($filename)));
      }
    }
code: protected function writeTwoPhases(string $filename, string $data): void
    {
      $write_flag = true;
      if (file_exists($filename))
      {
        $old_data = file_get_contents($filename);
        if ($data==$old_data) $write_flag = false;
      }
  
      if ($write_flag)
      {
        $tmp_filename = $filename.'.tmp';
        file_put_contents($tmp_filename, $data);
        rename($tmp_filename, $filename);
  
        $this->io->text(sprintf('Wrote <fso>%s</fso>', OutputFormatter::escape($filename)));
      }
      else
      {
        $this->io->text(sprintf('File <fso>%s</fso> is up to date', OutputFormatter::escape($filename)));
      }
    }
code_tokens: protected function writeTwoPhases ( string $ filename , string $ data ) : void { $ write_flag = true ; if ( file_exists ( $ filename ) ) { $ old_data = file_get_contents ( $ filename ) ; if ( $ data == $ old_data ) $ write_flag = false ; } if ( $ write_flag ) { $ tmp_filename = $ filename . '.tmp' ; file_put_contents ( $ tmp_filename , $ data ) ; rename ( $ tmp_filename , $ filename ) ; $ this -> io -> text ( sprintf ( 'Wrote <fso>%s</fso>' , OutputFormatter :: escape ( $ filename ) ) ) ; } else { $ this -> io -> text ( sprintf ( 'File <fso>%s</fso> is up to date' , OutputFormatter :: escape ( $ filename ) ) ) ; } }
docstring: Writes a file in two phase to the filesystem.
  
  First write the data to a temporary file (in the same directory) and than renames the temporary file. If the file
  already exists and its content is equal to the data that must be written no action  is taken. This has the
  following advantages:
  * In case of some write error (e.g. disk full) the original file is kept in tact and no file with partially data
  is written.
  * Renaming a file is atomic. So, running processes will never read a partially written data.
  
  @param string $filename The name of the file were the data must be stored.
  @param string $data     The data that must be written.
docstring_tokens: Writes a file in two phase to the filesystem .