Class HTMLPurifier_VarParser

Description

Parses string representations into their corresponding native PHP variable type.

Parses string representations into their corresponding native PHP variable type. The base implementation does a simple type-check.

Located in /library/HTMLPurifier/VarParser.php (line 7)


	
			
Direct descendents
Class Description
HTMLPurifier_VarParser_Flexible Performs safe variable parsing based on types which can be used by users. however.
HTMLPurifier_VarParser_Native This variable parser uses PHP's internal code engine. this, it can represent all inputs; however, it is dangerous and cannot be used by users.
Class Constant Summary
 ALIST = 9
 BOOL = 7
 FLOAT = 6
 HASH = 10
 INT = 5
 ISTRING = 2
 ITEXT = 4
 LOOKUP = 8
 MIXED = 11
 STRING = 1
 TEXT = 3
Variable Summary
static mixed $stringTypes
static mixed $types
Method Summary
static void getTypeName ( $type)
void error ( $msg)
void errorGeneric ( $var,  $type)
void errorInconsistent ( $class,  $type)
Validated parse ($var $var, $type $type, [$allow_null $allow_null = false])
void parseImplementation ( $var,  $type,  $allow_null)
Variables
static mixed $stringTypes = array(
self::STRING => true,
self::ISTRING => true,
self::TEXT => true,
self::ITEXT => true,
)
(line 44)

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

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

  • access: public
static mixed $types = array(
'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
)
(line 26)

Lookup table of allowed types. also convenient for transforming string type names to the integer constants.

Lookup table of allowed types. Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants.

  • access: public
Methods
static method getTypeName (line 142)
  • access: public
static void getTypeName ( $type)
  • $type
error (line 120)

Throws an exception.

Throws an exception.

  • access: protected
void error ( $msg)
  • $msg
errorGeneric (line 137)

Generic error for if a type didn't work.

Generic error for if a type didn't work.

  • access: protected
void errorGeneric ( $var,  $type)
  • $var
  • $type
errorInconsistent (line 130)

Throws an inconsistency exception.

Throws an inconsistency exception.

  • access: protected
void errorInconsistent ( $class,  $type)
  • $class
  • $type
parse (line 61)

Validate a variable according to type. HTMLPurifier_VarParserException if invalid.

Validate a variable according to type. Throws HTMLPurifier_VarParserException if invalid. It may return NULL as a valid type if $allow_null is true.

  • return: and type-coerced variable
  • access: public
Validated parse ($var $var, $type $type, [$allow_null $allow_null = false])
  • $var $var: Variable to validate
  • $type $type: Type of variable, see HTMLPurifier_VarParser->types
  • $allow_null $allow_null: Whether or not to permit null as a value
parseImplementation (line 113)

Actually implements the parsing.

Actually implements the parsing. Base implementation is to not do anything to $var. Subclasses should overload this!

  • access: protected
void parseImplementation ( $var,  $type,  $allow_null)
  • $var
  • $type
  • $allow_null

Redefined in descendants as:
Class Constants
ALIST = 9 (line 18)
BOOL = 7 (line 16)
FLOAT = 6 (line 15)
HASH = 10 (line 19)
INT = 5 (line 14)
ISTRING = 2 (line 11)
ITEXT = 4 (line 13)
LOOKUP = 8 (line 17)
MIXED = 11 (line 20)
STRING = 1 (line 10)
TEXT = 3 (line 12)

Documentation generated on Thu, 19 Jun 2008 18:50:31 -0400 by phpDocumentor 1.4.2