original_string: public static function get_site_categories() {
          global $DB;
  
          if (method_exists('\core_course_category', 'get_all')) {
              $categories = \core_course_category::get_all(['returnhidden' => true]);
          } else {
              // Fallback (to be removed once this gets integrated into master).
              $ids = $DB->get_fieldset_select('course_categories', 'id', '');
              $categories = \core_course_category::get_many($ids);
          }
  
          foreach ($categories as $key => $category) {
              if (!$category->is_uservisible()) {
                  unset($categories[$key]);
              }
          }
          return $categories;
      }
code: public static function get_site_categories() {
          global $DB;
  
          if (method_exists('\core_course_category', 'get_all')) {
              $categories = \core_course_category::get_all(['returnhidden' => true]);
          } else {
              // Fallback (to be removed once this gets integrated into master).
              $ids = $DB->get_fieldset_select('course_categories', 'id', '');
              $categories = \core_course_category::get_many($ids);
          }
  
          foreach ($categories as $key => $category) {
              if (!$category->is_uservisible()) {
                  unset($categories[$key]);
              }
          }
          return $categories;
      }
code_tokens: public static function get_site_categories ( ) { global $ DB ; if ( method_exists ( '\core_course_category' , 'get_all' ) ) { $ categories = \ core_course_category :: get_all ( [ 'returnhidden' => true ] ) ; } else { // Fallback (to be removed once this gets integrated into master). $ ids = $ DB -> get_fieldset_select ( 'course_categories' , 'id' , '' ) ; $ categories = \ core_course_category :: get_many ( $ ids ) ; } foreach ( $ categories as $ key => $ category ) { if ( ! $ category -> is_uservisible ( ) ) { unset ( $ categories [ $ key ] ) ; } } return $ categories ; }
docstring: Returns all site categories that are visible to the current user.
  
  @return \core_course_category[]
docstring_tokens: Returns all site categories that are visible to the current user .