Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 39 and 402]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\Engine;
   4  
   5  class CyclicReferenceStack
   6  {
   7      /**
   8       * The call stack for calculated cells.
   9       *
  10       * @var mixed[]
  11       */
  12      private $stack = [];
  13  
  14      /**
  15       * Return the number of entries on the stack.
  16       *
  17       * @return int
  18       */
  19      public function count()
  20      {
  21          return count($this->stack);
  22      }
  23  
  24      /**
  25       * Push a new entry onto the stack.
  26       *
  27       * @param mixed $value
  28       */
  29      public function push($value): void
  30      {
  31          $this->stack[$value] = $value;
  32      }
  33  
  34      /**
  35       * Pop the last entry from the stack.
  36       *
  37       * @return mixed
  38       */
  39      public function pop()
  40      {
  41          return array_pop($this->stack);
  42      }
  43  
  44      /**
  45       * Test to see if a specified entry exists on the stack.
  46       *
  47       * @param mixed $value The value to test
  48       *
  49       * @return bool
  50       */
  51      public function onStack($value)
  52      {
  53          return isset($this->stack[$value]);
  54      }
  55  
  56      /**
  57       * Clear the stack.
  58       */
  59      public function clear(): void
  60      {
  61          $this->stack = [];
  62      }
  63  
  64      /**
  65       * Return an array of all entries on the stack.
  66       *
  67       * @return mixed[]
  68       */
  69      public function showStack()
  70      {
  71          return $this->stack;
  72      }
  73  }