Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
HTMLPurifier_VarParser_Native Class Reference
Inheritance diagram for HTMLPurifier_VarParser_Native:
HTMLPurifier_VarParser

Public Member Functions

 parse ($var, $type, $allow_null=false)
 Validate a variable according to type.
 

Static Public Member Functions

static getTypeName ($type)
 

Public Attributes

const ALIST = 9
 
const C_BOOL = 7
 
const C_FLOAT = 6
 
const C_INT = 5
 
const C_MIXED = 11
 
const C_STRING = 1
 
const HASH = 10
 
const ISTRING = 2
 
const ITEXT = 4
 
const LOOKUP = 8
 
const TEXT = 3
 

Static Public Attributes

static $stringTypes
 Lookup table of types that are string, and can have aliases or allowed value lists.
 
static $types
 Lookup table of allowed types.
 

Protected Member Functions

 error ($msg)
 Throws an exception.
 
 errorGeneric ($var, $type)
 Generic error for if a type didn't work.
 
 errorInconsistent ($class, $type)
 Throws an inconsistency exception.
 
 evalExpression ($expr)
 
 parseImplementation ($var, $type, $allow_null)
 

Member Function Documentation

◆ error()

HTMLPurifier_VarParser::error ( $msg)
protectedinherited

Throws an exception.

Exceptions
HTMLPurifier_VarParserException

◆ errorGeneric()

HTMLPurifier_VarParser::errorGeneric ( $var,
$type )
protectedinherited

Generic error for if a type didn't work.

Parameters
mixed$var
int$type

◆ errorInconsistent()

HTMLPurifier_VarParser::errorInconsistent ( $class,
$type )
protectedinherited

Throws an inconsistency exception.

Note
This should not ever be called. It would be called if we extend the allowed values of HTMLPurifier_VarParser without updating subclasses.
Parameters
string$class
int$type
Exceptions
HTMLPurifier_Exception

◆ evalExpression()

HTMLPurifier_VarParser_Native::evalExpression ( $expr)
protected
Parameters
string$expr
Return values
mixed
Exceptions
HTMLPurifier_VarParserException

◆ getTypeName()

static HTMLPurifier_VarParser::getTypeName ( $type)
staticinherited
Parameters
int$type
Return values
string

◆ parse()

HTMLPurifier_VarParser::parse ( $var,
$type,
$allow_null = false )
finalinherited

Validate a variable according to type.

It may return NULL as a valid type if $allow_null is true.

Parameters
mixed$varVariable to validate
int$typeType of variable, see HTMLPurifier_VarParser->types
bool$allow_nullWhether or not to permit null as a value
Return values
stringValidated and type-coerced variable
Exceptions
HTMLPurifier_VarParserException

◆ parseImplementation()

HTMLPurifier_VarParser_Native::parseImplementation ( $var,
$type,
$allow_null )
protected
Parameters
mixed$var
int$type
bool$allow_null
Return values
null|string

Reimplemented from HTMLPurifier_VarParser.

Member Data Documentation

◆ $stringTypes

HTMLPurifier_VarParser::$stringTypes
staticinherited
Initial value:
= array(
self::C_STRING => true,
self::ISTRING => true,
self::TEXT => true,
self::ITEXT => true,
)

Lookup table of types that are string, and can have aliases or allowed value lists.

◆ $types

HTMLPurifier_VarParser::$types
staticinherited
Initial value:
= array(
'string' => self::C_STRING,
'istring' => self::ISTRING,
'text' => self::TEXT,
'itext' => self::ITEXT,
'int' => self::C_INT,
'float' => self::C_FLOAT,
'bool' => self::C_BOOL,
'lookup' => self::LOOKUP,
'list' => self::ALIST,
'hash' => self::HASH,
'mixed' => self::C_MIXED
)

Lookup table of allowed types.

Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants.


The documentation for this class was generated from the following file: