original_string: public static function doAsSuperUser($function)
      {
          $isSuperUser = self::getInstance()->hasSuperUserAccess();
  
          $access = self::getInstance();
          $login = $access->getLogin();
          $shouldResetLogin = empty($login); // make sure to reset login if a login was set by "makeSureLoginNameIsSet()"
          $access->setSuperUserAccess(true);
  
          try {
              $result = $function();
          } catch (Exception $ex) {
              $access->setSuperUserAccess($isSuperUser);
              if ($shouldResetLogin) {
                  $access->login = null;
              }
  
              throw $ex;
          }
  
          if ($shouldResetLogin) {
              $access->login = null;
          }
          $access->setSuperUserAccess($isSuperUser);
  
          return $result;
      }
code: public static function doAsSuperUser($function)
      {
          $isSuperUser = self::getInstance()->hasSuperUserAccess();
  
          $access = self::getInstance();
          $login = $access->getLogin();
          $shouldResetLogin = empty($login); // make sure to reset login if a login was set by "makeSureLoginNameIsSet()"
          $access->setSuperUserAccess(true);
  
          try {
              $result = $function();
          } catch (Exception $ex) {
              $access->setSuperUserAccess($isSuperUser);
              if ($shouldResetLogin) {
                  $access->login = null;
              }
  
              throw $ex;
          }
  
          if ($shouldResetLogin) {
              $access->login = null;
          }
          $access->setSuperUserAccess($isSuperUser);
  
          return $result;
      }
code_tokens: public static function doAsSuperUser ( $ function ) { $ isSuperUser = self :: getInstance ( ) -> hasSuperUserAccess ( ) ; $ access = self :: getInstance ( ) ; $ login = $ access -> getLogin ( ) ; $ shouldResetLogin = empty ( $ login ) ; // make sure to reset login if a login was set by "makeSureLoginNameIsSet()" $ access -> setSuperUserAccess ( true ) ; try { $ result = $ function ( ) ; } catch ( Exception $ ex ) { $ access -> setSuperUserAccess ( $ isSuperUser ) ; if ( $ shouldResetLogin ) { $ access -> login = null ; } throw $ ex ; } if ( $ shouldResetLogin ) { $ access -> login = null ; } $ access -> setSuperUserAccess ( $ isSuperUser ) ; return $ result ; }
docstring: Executes a callback with superuser privileges, making sure those privileges are rescinded
  before this method exits. Privileges will be rescinded even if an exception is thrown.
  
  @param callback $function The callback to execute. Should accept no arguments.
  @return mixed The result of `$function`.
  @throws Exception rethrows any exceptions thrown by `$function`.
  @api
docstring_tokens: Executes a callback with superuser privileges making sure those privileges are rescinded before this method exits . Privileges will be rescinded even if an exception is thrown .