1 | <?php |
||
27 | class Stack |
||
28 | { |
||
29 | /** |
||
30 | * The parser stack for formulae. |
||
31 | * |
||
32 | * @var mixed[] |
||
33 | */ |
||
34 | private $stack = []; |
||
35 | |||
36 | /** |
||
37 | * Count of entries in the parser stack. |
||
38 | * |
||
39 | * @var int |
||
40 | */ |
||
41 | private $count = 0; |
||
42 | |||
43 | /** |
||
44 | * Return the number of entries on the stack. |
||
45 | * |
||
46 | * @return int |
||
47 | */ |
||
48 | 95 | public function count() |
|
52 | |||
53 | /** |
||
54 | * Push a new entry onto the stack. |
||
55 | * |
||
56 | * @param mixed $type |
||
57 | * @param mixed $value |
||
58 | * @param mixed $reference |
||
59 | */ |
||
60 | 95 | public function push($type, $value, $reference = null) |
|
61 | { |
||
62 | 95 | $this->stack[$this->count++] = [ |
|
63 | 95 | 'type' => $type, |
|
64 | 95 | 'value' => $value, |
|
65 | 95 | 'reference' => $reference, |
|
66 | ]; |
||
67 | 95 | if ($type == 'Function') { |
|
68 | 25 | $localeFunction = \PhpOffice\PhpSpreadsheet\Calculation::localeFunc($value); |
|
69 | 25 | if ($localeFunction != $value) { |
|
70 | 1 | $this->stack[($this->count - 1)]['localeValue'] = $localeFunction; |
|
71 | } |
||
72 | } |
||
73 | 95 | } |
|
74 | |||
75 | /** |
||
76 | * Pop the last entry from the stack. |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | 95 | public function pop() |
|
88 | |||
89 | /** |
||
90 | * Return an entry from the stack without removing it. |
||
91 | * |
||
92 | * @param int $n number indicating how far back in the stack we want to look |
||
93 | * |
||
94 | * @return mixed |
||
95 | */ |
||
96 | 95 | public function last($n = 1) |
|
104 | |||
105 | /** |
||
106 | * Clear the stack. |
||
107 | */ |
||
108 | public function clear() |
||
113 | } |
||
114 |