HTMLPurifier_VarParser
Parses string representations into their corresponding native PHP variable type. The base implementation does a simple type-check.
- Full name:
\HTMLPurifier_VarParser
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
C_STRING |
public | 1 | |
ISTRING |
public | 2 | |
TEXT |
public | 3 | |
ITEXT |
public | 4 | |
C_INT |
public | 5 | |
C_FLOAT |
public | 6 | |
C_BOOL |
public | 7 | |
LOOKUP |
public | 8 | |
ALIST |
public | 9 | |
HASH |
public | 10 | |
C_MIXED |
public | 11 |
Properties
types
Lookup table of allowed types. Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants.
- This property is static.
stringTypes
Lookup table of types that are string, and can have aliases or allowed value lists.
- This property is static.
Methods
parse
Validate a variable according to type.
It may return NULL as a valid type if $allow_null is true.
- This method is final.
Parameters:
Parameter | Type | Description |
---|---|---|
$var |
mixed | Variable to validate |
$type |
int | Type of variable, see HTMLPurifier_VarParser->types |
$allow_null |
bool | Whether or not to permit null as a value |
Return Value:
Validated and type-coerced variable
Throws:
parseImplementation
Actually implements the parsing. Base implementation does not do anything to $var. Subclasses should overload this!
Parameters:
Parameter | Type | Description |
---|---|---|
$var |
mixed | |
$type |
int | |
$allow_null |
bool |
error
Throws an exception.
Parameters:
Parameter | Type | Description |
---|---|---|
$msg |
mixed |
Throws:
errorInconsistent
Throws an inconsistency exception.
Parameters:
Parameter | Type | Description |
---|---|---|
$class |
string | |
$type |
int |
Throws:
errorGeneric
Generic error for if a type didn't work.
Parameters:
Parameter | Type | Description |
---|---|---|
$var |
mixed | |
$type |
int |
getTypeName
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
int |
Automatically generated on 2025-03-18