Make test script less chatty when log_errors is on.
[htmlpurifier.git] / library / HTMLPurifier / ChildDef / Optional.php
blob32bcb9898eac9ea6fff386e1617ad332b5c19971
1 <?php
3 /**
4 * Definition that allows a set of elements, and allows no children.
5 * @note This is a hack to reuse code from HTMLPurifier_ChildDef_Required,
6 * really, one shouldn't inherit from the other. Only altered behavior
7 * is to overload a returned false with an array. Thus, it will never
8 * return false.
9 */
10 class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required
12 public $allow_empty = true;
13 public $type = 'optional';
14 public function validateChildren($tokens_of_children, $config, $context) {
15 $result = parent::validateChildren($tokens_of_children, $config, $context);
16 // we assume that $tokens_of_children is not modified
17 if ($result === false) {
18 if (empty($tokens_of_children)) return true;
19 elseif ($this->whitespace) return $tokens_of_children;
20 else return array();
22 return $result;
26 // vim: et sw=4 sts=4