Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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 array $stack = [];
13
 
14
    /**
15
     * Return the number of entries on the stack.
16
     */
17
    public function count(): int
18
    {
19
        return count($this->stack);
20
    }
21
 
22
    /**
23
     * Push a new entry onto the stack.
24
     */
25
    public function push(mixed $value): void
26
    {
27
        $this->stack[$value] = $value;
28
    }
29
 
30
    /**
31
     * Pop the last entry from the stack.
32
     */
33
    public function pop(): mixed
34
    {
35
        return array_pop($this->stack);
36
    }
37
 
38
    /**
39
     * Test to see if a specified entry exists on the stack.
40
     *
41
     * @param mixed $value The value to test
42
     */
43
    public function onStack(mixed $value): bool
44
    {
45
        return isset($this->stack[$value]);
46
    }
47
 
48
    /**
49
     * Clear the stack.
50
     */
51
    public function clear(): void
52
    {
53
        $this->stack = [];
54
    }
55
 
56
    /**
57
     * Return an array of all entries on the stack.
58
     *
59
     * @return mixed[]
60
     */
61
    public function showStack(): array
62
    {
63
        return $this->stack;
64
    }
65
}