← All changes
|
vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Token/Stack.php
+88
-84
3.1.2
→
3.0.10
View file →
| @@ -1,10 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | /** |
| 4 | - * PHPExcel_Calculation_Token_Stack | |
| 3 | + * PHPExcel | |
| 5 | 4 | * |
| 6 | - * Copyright (c) 2006 - 2015 PHPExcel | |
| 5 | + * Copyright (c) 2006 - 2014 PHPExcel | |
| 7 | 6 | * |
| 8 | 7 | * This library is free software; you can redistribute it and/or |
| 9 | 8 | * modify it under the terms of the GNU Lesser General Public |
| 10 | 9 | * License as published by the Free Software Foundation; either |
| @@ -20,92 +19,97 @@ | ||
| 20 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | 20 | * |
| 22 | 21 | * @category PHPExcel |
| 23 | 22 | * @package PHPExcel_Calculation |
| 24 | - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 25 | - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL | |
| 26 | - * @version ##VERSION##, ##DATE## | |
| 23 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 24 | + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL | |
| 25 | + * @version ##VERSION##, ##DATE## | |
| 27 | 26 | */ |
| 28 | -class PHPExcel_Calculation_Token_Stack | |
| 29 | -{ | |
| 30 | - /** | |
| 31 | - * The parser stack for formulae | |
| 32 | - * | |
| 33 | - * @var mixed[] | |
| 34 | - */ | |
| 35 | - private $stack = array(); | |
| 36 | 27 | |
| 37 | - /** | |
| 38 | - * Count of entries in the parser stack | |
| 39 | - * | |
| 40 | - * @var integer | |
| 41 | - */ | |
| 42 | - private $count = 0; | |
| 43 | 28 | |
| 44 | - /** | |
| 45 | - * Return the number of entries on the stack | |
| 46 | - * | |
| 47 | - * @return integer | |
| 48 | - */ | |
| 49 | - public function count() | |
| 50 | - { | |
| 51 | - return $this->count; | |
| 52 | - } | |
| 29 | +/** | |
| 30 | + * PHPExcel_Calculation_Token_Stack | |
| 31 | + * | |
| 32 | + * @category PHPExcel_Calculation_Token_Stack | |
| 33 | + * @package PHPExcel_Calculation | |
| 34 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 35 | + */ | |
| 36 | +class PHPExcel_Calculation_Token_Stack { | |
| 53 | 37 | |
| 54 | - /** | |
| 55 | - * Push a new entry onto the stack | |
| 56 | - * | |
| 57 | - * @param mixed $type | |
| 58 | - * @param mixed $value | |
| 59 | - * @param mixed $reference | |
| 60 | - */ | |
| 61 | - public function push($type, $value, $reference = null) | |
| 62 | - { | |
| 63 | - $this->stack[$this->count++] = array( | |
| 64 | - 'type' => $type, | |
| 65 | - 'value' => $value, | |
| 66 | - 'reference' => $reference | |
| 67 | - ); | |
| 68 | - if ($type == 'Function') { | |
| 69 | - $localeFunction = PHPExcel_Calculation::localeFunc($value); | |
| 70 | - if ($localeFunction != $value) { | |
| 71 | - $this->stack[($this->count - 1)]['localeValue'] = $localeFunction; | |
| 72 | - } | |
| 73 | - } | |
| 74 | - } | |
| 38 | + /** | |
| 39 | + * The parser stack for formulae | |
| 40 | + * | |
| 41 | + * @var mixed[] | |
| 42 | + */ | |
| 43 | + private $_stack = array(); | |
| 75 | 44 | |
| 76 | - /** | |
| 77 | - * Pop the last entry from the stack | |
| 78 | - * | |
| 79 | - * @return mixed | |
| 80 | - */ | |
| 81 | - public function pop() | |
| 82 | - { | |
| 83 | - if ($this->count > 0) { | |
| 84 | - return $this->stack[--$this->count]; | |
| 85 | - } | |
| 86 | - return null; | |
| 87 | - } | |
| 45 | + /** | |
| 46 | + * Count of entries in the parser stack | |
| 47 | + * | |
| 48 | + * @var integer | |
| 49 | + */ | |
| 50 | + private $_count = 0; | |
| 88 | 51 | |
| 89 | - /** | |
| 90 | - * Return an entry from the stack without removing it | |
| 91 | - * | |
| 92 | - * @param integer $n number indicating how far back in the stack we want to look | |
| 93 | - * @return mixed | |
| 94 | - */ | |
| 95 | - public function last($n = 1) | |
| 96 | - { | |
| 97 | - if ($this->count - $n < 0) { | |
| 98 | - return null; | |
| 99 | - } | |
| 100 | - return $this->stack[$this->count - $n]; | |
| 101 | - } | |
| 102 | 52 | |
| 103 | - /** | |
| 104 | - * Clear the stack | |
| 105 | - */ | |
| 106 | - public function clear() | |
| 107 | - { | |
| 108 | - $this->stack = array(); | |
| 109 | - $this->count = 0; | |
| 110 | - } | |
| 111 | -} | |
| 53 | + /** | |
| 54 | + * Return the number of entries on the stack | |
| 55 | + * | |
| 56 | + * @return integer | |
| 57 | + */ | |
| 58 | + public function count() { | |
| 59 | + return $this->_count; | |
| 60 | + } // function count() | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Push a new entry onto the stack | |
| 64 | + * | |
| 65 | + * @param mixed $type | |
| 66 | + * @param mixed $value | |
| 67 | + * @param mixed $reference | |
| 68 | + */ | |
| 69 | + public function push($type, $value, $reference = NULL) { | |
| 70 | + $this->_stack[$this->_count++] = array('type' => $type, | |
| 71 | + 'value' => $value, | |
| 72 | + 'reference' => $reference | |
| 73 | + ); | |
| 74 | + if ($type == 'Function') { | |
| 75 | + $localeFunction = PHPExcel_Calculation::_localeFunc($value); | |
| 76 | + if ($localeFunction != $value) { | |
| 77 | + $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction; | |
| 78 | + } | |
| 79 | + } | |
| 80 | + } // function push() | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * Pop the last entry from the stack | |
| 84 | + * | |
| 85 | + * @return mixed | |
| 86 | + */ | |
| 87 | + public function pop() { | |
| 88 | + if ($this->_count > 0) { | |
| 89 | + return $this->_stack[--$this->_count]; | |
| 90 | + } | |
| 91 | + return NULL; | |
| 92 | + } // function pop() | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Return an entry from the stack without removing it | |
| 96 | + * | |
| 97 | + * @param integer $n number indicating how far back in the stack we want to look | |
| 98 | + * @return mixed | |
| 99 | + */ | |
| 100 | + public function last($n = 1) { | |
| 101 | + if ($this->_count - $n < 0) { | |
| 102 | + return NULL; | |
| 103 | + } | |
| 104 | + return $this->_stack[$this->_count - $n]; | |
| 105 | + } // function last() | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * Clear the stack | |
| 109 | + */ | |
| 110 | + function clear() { | |
| 111 | + $this->_stack = array(); | |
| 112 | + $this->_count = 0; | |
| 113 | + } | |
| 114 | + | |
| 115 | +} // class PHPExcel_Calculation_Token_Stack | |