Class HTMLPurifier_VarParser
Inheritance | HTMLPurifier_VarParser |
---|---|
Subclasses | HTMLPurifier_VarParser_Flexible, HTMLPurifier_VarParser_Native |
Parses string representations into their corresponding native PHP variable type. The base implementation does a simple type-check.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$stringTypes | Lookup table of types that are string, and can have aliases or allowed value lists. | HTMLPurifier_VarParser | |
$types | Lookup table of allowed types. Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants. | HTMLPurifier_VarParser |
Public Methods
Method | Description | Defined By |
---|---|---|
getTypeName() | HTMLPurifier_VarParser | |
parse() | Validate a variable according to type. | HTMLPurifier_VarParser |
Protected Methods
Method | Description | Defined By |
---|---|---|
error() | Throws an exception. | HTMLPurifier_VarParser |
errorGeneric() | Generic error for if a type didn't work. | HTMLPurifier_VarParser |
errorInconsistent() | Throws an inconsistency exception. | HTMLPurifier_VarParser |
parseImplementation() | Actually implements the parsing. Base implementation does not do anything to $var. Subclasses should overload this! | HTMLPurifier_VarParser |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
ALIST | 9 | HTMLPurifier_VarParser | |
BOOL | 7 | HTMLPurifier_VarParser | |
FLOAT | 6 | HTMLPurifier_VarParser | |
HASH | 10 | HTMLPurifier_VarParser | |
INT | 5 | HTMLPurifier_VarParser | |
ISTRING | 2 | HTMLPurifier_VarParser | |
ITEXT | 4 | HTMLPurifier_VarParser | |
LOOKUP | 8 | HTMLPurifier_VarParser | |
MIXED | 11 | HTMLPurifier_VarParser | |
STRING | 1 | HTMLPurifier_VarParser | |
TEXT | 3 | HTMLPurifier_VarParser |
Property Details
public static $stringTypes = [self::STRING => true, self::ISTRING => true, self::TEXT => true, self::ITEXT => true]
public static $types = ['string' => self::STRING, 'istring' => self::ISTRING, 'text' => self::TEXT, 'itext' => self::ITEXT, 'int' => self::INT, 'float' => self::FLOAT, 'bool' => self::BOOL, 'lookup' => self::LOOKUP, 'list' => self::ALIST, 'hash' => self::HASH, 'mixed' => self::MIXED]
Method Details
Throws an exception.
protected void error ( $msg ) | ||
$msg | ||
throws | HTMLPurifier_VarParserException |
---|
Generic error for if a type didn't work.
protected void errorGeneric ( $var, $type ) | ||
$var | mixed | |
$type | int |
Throws an inconsistency exception.
protected void errorInconsistent ( $class, $type ) | ||
$class | string | |
$type | int | |
throws | HTMLPurifier_Exception |
---|
public static string getTypeName ( $type ) | ||
$type | int |
Validate a variable according to type.
It may return NULL as a valid type if $allow_null is true.
public string parse ( $var, $type, $allow_null = false ) | ||
$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 | string | Validated and type-coerced variable |
---|---|---|
throws | HTMLPurifier_VarParserException |
Actually implements the parsing. Base implementation does not do anything to $var. Subclasses should overload this!
protected string parseImplementation ( $var, $type, $allow_null ) | ||
$var | mixed | |
$type | int | |
$allow_null | bool |