original_string: public static function get_all($options = []) {
          global $DB;
  
          $coursecatrecordcache = cache::make('core', 'coursecatrecords');
  
          $catcontextsql = \context_helper::get_preload_record_columns_sql('ctx');
          $catsql = "SELECT cc.*, {$catcontextsql}
                       FROM {course_categories} cc
                       JOIN {context} ctx ON cc.id = ctx.instanceid";
          $catsqlwhere = "WHERE ctx.contextlevel = :contextlevel";
          $catsqlorder = "ORDER BY cc.depth ASC, cc.sortorder ASC";
  
          $catrs = $DB->get_recordset_sql("{$catsql} {$catsqlwhere} {$catsqlorder}", [
              'contextlevel' => CONTEXT_COURSECAT,
          ]);
  
          $types['categories'] = [];
          $categories = [];
          $toset = [];
          foreach ($catrs as $record) {
              $category = new self($record);
              $toset[$category->id] = $category;
  
              if (!empty($options['returnhidden']) || $category->is_uservisible()) {
                  $categories[$record->id] = $category;
              }
          }
          $catrs->close();
  
          $coursecatrecordcache->set_many($toset);
  
          return $categories;
  
      }
code: public static function get_all($options = []) {
          global $DB;
  
          $coursecatrecordcache = cache::make('core', 'coursecatrecords');
  
          $catcontextsql = \context_helper::get_preload_record_columns_sql('ctx');
          $catsql = "SELECT cc.*, {$catcontextsql}
                       FROM {course_categories} cc
                       JOIN {context} ctx ON cc.id = ctx.instanceid";
          $catsqlwhere = "WHERE ctx.contextlevel = :contextlevel";
          $catsqlorder = "ORDER BY cc.depth ASC, cc.sortorder ASC";
  
          $catrs = $DB->get_recordset_sql("{$catsql} {$catsqlwhere} {$catsqlorder}", [
              'contextlevel' => CONTEXT_COURSECAT,
          ]);
  
          $types['categories'] = [];
          $categories = [];
          $toset = [];
          foreach ($catrs as $record) {
              $category = new self($record);
              $toset[$category->id] = $category;
  
              if (!empty($options['returnhidden']) || $category->is_uservisible()) {
                  $categories[$record->id] = $category;
              }
          }
          $catrs->close();
  
          $coursecatrecordcache->set_many($toset);
  
          return $categories;
  
      }
code_tokens: public static function get_all ( $ options = [ ] ) { global $ DB ; $ coursecatrecordcache = cache :: make ( 'core' , 'coursecatrecords' ) ; $ catcontextsql = \ context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ catsql = "SELECT cc.*, {$catcontextsql}
                       FROM {course_categories} cc
                       JOIN {context} ctx ON cc.id = ctx.instanceid" ; $ catsqlwhere = "WHERE ctx.contextlevel = :contextlevel" ; $ catsqlorder = "ORDER BY cc.depth ASC, cc.sortorder ASC" ; $ catrs = $ DB -> get_recordset_sql ( "{$catsql} {$catsqlwhere} {$catsqlorder}" , [ 'contextlevel' => CONTEXT_COURSECAT , ] ) ; $ types [ 'categories' ] = [ ] ; $ categories = [ ] ; $ toset = [ ] ; foreach ( $ catrs as $ record ) { $ category = new self ( $ record ) ; $ toset [ $ category -> id ] = $ category ; if ( ! empty ( $ options [ 'returnhidden' ] ) || $ category -> is_uservisible ( ) ) { $ categories [ $ record -> id ] = $ category ; } } $ catrs -> close ( ) ; $ coursecatrecordcache -> set_many ( $ toset ) ; return $ categories ; }
docstring: Load all core_course_category objects.
  
  @param array $options Options:
  - returnhidden Return categories even if they are hidden
  @return  core_course_category[]
docstring_tokens: Load all core_course_category objects .