1
0
Fork 0
friendica_2020-09-1_sharedH.../vendor/ezyang/htmlpurifier/library/HTMLPurifier/StringHash.php

48 lines
1 KiB
PHP
Raw Normal View History

2010-09-09 05:14:17 +02:00
<?php
/**
* This is in almost every respect equivalent to an array except
* that it keeps track of which keys were accessed.
*
* @warning For the sake of backwards compatibility with early versions
* of PHP 5, you must not use the $hash[$key] syntax; if you do
* our version of offsetGet is never called.
*/
class HTMLPurifier_StringHash extends ArrayObject
{
2016-02-09 11:06:17 +01:00
/**
* @type array
*/
2010-09-09 05:14:17 +02:00
protected $accessed = array();
/**
* Retrieves a value, and logs the access.
2016-02-09 11:06:17 +01:00
* @param mixed $index
* @return mixed
2010-09-09 05:14:17 +02:00
*/
2016-02-09 11:06:17 +01:00
public function offsetGet($index)
{
2010-09-09 05:14:17 +02:00
$this->accessed[$index] = true;
return parent::offsetGet($index);
}
/**
* Returns a lookup array of all array indexes that have been accessed.
2016-02-09 11:06:17 +01:00
* @return array in form array($index => true).
2010-09-09 05:14:17 +02:00
*/
2016-02-09 11:06:17 +01:00
public function getAccessed()
{
2010-09-09 05:14:17 +02:00
return $this->accessed;
}
/**
* Resets the access array.
*/
2016-02-09 11:06:17 +01:00
public function resetAccessed()
{
2010-09-09 05:14:17 +02:00
$this->accessed = array();
}
}
// vim: et sw=4 sts=4