original_string: public function describe_file_types($types) {
  
          $descriptions = [];
          $types = $this->normalize_file_types($types);
  
          foreach ($types as $type) {
              if ($type === '*') {
                  $desc = get_string('filetypesany', 'core_form');
                  $descriptions[$desc] = [];
              } else if ($group = $this->is_filetype_group($type)) {
                  $desc = $this->get_group_description($type);
                  $descriptions[$desc] = $group->extensions;
  
              } else if ($this->looks_like_mimetype($type)) {
                  $desc = get_mimetype_description($type);
                  $descriptions[$desc] = file_get_typegroup('extension', [$type]);
  
              } else {
                  $desc = get_mimetype_description(['filename' => 'fakefile'.$type]);
                  if (isset($descriptions[$desc])) {
                      $descriptions[$desc][] = $type;
                  } else {
                      $descriptions[$desc] = [$type];
                  }
              }
          }
  
          $data = [];
  
          foreach ($descriptions as $desc => $exts) {
              sort($exts);
              $data[] = (object)[
                  'description' => $desc,
                  'extensions' => join(' ', $exts),
              ];
          }
  
          core_collator::asort_objects_by_property($data, 'description', core_collator::SORT_NATURAL);
  
          return (object)[
              'hasdescriptions' => !empty($data),
              'descriptions' => array_values($data),
          ];
      }
code: public function describe_file_types($types) {
  
          $descriptions = [];
          $types = $this->normalize_file_types($types);
  
          foreach ($types as $type) {
              if ($type === '*') {
                  $desc = get_string('filetypesany', 'core_form');
                  $descriptions[$desc] = [];
              } else if ($group = $this->is_filetype_group($type)) {
                  $desc = $this->get_group_description($type);
                  $descriptions[$desc] = $group->extensions;
  
              } else if ($this->looks_like_mimetype($type)) {
                  $desc = get_mimetype_description($type);
                  $descriptions[$desc] = file_get_typegroup('extension', [$type]);
  
              } else {
                  $desc = get_mimetype_description(['filename' => 'fakefile'.$type]);
                  if (isset($descriptions[$desc])) {
                      $descriptions[$desc][] = $type;
                  } else {
                      $descriptions[$desc] = [$type];
                  }
              }
          }
  
          $data = [];
  
          foreach ($descriptions as $desc => $exts) {
              sort($exts);
              $data[] = (object)[
                  'description' => $desc,
                  'extensions' => join(' ', $exts),
              ];
          }
  
          core_collator::asort_objects_by_property($data, 'description', core_collator::SORT_NATURAL);
  
          return (object)[
              'hasdescriptions' => !empty($data),
              'descriptions' => array_values($data),
          ];
      }
code_tokens: public function describe_file_types ( $ types ) { $ descriptions = [ ] ; $ types = $ this -> normalize_file_types ( $ types ) ; foreach ( $ types as $ type ) { if ( $ type === '*' ) { $ desc = get_string ( 'filetypesany' , 'core_form' ) ; $ descriptions [ $ desc ] = [ ] ; } else if ( $ group = $ this -> is_filetype_group ( $ type ) ) { $ desc = $ this -> get_group_description ( $ type ) ; $ descriptions [ $ desc ] = $ group -> extensions ; } else if ( $ this -> looks_like_mimetype ( $ type ) ) { $ desc = get_mimetype_description ( $ type ) ; $ descriptions [ $ desc ] = file_get_typegroup ( 'extension' , [ $ type ] ) ; } else { $ desc = get_mimetype_description ( [ 'filename' => 'fakefile' . $ type ] ) ; if ( isset ( $ descriptions [ $ desc ] ) ) { $ descriptions [ $ desc ] [ ] = $ type ; } else { $ descriptions [ $ desc ] = [ $ type ] ; } } } $ data = [ ] ; foreach ( $ descriptions as $ desc => $ exts ) { sort ( $ exts ) ; $ data [ ] = ( object ) [ 'description' => $ desc , 'extensions' => join ( ' ' , $ exts ) , ] ; } core_collator :: asort_objects_by_property ( $ data , 'description' , core_collator :: SORT_NATURAL ) ; return ( object ) [ 'hasdescriptions' => ! empty ( $ data ) , 'descriptions' => array_values ( $ data ) , ] ; }
docstring: Describe the list of file types for human user.
  
  Given the list of file types, return a list of human readable
  descriptive names of relevant groups, types or file formats.
  
  @param string|array $types
  @return object
docstring_tokens: Describe the list of file types for human user .