original_string: public function createFile($path, $contents, $forceOverwrite = false)
      {
          $this->out();
          $forceOverwrite = $forceOverwrite || $this->forceOverwrite;
  
          if (file_exists($path) && $forceOverwrite === false) {
              $this->warning("File `{$path}` exists");
              $key = $this->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n');
              $key = strtolower($key);
  
              if ($key === 'q') {
                  $this->error('Quitting.', 2);
                  throw new StopException('Not creating file. Quitting.');
              }
              if ($key === 'a') {
                  $this->forceOverwrite = true;
                  $key = 'y';
              }
              if ($key !== 'y') {
                  $this->out("Skip `{$path}`", 2);
  
                  return false;
              }
          } else {
              $this->out("Creating file {$path}");
          }
  
          try {
              // Create the directory using the current user permissions.
              $directory = dirname($path);
              if (!file_exists($directory)) {
                  mkdir($directory, 0777 ^ umask(), true);
              }
  
              $file = new SplFileObject($path, 'w');
          } catch (RuntimeException $e) {
              $this->error("Could not write to `{$path}`. Permission denied.", 2);
  
              return false;
          }
  
          $file->rewind();
          if ($file->fwrite($contents) > 0) {
              $this->out("<success>Wrote</success> `{$path}`");
  
              return true;
          }
          $this->error("Could not write to `{$path}`.", 2);
  
          return false;
      }
code: public function createFile($path, $contents, $forceOverwrite = false)
      {
          $this->out();
          $forceOverwrite = $forceOverwrite || $this->forceOverwrite;
  
          if (file_exists($path) && $forceOverwrite === false) {
              $this->warning("File `{$path}` exists");
              $key = $this->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n');
              $key = strtolower($key);
  
              if ($key === 'q') {
                  $this->error('Quitting.', 2);
                  throw new StopException('Not creating file. Quitting.');
              }
              if ($key === 'a') {
                  $this->forceOverwrite = true;
                  $key = 'y';
              }
              if ($key !== 'y') {
                  $this->out("Skip `{$path}`", 2);
  
                  return false;
              }
          } else {
              $this->out("Creating file {$path}");
          }
  
          try {
              // Create the directory using the current user permissions.
              $directory = dirname($path);
              if (!file_exists($directory)) {
                  mkdir($directory, 0777 ^ umask(), true);
              }
  
              $file = new SplFileObject($path, 'w');
          } catch (RuntimeException $e) {
              $this->error("Could not write to `{$path}`. Permission denied.", 2);
  
              return false;
          }
  
          $file->rewind();
          if ($file->fwrite($contents) > 0) {
              $this->out("<success>Wrote</success> `{$path}`");
  
              return true;
          }
          $this->error("Could not write to `{$path}`.", 2);
  
          return false;
      }
code_tokens: public function createFile ( $ path , $ contents , $ forceOverwrite = false ) { $ this -> out ( ) ; $ forceOverwrite = $ forceOverwrite || $ this -> forceOverwrite ; if ( file_exists ( $ path ) && $ forceOverwrite === false ) { $ this -> warning ( "File `{$path}` exists" ) ; $ key = $ this -> askChoice ( 'Do you want to overwrite?' , [ 'y' , 'n' , 'a' , 'q' ] , 'n' ) ; $ key = strtolower ( $ key ) ; if ( $ key === 'q' ) { $ this -> error ( 'Quitting.' , 2 ) ; throw new StopException ( 'Not creating file. Quitting.' ) ; } if ( $ key === 'a' ) { $ this -> forceOverwrite = true ; $ key = 'y' ; } if ( $ key !== 'y' ) { $ this -> out ( "Skip `{$path}`" , 2 ) ; return false ; } } else { $ this -> out ( "Creating file {$path}" ) ; } try { // Create the directory using the current user permissions. $ directory = dirname ( $ path ) ; if ( ! file_exists ( $ directory ) ) { mkdir ( $ directory , 0777 ^ umask ( ) , true ) ; } $ file = new SplFileObject ( $ path , 'w' ) ; } catch ( RuntimeException $ e ) { $ this -> error ( "Could not write to `{$path}`. Permission denied." , 2 ) ; return false ; } $ file -> rewind ( ) ; if ( $ file -> fwrite ( $ contents ) > 0 ) { $ this -> out ( "<success>Wrote</success> `{$path}`" ) ; return true ; } $ this -> error ( "Could not write to `{$path}`." , 2 ) ; return false ; }
docstring: Create a file at the given path.
  
  This method will prompt the user if a file will be overwritten.
  Setting `forceOverwrite` to true will suppress this behavior
  and always overwrite the file.
  
  If the user replies `a` subsequent `forceOverwrite` parameters will
  be coerced to true and all files will be overwritten.
  
  @param string $path The path to create the file at.
  @param string $contents The contents to put into the file.
  @param bool $forceOverwrite Whether or not the file should be overwritten.
  If true, no question will be asked about whether or not to overwrite existing files.
  @return bool Success.
  @throws \Cake\Console\Exception\StopException When `q` is given as an answer
  to whether or not a file should be overwritten.
docstring_tokens: Create a file at the given path .