mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-03-11 17:18:44 +00:00
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1602 48356398-32a2-884e-a903-53898d9a118a
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Parses string representations into their corresponding native PHP
|
|
* variable type.
|
|
*/
|
|
abstract class HTMLPurifier_VarParser
|
|
{
|
|
|
|
/**
|
|
* Lookup table of allowed types.
|
|
*/
|
|
static public $types = array(
|
|
'string' => true,
|
|
'istring' => true,
|
|
'text' => true,
|
|
'itext' => true,
|
|
'int' => true,
|
|
'float' => true,
|
|
'bool' => true,
|
|
'lookup' => true,
|
|
'list' => true,
|
|
'hash' => true,
|
|
'mixed' => true
|
|
);
|
|
|
|
/**
|
|
* Validate a variable according to type. Throws
|
|
* HTMLPurifier_VarParserException if invalid.
|
|
* It may return NULL as a valid type if $allow_null is true.
|
|
*
|
|
* @param $var Variable to validate
|
|
* @param $type Type of variable, see HTMLPurifier_VarParser->types
|
|
* @param $allow_null Whether or not to permit null as a value
|
|
* @return Validated and type-coerced variable
|
|
*/
|
|
abstract public function parse($var, $type, $allow_null = false);
|
|
|
|
}
|