original_string: public function recursiveCopy(
          $sourceDir,
          $destDir,
          $extensions = array('php')
      ) {
          if (!realpath($sourceDir)) {
              throw new \InvalidArgumentException("$sourceDir not found");
          }
  
          if (!$extensions) {
              throw new \InvalidArgumentException('$extensions is empty!');
          }
  
          $sourceDir = realpath($sourceDir);
          $exts = array_fill_keys($extensions, true);
          $iter = new \RecursiveDirectoryIterator($sourceDir);
          $iter = new \RecursiveIteratorIterator($iter);
          $total = 0;
  
          $this->startSection('copy');
          $this->debug("Starting to copy files from $sourceDir");
  
          foreach ($iter as $file) {
              if (isset($exts[$file->getExtension()])
                  || $file->getBaseName() == 'LICENSE'
              ) {
                  // Remove the source directory from the destination path
                  $toPath = str_replace($sourceDir, '', (string) $file);
                  $toPath = $destDir . '/' . $toPath;
                  $toPath = str_replace('//', '/', $toPath);
                  $this->deepCopy((string) $file, $toPath);
                  $total++;
              }
          }
  
          $this->debug("Copied $total files from $sourceDir");
          $this->endSection();
      }
code: public function recursiveCopy(
          $sourceDir,
          $destDir,
          $extensions = array('php')
      ) {
          if (!realpath($sourceDir)) {
              throw new \InvalidArgumentException("$sourceDir not found");
          }
  
          if (!$extensions) {
              throw new \InvalidArgumentException('$extensions is empty!');
          }
  
          $sourceDir = realpath($sourceDir);
          $exts = array_fill_keys($extensions, true);
          $iter = new \RecursiveDirectoryIterator($sourceDir);
          $iter = new \RecursiveIteratorIterator($iter);
          $total = 0;
  
          $this->startSection('copy');
          $this->debug("Starting to copy files from $sourceDir");
  
          foreach ($iter as $file) {
              if (isset($exts[$file->getExtension()])
                  || $file->getBaseName() == 'LICENSE'
              ) {
                  // Remove the source directory from the destination path
                  $toPath = str_replace($sourceDir, '', (string) $file);
                  $toPath = $destDir . '/' . $toPath;
                  $toPath = str_replace('//', '/', $toPath);
                  $this->deepCopy((string) $file, $toPath);
                  $total++;
              }
          }
  
          $this->debug("Copied $total files from $sourceDir");
          $this->endSection();
      }
code_tokens: public function recursiveCopy ( $ sourceDir , $ destDir , $ extensions = array ( 'php' ) ) { if ( ! realpath ( $ sourceDir ) ) { throw new \ InvalidArgumentException ( "$sourceDir not found" ) ; } if ( ! $ extensions ) { throw new \ InvalidArgumentException ( '$extensions is empty!' ) ; } $ sourceDir = realpath ( $ sourceDir ) ; $ exts = array_fill_keys ( $ extensions , true ) ; $ iter = new \ RecursiveDirectoryIterator ( $ sourceDir ) ; $ iter = new \ RecursiveIteratorIterator ( $ iter ) ; $ total = 0 ; $ this -> startSection ( 'copy' ) ; $ this -> debug ( "Starting to copy files from $sourceDir" ) ; foreach ( $ iter as $ file ) { if ( isset ( $ exts [ $ file -> getExtension ( ) ] ) || $ file -> getBaseName ( ) == 'LICENSE' ) { // Remove the source directory from the destination path $ toPath = str_replace ( $ sourceDir , '' , ( string ) $ file ) ; $ toPath = $ destDir . '/' . $ toPath ; $ toPath = str_replace ( '//' , '/' , $ toPath ) ; $ this -> deepCopy ( ( string ) $ file , $ toPath ) ; $ total ++ ; } } $ this -> debug ( "Copied $total files from $sourceDir" ) ; $ this -> endSection ( ) ; }
docstring: Recursively copy one folder to another.
  
  Any LICENSE file is automatically copied.
  
  @param string $sourceDir  Source directory to copy from
  @param string $destDir    Directory to copy the files to that is relative
  to the the stage base directory.
  @param array  $extensions File extensions to copy from the $sourceDir.
  Defaults to "php" files only (e.g., ['php']).
  @throws \InvalidArgumentException if the source directory is invalid.
docstring_tokens: Recursively copy one folder to another .