CyclicReferenceStack.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. class PHPExcel_CalcEngine_CyclicReferenceStack
  8. {
  9. /**
  10. * The call stack for calculated cells
  11. *
  12. * @var mixed[]
  13. */
  14. private $stack = array();
  15. /**
  16. * Return the number of entries on the stack
  17. *
  18. * @return integer
  19. */
  20. public function count()
  21. {
  22. return count($this->stack);
  23. }
  24. /**
  25. * Push a new entry onto the stack
  26. *
  27. * @param mixed $value
  28. */
  29. public function push($value)
  30. {
  31. $this->stack[$value] = $value;
  32. }
  33. /**
  34. * Pop the last entry from the stack
  35. *
  36. * @return mixed
  37. */
  38. public function pop()
  39. {
  40. return array_pop($this->stack);
  41. }
  42. /**
  43. * Test to see if a specified entry exists on the stack
  44. *
  45. * @param mixed $value The value to test
  46. */
  47. public function onStack($value)
  48. {
  49. return isset($this->stack[$value]);
  50. }
  51. /**
  52. * Clear the stack
  53. */
  54. public function clear()
  55. {
  56. $this->stack = array();
  57. }
  58. /**
  59. * Return an array of all entries on the stack
  60. *
  61. * @return mixed[]
  62. */
  63. public function showStack()
  64. {
  65. return $this->stack;
  66. }
  67. }