PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.7
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Calculation / Token / Stack.php

Stack.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.7, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Token/Stack.php

94 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Calculation\Token;
4
5 use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
6
7 class Stack
8 {
9 /**
10 * The parser stack for formulae.
11 *
12 * @var mixed[]
13 */
14 private $stack = [];
15
16 /**
17 * Count of entries in the parser stack.
18 *
19 * @var int
20 */
21 private $count = 0;
22
23 /**
24 * Return the number of entries on the stack.
25 *
26 * @return int
27 */
28 public function count()
29 {
30 return $this->count;
31 }
32
33 /**
34 * Push a new entry onto the stack.
35 *
36 * @param mixed $type
37 * @param mixed $value
38 * @param mixed $reference
39 */
40 public function push($type, $value, $reference = null)
41 {
42 $this->stack[$this->count++] = [
43 'type' => $type,
44 'value' => $value,
45 'reference' => $reference,
46 ];
47 if ($type == 'Function') {
48 $localeFunction = Calculation::localeFunc($value);
49 if ($localeFunction != $value) {
50 $this->stack[($this->count - 1)]['localeValue'] = $localeFunction;
51 }
52 }
53 }
54
55 /**
56 * Pop the last entry from the stack.
57 *
58 * @return mixed
59 */
60 public function pop()
61 {
62 if ($this->count > 0) {
63 return $this->stack[--$this->count];
64 }
65
66 return null;
67 }
68
69 /**
70 * Return an entry from the stack without removing it.
71 *
72 * @param int $n number indicating how far back in the stack we want to look
73 *
74 * @return mixed
75 */
76 public function last($n = 1)
77 {
78 if ($this->count - $n < 0) {
79 return null;
80 }
81
82 return $this->stack[$this->count - $n];
83 }
84
85 /**
86 * Clear the stack.
87 */
88 public function clear()
89 {
90 $this->stack = [];
91 $this->count = 0;
92 }
93 }
94