Class HTMLPurifier_VarParser

Description

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

Located in /lib/core/Parsers/htmlpurifier/HTMLPurifier.standalone.php (line 7528)


	
			
Direct descendents
Class Description
HTMLPurifier_VarParser_Flexible Performs safe variable parsing based on types which can be used by users. This may not be able to represent all possible data inputs, however.
HTMLPurifier_VarParser_Native This variable parser uses PHP's internal code engine. Because it does 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 7565)

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 7547)

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 7663)
  • access: public
static void getTypeName ( $type)
  • $type
error (line 7641)

Throws an exception.

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

Generic error for if a type didn't work.

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

Throws an inconsistency exception.

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

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 7634)

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 7539)
BOOL = 7 (line 7537)
FLOAT = 6 (line 7536)
HASH = 10 (line 7540)
INT = 5 (line 7535)
ISTRING = 2 (line 7532)
ITEXT = 4 (line 7534)
LOOKUP = 8 (line 7538)
MIXED = 11 (line 7541)
STRING = 1 (line 7531)
TEXT = 3 (line 7533)

Documentation generated on Sun, 06 Mar 2011 00:24:14 -0500 by phpDocumentor 1.4.3