private function validate_moodle_variable_name($varname, PHP_CodeSniffer_File $phpcsfile, $stackptr) {
        if (preg_match('/[A-Z]+/', $varname) && !in_array($varname, self::$allowedglobals)) {
            $error = "Variable \"$varname\" must be all lower-case";
            $phpcsfile->addError($error, $stackptr);
        }

        if (strpos($varname, '_') !== false && !in_array($varname, self::$allowedglobals)) {
            $error = "Variable \"$varname\" must not contain underscores.";
            $phpcsfile->addError($error, $stackptr);
        }
    }