Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  
   3  /**
   4   * This is in almost every respect equivalent to an array except
   5   * that it keeps track of which keys were accessed.
   6   *
   7   * @warning For the sake of backwards compatibility with early versions
   8   *     of PHP 5, you must not use the $hash[$key] syntax; if you do
   9   *     our version of offsetGet is never called.
  10   */
  11  class HTMLPurifier_StringHash extends ArrayObject
  12  {
  13      /**
  14       * @type array
  15       */
  16      protected $accessed = array();
  17  
  18      /**
  19       * Retrieves a value, and logs the access.
  20       * @param mixed $index
  21       * @return mixed
  22       */
  23      #[\ReturnTypeWillChange]
  24      public function offsetGet($index)
  25      {
  26          $this->accessed[$index] = true;
  27          return parent::offsetGet($index);
  28      }
  29  
  30      /**
  31       * Returns a lookup array of all array indexes that have been accessed.
  32       * @return array in form array($index => true).
  33       */
  34      public function getAccessed()
  35      {
  36          return $this->accessed;
  37      }
  38  
  39      /**
  40       * Resets the access array.
  41       */
  42      public function resetAccessed()
  43      {
  44          $this->accessed = array();
  45      }
  46  }
  47  
  48  // vim: et sw=4 sts=4