original_string: public function list_plugin_folder_files($folderpath) {
  
          $folder = new RecursiveDirectoryIterator($folderpath);
          $iterator = new RecursiveIteratorIterator($folder);
          $folderpathinfo = new SplFileInfo($folderpath);
          $strip = strlen($folderpathinfo->getPathInfo()->getRealPath()) + 1;
          $files = array();
          foreach ($iterator as $fileinfo) {
              if ($fileinfo->getFilename() === '..') {
                  continue;
              }
              if (strpos($fileinfo->getRealPath(), $folderpathinfo->getRealPath()) !== 0) {
                  throw new moodle_exception('unexpected_filepath_mismatch', 'core_plugin');
              }
              $key = substr($fileinfo->getRealPath(), $strip);
              if ($fileinfo->isDir() and substr($key, -1) !== '/') {
                  $key .= '/';
              }
              $files[str_replace(DIRECTORY_SEPARATOR, '/', $key)] = str_replace(DIRECTORY_SEPARATOR, '/', $fileinfo->getRealPath());
          }
          return $files;
      }
code: public function list_plugin_folder_files($folderpath) {
  
          $folder = new RecursiveDirectoryIterator($folderpath);
          $iterator = new RecursiveIteratorIterator($folder);
          $folderpathinfo = new SplFileInfo($folderpath);
          $strip = strlen($folderpathinfo->getPathInfo()->getRealPath()) + 1;
          $files = array();
          foreach ($iterator as $fileinfo) {
              if ($fileinfo->getFilename() === '..') {
                  continue;
              }
              if (strpos($fileinfo->getRealPath(), $folderpathinfo->getRealPath()) !== 0) {
                  throw new moodle_exception('unexpected_filepath_mismatch', 'core_plugin');
              }
              $key = substr($fileinfo->getRealPath(), $strip);
              if ($fileinfo->isDir() and substr($key, -1) !== '/') {
                  $key .= '/';
              }
              $files[str_replace(DIRECTORY_SEPARATOR, '/', $key)] = str_replace(DIRECTORY_SEPARATOR, '/', $fileinfo->getRealPath());
          }
          return $files;
      }
code_tokens: public function list_plugin_folder_files ( $ folderpath ) { $ folder = new RecursiveDirectoryIterator ( $ folderpath ) ; $ iterator = new RecursiveIteratorIterator ( $ folder ) ; $ folderpathinfo = new SplFileInfo ( $ folderpath ) ; $ strip = strlen ( $ folderpathinfo -> getPathInfo ( ) -> getRealPath ( ) ) + 1 ; $ files = array ( ) ; foreach ( $ iterator as $ fileinfo ) { if ( $ fileinfo -> getFilename ( ) === '..' ) { continue ; } if ( strpos ( $ fileinfo -> getRealPath ( ) , $ folderpathinfo -> getRealPath ( ) ) !== 0 ) { throw new moodle_exception ( 'unexpected_filepath_mismatch' , 'core_plugin' ) ; } $ key = substr ( $ fileinfo -> getRealPath ( ) , $ strip ) ; if ( $ fileinfo -> isDir ( ) and substr ( $ key , - 1 ) !== '/' ) { $ key .= '/' ; } $ files [ str_replace ( DIRECTORY_SEPARATOR , '/' , $ key ) ] = str_replace ( DIRECTORY_SEPARATOR , '/' , $ fileinfo -> getRealPath ( ) ) ; } return $ files ; }
docstring: Returns list of all files in the given directory.
  
  Given a path like /full/path/to/mod/workshop, it returns array like
  
  [workshop/] => /full/path/to/mod/workshop
  [workshop/lang/] => /full/path/to/mod/workshop/lang
  [workshop/lang/workshop.php] => /full/path/to/mod/workshop/lang/workshop.php
  ...
  
  Which mathes the format used by Moodle file packers.
  
  @param string $folderpath full path to the plugin directory
  @return array (string)relpath => (string)fullpath
docstring_tokens: Returns list of all files in the given directory .