File indexing completed on 2024-05-12 14:03:13
0001 <?php 0002 0003 /** 0004 * This is in almost every respect equivalent to an array except 0005 * that it keeps track of which keys were accessed. 0006 * 0007 * @warning For the sake of backwards compatibility with early versions 0008 * of PHP 5, you must not use the $hash[$key] syntax; if you do 0009 * our version of offsetGet is never called. 0010 */ 0011 class HTMLPurifier_StringHash extends ArrayObject 0012 { 0013 /** 0014 * @type array 0015 */ 0016 protected $accessed = array(); 0017 0018 /** 0019 * Retrieves a value, and logs the access. 0020 * @param mixed $index 0021 * @return mixed 0022 */ 0023 public function offsetGet($index) 0024 { 0025 $this->accessed[$index] = true; 0026 return parent::offsetGet($index); 0027 } 0028 0029 /** 0030 * Returns a lookup array of all array indexes that have been accessed. 0031 * @return array in form array($index => true). 0032 */ 0033 public function getAccessed() 0034 { 0035 return $this->accessed; 0036 } 0037 0038 /** 0039 * Resets the access array. 0040 */ 0041 public function resetAccessed() 0042 { 0043 $this->accessed = array(); 0044 } 0045 } 0046 0047 // vim: et sw=4 sts=4