@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | trigger_error("Trend(): Number of elements in coordinate arrays do not match.", E_USER_ERROR); |
87 | 87 | } |
88 | 88 | |
89 | - $key = md5($trendType.$const.serialize($yValues).serialize($xValues)); |
|
89 | + $key = md5($trendType . $const . serialize($yValues) . serialize($xValues)); |
|
90 | 90 | // Determine which Trend method has been requested |
91 | 91 | switch ($trendType) { |
92 | 92 | // Instantiate and return the class for the requested Trend method |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | case self::TREND_EXPONENTIAL: |
96 | 96 | case self::TREND_POWER: |
97 | 97 | if (!isset(self::$trendCache[$key])) { |
98 | - $className = '\PhpSpreadsheet\Shared\Trend\\'.$trendType.'BestFit'; |
|
98 | + $className = '\PhpSpreadsheet\Shared\Trend\\' . $trendType . 'BestFit'; |
|
99 | 99 | self::$trendCache[$key] = new $className($yValues, $xValues, $const); |
100 | 100 | } |
101 | 101 | return self::$trendCache[$key]; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // If the request is to determine the best fit regression, then we test each Trend line in turn |
115 | 115 | // Start by generating an instance of each available Trend method |
116 | 116 | foreach (self::$trendTypes as $trendMethod) { |
117 | - $className = '\PhpSpreadsheet\Shared\Trend\\'.$trendType.'BestFit'; |
|
117 | + $className = '\PhpSpreadsheet\Shared\Trend\\' . $trendType . 'BestFit'; |
|
118 | 118 | $bestFit[$trendMethod] = new $className($yValues, $xValues, $const); |
119 | 119 | $bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit(); |
120 | 120 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | // Check for number in scientific format |
58 | - if (preg_match('/^'.\PhpSpreadsheet\Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { |
|
58 | + if (preg_match('/^' . \PhpSpreadsheet\Calculation::CALCULATION_REGEXP_NUMBER . '$/', $value)) { |
|
59 | 59 | $cell->setValueExplicit((float) $value, DataType::TYPE_NUMERIC); |
60 | 60 | return true; |
61 | 61 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $currencyCode = \PhpSpreadsheet\Shared\StringHelper::getCurrencyCode(); |
101 | 101 | $decimalSeparator = \PhpSpreadsheet\Shared\StringHelper::getDecimalSeparator(); |
102 | 102 | $thousandsSeparator = \PhpSpreadsheet\Shared\StringHelper::getThousandsSeparator(); |
103 | - if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) { |
|
103 | + if (preg_match('/^' . preg_quote($currencyCode) . ' *(\d{1,3}(' . preg_quote($thousandsSeparator) . '\d{3})*|(\d+))(' . preg_quote($decimalSeparator) . '\d{2})?$/', $value)) { |
|
104 | 104 | // Convert value to number |
105 | 105 | $value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value)); |
106 | 106 | $cell->setValueExplicit($value, DataType::TYPE_NUMERIC); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return true; |
113 | 113 | } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { |
114 | 114 | // Convert value to number |
115 | - $value = (float) trim(str_replace(array('$',','), '', $value)); |
|
115 | + $value = (float) trim(str_replace(array('$', ','), '', $value)); |
|
116 | 116 | $cell->setValueExplicit($value, DataType::TYPE_NUMERIC); |
117 | 117 | // Set style |
118 | 118 | $cell->getWorksheet()->getStyle($cell->getCoordinate()) |
@@ -171,7 +171,7 @@ |
||
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
174 | - $cacheStorageClass = '\\PhpSpreadsheet\\CachedObjectStorage\\'.$method; |
|
174 | + $cacheStorageClass = '\\PhpSpreadsheet\\CachedObjectStorage\\' . $method; |
|
175 | 175 | if (!call_user_func([$cacheStorageClass, 'cacheMethodIsAvailable'])) { |
176 | 176 | return false; |
177 | 177 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | } else { |
409 | 409 | // String values are always tested for equality, factoring in for wildcards (hence a regexp test) |
410 | - $retVal = preg_match('/^'.$rule['value'].'$/i', $cellValue); |
|
410 | + $retVal = preg_match('/^' . $rule['value'] . '$/i', $cellValue); |
|
411 | 411 | } |
412 | 412 | // If there are multiple conditions, then we need to test both using the appropriate join operator |
413 | 413 | switch ($join) { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @var array |
459 | 459 | */ |
460 | 460 | private static $fromReplace = array('\*', '\?', '~~', '~.*', '~.?'); |
461 | - private static $toReplace = array('.*', '.', '~', '\*', '\?'); |
|
461 | + private static $toReplace = array('.*', '.', '~', '\*', '\?'); |
|
462 | 462 | |
463 | 463 | |
464 | 464 | /** |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER: |
528 | 528 | $thisMonth = date('m', $baseDate); |
529 | 529 | $thisQuarter = floor(--$thisMonth / 3); |
530 | - $maxVal = (int) \PhpSpreadsheet\Shared\Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1+$thisQuarter)*3, date('Y', $baseDate))); |
|
530 | + $maxVal = (int) \PhpSpreadsheet\Shared\Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1 + $thisQuarter) * 3, date('Y', $baseDate))); |
|
531 | 531 | ++$maxVal; |
532 | - $val = (int) \PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1+$thisQuarter*3, date('Y', $baseDate))); |
|
532 | + $val = (int) \PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1 + $thisQuarter * 3, date('Y', $baseDate))); |
|
533 | 533 | break; |
534 | 534 | case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH: |
535 | 535 | case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH: |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | private function calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue) |
574 | 574 | { |
575 | - $range = $columnID.$startRow.':'.$columnID.$endRow; |
|
575 | + $range = $columnID . $startRow . ':' . $columnID . $endRow; |
|
576 | 576 | $dataValues = \PhpSpreadsheet\Calculation\Functions::flattenArray($this->workSheet->rangeToArray($range, null, true, false)); |
577 | 577 | |
578 | 578 | $dataValues = array_filter($dataValues); |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | ($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE)) { |
704 | 704 | // Number (Average) based |
705 | 705 | // Calculate the average |
706 | - $averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')'; |
|
706 | + $averageFormula = '=AVERAGE(' . $columnID . ($rangeStart[1] + 1) . ':' . $columnID . $rangeEnd[1] . ')'; |
|
707 | 707 | $average = \PhpSpreadsheet\Calculation::getInstance()->calculateFormula($averageFormula, null, $this->workSheet->getCell('A1')); |
708 | 708 | // Set above/below rule based on greaterThan or LessTan |
709 | 709 | $operator = ($dynamicRuleType === AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | $ruleValues = array($period); |
726 | 726 | } else { |
727 | 727 | --$period; |
728 | - $periodEnd = (1+$period)*3; |
|
729 | - $periodStart = 1+$period*3; |
|
728 | + $periodEnd = (1 + $period) * 3; |
|
729 | + $periodStart = 1 + $period * 3; |
|
730 | 730 | $ruleValues = range($periodStart, $periodEnd); |
731 | 731 | } |
732 | 732 | $columnFilterTests[$columnID] = array( |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $ruleValue = 500; |
762 | 762 | } |
763 | 763 | |
764 | - $maxVal = $this->calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue); |
|
764 | + $maxVal = $this->calculateTopTenValue($columnID, $rangeStart[1] + 1, $rangeEnd[1], $toptenRuleType, $ruleValue); |
|
765 | 765 | |
766 | 766 | $operator = ($toptenRuleType == AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) |
767 | 767 | ? AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL |
@@ -780,12 +780,12 @@ discard block |
||
780 | 780 | // var_dump($columnFilterTests); |
781 | 781 | // |
782 | 782 | // Execute the column tests for each row in the autoFilter range to determine show/hide, |
783 | - for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) { |
|
783 | + for ($row = $rangeStart[1] + 1; $row <= $rangeEnd[1]; ++$row) { |
|
784 | 784 | // echo 'Testing Row = ', $row,PHP_EOL; |
785 | 785 | $result = true; |
786 | 786 | foreach ($columnFilterTests as $columnID => $columnFilterTest) { |
787 | 787 | // echo 'Testing cell ', $columnID.$row,PHP_EOL; |
788 | - $cellValue = $this->workSheet->getCell($columnID.$row)->getCalculatedValue(); |
|
788 | + $cellValue = $this->workSheet->getCell($columnID . $row)->getCalculatedValue(); |
|
789 | 789 | // echo 'Value is ', $cellValue,PHP_EOL; |
790 | 790 | // Execute the filter test |
791 | 791 | $result = $result && |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'NULL' => null |
262 | 262 | ); |
263 | 263 | |
264 | - // PhpSpreadsheet functions |
|
264 | + // PhpSpreadsheet functions |
|
265 | 265 | private static $phpSpreadsheetFunctions = array( |
266 | 266 | 'ABS' => array( |
267 | 267 | 'category' => Calculation\Categories::CATEGORY_MATH_AND_TRIG, |
@@ -3136,13 +3136,13 @@ discard block |
||
3136 | 3136 | $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null; |
3137 | 3137 | |
3138 | 3138 | $regexpMatchString = '/^('.self::CALCULATION_REGEXP_FUNCTION. |
3139 | - '|'.self::CALCULATION_REGEXP_CELLREF. |
|
3140 | - '|'.self::CALCULATION_REGEXP_NUMBER. |
|
3141 | - '|'.self::CALCULATION_REGEXP_STRING. |
|
3142 | - '|'.self::CALCULATION_REGEXP_OPENBRACE. |
|
3143 | - '|'.self::CALCULATION_REGEXP_NAMEDRANGE. |
|
3144 | - '|'.self::CALCULATION_REGEXP_ERROR. |
|
3145 | - ')/si'; |
|
3139 | + '|'.self::CALCULATION_REGEXP_CELLREF. |
|
3140 | + '|'.self::CALCULATION_REGEXP_NUMBER. |
|
3141 | + '|'.self::CALCULATION_REGEXP_STRING. |
|
3142 | + '|'.self::CALCULATION_REGEXP_OPENBRACE. |
|
3143 | + '|'.self::CALCULATION_REGEXP_NAMEDRANGE. |
|
3144 | + '|'.self::CALCULATION_REGEXP_ERROR. |
|
3145 | + ')/si'; |
|
3146 | 3146 | |
3147 | 3147 | // Start with initialisation |
3148 | 3148 | $index = 0; |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | // String operand |
51 | 51 | const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"'; |
52 | 52 | // Opening bracket |
53 | - const CALCULATION_REGEXP_OPENBRACE = '\('; |
|
53 | + const CALCULATION_REGEXP_OPENBRACE = '\('; |
|
54 | 54 | // Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it) |
55 | - const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('; |
|
55 | + const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('; |
|
56 | 56 | // Cell reference (cell or range of cells, with or without a sheet reference) |
57 | - const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; |
|
57 | + const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; |
|
58 | 58 | // Named Range of cells |
59 | - const CALCULATION_REGEXP_NAMEDRANGE = CALCULATION_REGEXP_NAMEDRANGE; |
|
59 | + const CALCULATION_REGEXP_NAMEDRANGE = CALCULATION_REGEXP_NAMEDRANGE; |
|
60 | 60 | // Error |
61 | - const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; |
|
61 | + const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | /** constants */ |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @access private |
101 | 101 | * @var array |
102 | 102 | */ |
103 | - private $calculationCache = array (); |
|
103 | + private $calculationCache = array(); |
|
104 | 104 | |
105 | 105 | |
106 | 106 | /** |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * @var array |
121 | 121 | */ |
122 | 122 | private static $operators = array( |
123 | - '+' => true, '-' => true, '*' => true, '/' => true, |
|
124 | - '^' => true, '&' => true, '%' => false, '~' => false, |
|
125 | - '>' => true, '<' => true, '=' => true, '>=' => true, |
|
126 | - '<=' => true, '<>' => true, '|' => true, ':' => true |
|
123 | + '+' => true, '-' => true, '*' => true, '/' => true, |
|
124 | + '^' => true, '&' => true, '%' => false, '~' => false, |
|
125 | + '>' => true, '<' => true, '=' => true, '>=' => true, |
|
126 | + '<=' => true, '<>' => true, '|' => true, ':' => true |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | /** |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | * @var array |
134 | 134 | */ |
135 | 135 | private static $binaryOperators = array( |
136 | - '+' => true, '-' => true, '*' => true, '/' => true, |
|
137 | - '^' => true, '&' => true, '>' => true, '<' => true, |
|
138 | - '=' => true, '>=' => true, '<=' => true, '<>' => true, |
|
139 | - '|' => true, ':' => true |
|
136 | + '+' => true, '-' => true, '*' => true, '/' => true, |
|
137 | + '^' => true, '&' => true, '>' => true, '<' => true, |
|
138 | + '=' => true, '>=' => true, '<=' => true, '<>' => true, |
|
139 | + '|' => true, ':' => true |
|
140 | 140 | ); |
141 | 141 | |
142 | 142 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @var float |
206 | 206 | * |
207 | 207 | */ |
208 | - private $delta = 0.1e-12; |
|
208 | + private $delta = 0.1e-12; |
|
209 | 209 | |
210 | 210 | |
211 | 211 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @var string |
215 | 215 | * |
216 | 216 | */ |
217 | - private static $localeLanguage = 'en_us'; // US English (default locale) |
|
217 | + private static $localeLanguage = 'en_us'; // US English (default locale) |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * List of available locale settings |
@@ -2072,9 +2072,9 @@ discard block |
||
2072 | 2072 | |
2073 | 2073 | private static function loadLocales() |
2074 | 2074 | { |
2075 | - $localeFileDirectory = PHPSPREADSHEET_ROOT.'PhpSpreadsheet/locale/'; |
|
2076 | - foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) { |
|
2077 | - $filename = substr($filename, strlen($localeFileDirectory)+1); |
|
2075 | + $localeFileDirectory = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet/locale/'; |
|
2076 | + foreach (glob($localeFileDirectory . '/*', GLOB_ONLYDIR) as $filename) { |
|
2077 | + $filename = substr($filename, strlen($localeFileDirectory) + 1); |
|
2078 | 2078 | if ($filename != 'en') { |
2079 | 2079 | self::$validLocaleLanguages[] = $filename; |
2080 | 2080 | } |
@@ -2319,10 +2319,10 @@ discard block |
||
2319 | 2319 | // Default is English, if user isn't requesting english, then read the necessary data from the locale files |
2320 | 2320 | if ($locale != 'en_us') { |
2321 | 2321 | // Search for a file with a list of function names for locale |
2322 | - $functionNamesFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'functions'; |
|
2322 | + $functionNamesFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $locale) . DIRECTORY_SEPARATOR . 'functions'; |
|
2323 | 2323 | if (!file_exists($functionNamesFile)) { |
2324 | 2324 | // If there isn't a locale specific function file, look for a language specific function file |
2325 | - $functionNamesFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions'; |
|
2325 | + $functionNamesFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . 'functions'; |
|
2326 | 2326 | if (!file_exists($functionNamesFile)) { |
2327 | 2327 | return false; |
2328 | 2328 | } |
@@ -2330,7 +2330,7 @@ discard block |
||
2330 | 2330 | // Retrieve the list of locale or language specific function names |
2331 | 2331 | $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
2332 | 2332 | foreach ($localeFunctions as $localeFunction) { |
2333 | - list($localeFunction) = explode('##', $localeFunction); // Strip out comments |
|
2333 | + list($localeFunction) = explode('##', $localeFunction); // Strip out comments |
|
2334 | 2334 | if (strpos($localeFunction, '=') !== false) { |
2335 | 2335 | list($fName, $lfName) = explode('=', $localeFunction); |
2336 | 2336 | $fName = trim($fName); |
@@ -2348,14 +2348,14 @@ discard block |
||
2348 | 2348 | self::$localeBoolean['FALSE'] = self::$localeFunctions['FALSE']; |
2349 | 2349 | } |
2350 | 2350 | |
2351 | - $configFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'config'; |
|
2351 | + $configFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $locale) . DIRECTORY_SEPARATOR . 'config'; |
|
2352 | 2352 | if (!file_exists($configFile)) { |
2353 | - $configFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config'; |
|
2353 | + $configFile = PHPSPREADSHEET_ROOT . 'PhpSpreadsheet' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . 'config'; |
|
2354 | 2354 | } |
2355 | 2355 | if (file_exists($configFile)) { |
2356 | 2356 | $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
2357 | 2357 | foreach ($localeSettings as $localeSetting) { |
2358 | - list($localeSetting) = explode('##', $localeSetting); // Strip out comments |
|
2358 | + list($localeSetting) = explode('##', $localeSetting); // Strip out comments |
|
2359 | 2359 | if (strpos($localeSetting, '=') !== false) { |
2360 | 2360 | list($settingName, $settingValue) = explode('=', $localeSetting); |
2361 | 2361 | $settingName = strtoupper(trim($settingName)); |
@@ -2393,7 +2393,7 @@ discard block |
||
2393 | 2393 | break; |
2394 | 2394 | case $fromSeparator: |
2395 | 2395 | if (!$inBraces) { |
2396 | - $formula = mb_substr($formula, 0, $i).$toSeparator.mb_substr($formula, $i+1); |
|
2396 | + $formula = mb_substr($formula, 0, $i) . $toSeparator . mb_substr($formula, $i + 1); |
|
2397 | 2397 | } |
2398 | 2398 | } |
2399 | 2399 | } |
@@ -2439,20 +2439,20 @@ discard block |
||
2439 | 2439 | if (self::$functionReplaceFromExcel === null) { |
2440 | 2440 | self::$functionReplaceFromExcel = array(); |
2441 | 2441 | foreach (array_keys(self::$localeFunctions) as $excelFunctionName) { |
2442 | - self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui'; |
|
2442 | + self::$functionReplaceFromExcel[] = '/(@?[^\w\.])' . preg_quote($excelFunctionName) . '([\s]*\()/Ui'; |
|
2443 | 2443 | } |
2444 | 2444 | foreach (array_keys(self::$localeBoolean) as $excelBoolean) { |
2445 | - self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; |
|
2445 | + self::$functionReplaceFromExcel[] = '/(@?[^\w\.])' . preg_quote($excelBoolean) . '([^\w\.])/Ui'; |
|
2446 | 2446 | } |
2447 | 2447 | } |
2448 | 2448 | |
2449 | 2449 | if (self::$functionReplaceToLocale === null) { |
2450 | 2450 | self::$functionReplaceToLocale = array(); |
2451 | 2451 | foreach (array_values(self::$localeFunctions) as $localeFunctionName) { |
2452 | - self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2'; |
|
2452 | + self::$functionReplaceToLocale[] = '$1' . trim($localeFunctionName) . '$2'; |
|
2453 | 2453 | } |
2454 | 2454 | foreach (array_values(self::$localeBoolean) as $localeBoolean) { |
2455 | - self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2'; |
|
2455 | + self::$functionReplaceToLocale[] = '$1' . trim($localeBoolean) . '$2'; |
|
2456 | 2456 | } |
2457 | 2457 | } |
2458 | 2458 | |
@@ -2468,20 +2468,20 @@ discard block |
||
2468 | 2468 | if (self::$functionReplaceFromLocale === null) { |
2469 | 2469 | self::$functionReplaceFromLocale = array(); |
2470 | 2470 | foreach (array_values(self::$localeFunctions) as $localeFunctionName) { |
2471 | - self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui'; |
|
2471 | + self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($localeFunctionName) . '([\s]*\()/Ui'; |
|
2472 | 2472 | } |
2473 | 2473 | foreach (array_values(self::$localeBoolean) as $excelBoolean) { |
2474 | - self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; |
|
2474 | + self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($excelBoolean) . '([^\w\.])/Ui'; |
|
2475 | 2475 | } |
2476 | 2476 | } |
2477 | 2477 | |
2478 | 2478 | if (self::$functionReplaceToExcel === null) { |
2479 | 2479 | self::$functionReplaceToExcel = array(); |
2480 | 2480 | foreach (array_keys(self::$localeFunctions) as $excelFunctionName) { |
2481 | - self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2'; |
|
2481 | + self::$functionReplaceToExcel[] = '$1' . trim($excelFunctionName) . '$2'; |
|
2482 | 2482 | } |
2483 | 2483 | foreach (array_keys(self::$localeBoolean) as $excelBoolean) { |
2484 | - self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2'; |
|
2484 | + self::$functionReplaceToExcel[] = '$1' . trim($excelBoolean) . '$2'; |
|
2485 | 2485 | } |
2486 | 2486 | } |
2487 | 2487 | |
@@ -2517,12 +2517,12 @@ discard block |
||
2517 | 2517 | { |
2518 | 2518 | if (is_string($value)) { |
2519 | 2519 | // Error values cannot be "wrapped" |
2520 | - if (preg_match('/^'.self::CALCULATION_REGEXP_ERROR.'$/i', $value, $match)) { |
|
2520 | + if (preg_match('/^' . self::CALCULATION_REGEXP_ERROR . '$/i', $value, $match)) { |
|
2521 | 2521 | // Return Excel errors "as is" |
2522 | 2522 | return $value; |
2523 | 2523 | } |
2524 | 2524 | // Return strings wrapped in quotes |
2525 | - return '"'.$value.'"'; |
|
2525 | + return '"' . $value . '"'; |
|
2526 | 2526 | // Convert numeric errors to NaN error |
2527 | 2527 | } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { |
2528 | 2528 | return Calculation\Functions::NAN(); |
@@ -2842,7 +2842,7 @@ discard block |
||
2842 | 2842 | // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller |
2843 | 2843 | self::resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); |
2844 | 2844 | } |
2845 | - return array( $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); |
|
2845 | + return array($matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); |
|
2846 | 2846 | } |
2847 | 2847 | |
2848 | 2848 | |
@@ -2928,14 +2928,14 @@ discard block |
||
2928 | 2928 | if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { |
2929 | 2929 | if ($matrix2Columns < $matrix1Columns) { |
2930 | 2930 | for ($i = 0; $i < $matrix2Rows; ++$i) { |
2931 | - $x = $matrix2[$i][$matrix2Columns-1]; |
|
2931 | + $x = $matrix2[$i][$matrix2Columns - 1]; |
|
2932 | 2932 | for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) { |
2933 | 2933 | $matrix2[$i][$j] = $x; |
2934 | 2934 | } |
2935 | 2935 | } |
2936 | 2936 | } |
2937 | 2937 | if ($matrix2Rows < $matrix1Rows) { |
2938 | - $x = $matrix2[$matrix2Rows-1]; |
|
2938 | + $x = $matrix2[$matrix2Rows - 1]; |
|
2939 | 2939 | for ($i = 0; $i < $matrix1Rows; ++$i) { |
2940 | 2940 | $matrix2[$i] = $x; |
2941 | 2941 | } |
@@ -2945,14 +2945,14 @@ discard block |
||
2945 | 2945 | if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) { |
2946 | 2946 | if ($matrix1Columns < $matrix2Columns) { |
2947 | 2947 | for ($i = 0; $i < $matrix1Rows; ++$i) { |
2948 | - $x = $matrix1[$i][$matrix1Columns-1]; |
|
2948 | + $x = $matrix1[$i][$matrix1Columns - 1]; |
|
2949 | 2949 | for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) { |
2950 | 2950 | $matrix1[$i][$j] = $x; |
2951 | 2951 | } |
2952 | 2952 | } |
2953 | 2953 | } |
2954 | 2954 | if ($matrix1Rows < $matrix2Rows) { |
2955 | - $x = $matrix1[$matrix1Rows-1]; |
|
2955 | + $x = $matrix1[$matrix1Rows - 1]; |
|
2956 | 2956 | for ($i = 0; $i < $matrix2Rows; ++$i) { |
2957 | 2957 | $matrix1[$i] = $x; |
2958 | 2958 | } |
@@ -2986,9 +2986,9 @@ discard block |
||
2986 | 2986 | $returnMatrix[] = $this->showValue($row); |
2987 | 2987 | } |
2988 | 2988 | } |
2989 | - return '{ '.implode($rpad, $returnMatrix).' }'; |
|
2989 | + return '{ ' . implode($rpad, $returnMatrix) . ' }'; |
|
2990 | 2990 | } elseif (is_string($value) && (trim($value, '"') == $value)) { |
2991 | - return '"'.$value.'"'; |
|
2991 | + return '"' . $value . '"'; |
|
2992 | 2992 | } elseif (is_bool($value)) { |
2993 | 2993 | return ($value) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE']; |
2994 | 2994 | } |
@@ -3025,12 +3025,12 @@ discard block |
||
3025 | 3025 | if ($value == '') { |
3026 | 3026 | return 'an empty string'; |
3027 | 3027 | } elseif ($value{0} == '#') { |
3028 | - return 'a '.$value.' error'; |
|
3028 | + return 'a ' . $value . ' error'; |
|
3029 | 3029 | } else { |
3030 | 3030 | $typeString = 'a string'; |
3031 | 3031 | } |
3032 | 3032 | } |
3033 | - return $typeString.' with a value of '.$this->showValue($value); |
|
3033 | + return $typeString . ' with a value of ' . $this->showValue($value); |
|
3034 | 3034 | } |
3035 | 3035 | } |
3036 | 3036 | |
@@ -3096,31 +3096,31 @@ discard block |
||
3096 | 3096 | // Binary Operators |
3097 | 3097 | // These operators always work on two values |
3098 | 3098 | // Array key is the operator, the value indicates whether this is a left or right associative operator |
3099 | - private static $operatorAssociativity = array( |
|
3100 | - '^' => 0, // Exponentiation |
|
3101 | - '*' => 0, '/' => 0, // Multiplication and Division |
|
3102 | - '+' => 0, '-' => 0, // Addition and Subtraction |
|
3103 | - '&' => 0, // Concatenation |
|
3104 | - '|' => 0, ':' => 0, // Intersect and Range |
|
3099 | + private static $operatorAssociativity = array( |
|
3100 | + '^' => 0, // Exponentiation |
|
3101 | + '*' => 0, '/' => 0, // Multiplication and Division |
|
3102 | + '+' => 0, '-' => 0, // Addition and Subtraction |
|
3103 | + '&' => 0, // Concatenation |
|
3104 | + '|' => 0, ':' => 0, // Intersect and Range |
|
3105 | 3105 | '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison |
3106 | 3106 | ); |
3107 | 3107 | |
3108 | 3108 | // Comparison (Boolean) Operators |
3109 | 3109 | // These operators work on two values, but always return a boolean result |
3110 | - private static $comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); |
|
3110 | + private static $comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); |
|
3111 | 3111 | |
3112 | 3112 | // Operator Precedence |
3113 | 3113 | // This list includes all valid operators, whether binary (including boolean) or unary (such as %) |
3114 | 3114 | // Array key is the operator, the value is its precedence |
3115 | - private static $operatorPrecedence = array( |
|
3116 | - ':' => 8, // Range |
|
3117 | - '|' => 7, // Intersect |
|
3118 | - '~' => 6, // Negation |
|
3119 | - '%' => 5, // Percentage |
|
3120 | - '^' => 4, // Exponentiation |
|
3121 | - '*' => 3, '/' => 3, // Multiplication and Division |
|
3122 | - '+' => 2, '-' => 2, // Addition and Subtraction |
|
3123 | - '&' => 1, // Concatenation |
|
3115 | + private static $operatorPrecedence = array( |
|
3116 | + ':' => 8, // Range |
|
3117 | + '|' => 7, // Intersect |
|
3118 | + '~' => 6, // Negation |
|
3119 | + '%' => 5, // Percentage |
|
3120 | + '^' => 4, // Exponentiation |
|
3121 | + '*' => 3, '/' => 3, // Multiplication and Division |
|
3122 | + '+' => 2, '-' => 2, // Addition and Subtraction |
|
3123 | + '&' => 1, // Concatenation |
|
3124 | 3124 | '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison |
3125 | 3125 | ); |
3126 | 3126 | |
@@ -3135,22 +3135,22 @@ discard block |
||
3135 | 3135 | // so we store the parent worksheet so that we can re-attach it when necessary |
3136 | 3136 | $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null; |
3137 | 3137 | |
3138 | - $regexpMatchString = '/^('.self::CALCULATION_REGEXP_FUNCTION. |
|
3139 | - '|'.self::CALCULATION_REGEXP_CELLREF. |
|
3140 | - '|'.self::CALCULATION_REGEXP_NUMBER. |
|
3141 | - '|'.self::CALCULATION_REGEXP_STRING. |
|
3142 | - '|'.self::CALCULATION_REGEXP_OPENBRACE. |
|
3143 | - '|'.self::CALCULATION_REGEXP_NAMEDRANGE. |
|
3144 | - '|'.self::CALCULATION_REGEXP_ERROR. |
|
3138 | + $regexpMatchString = '/^(' . self::CALCULATION_REGEXP_FUNCTION . |
|
3139 | + '|' . self::CALCULATION_REGEXP_CELLREF . |
|
3140 | + '|' . self::CALCULATION_REGEXP_NUMBER . |
|
3141 | + '|' . self::CALCULATION_REGEXP_STRING . |
|
3142 | + '|' . self::CALCULATION_REGEXP_OPENBRACE . |
|
3143 | + '|' . self::CALCULATION_REGEXP_NAMEDRANGE . |
|
3144 | + '|' . self::CALCULATION_REGEXP_ERROR . |
|
3145 | 3145 | ')/si'; |
3146 | 3146 | |
3147 | 3147 | // Start with initialisation |
3148 | 3148 | $index = 0; |
3149 | 3149 | $stack = new Calculation\Token\Stack; |
3150 | 3150 | $output = array(); |
3151 | - $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a |
|
3151 | + $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a |
|
3152 | 3152 | // - is a negation or + is a positive operator rather than an operation |
3153 | - $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand |
|
3153 | + $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand |
|
3154 | 3154 | // should be null in a function call |
3155 | 3155 | // The guts of the lexical parser |
3156 | 3156 | // Loop through the formula extracting each operator and operand in turn |
@@ -3158,7 +3158,7 @@ discard block |
||
3158 | 3158 | //echo 'Assessing Expression '.substr($formula, $index), PHP_EOL; |
3159 | 3159 | $opCharacter = $formula{$index}; // Get the first character of the value at the current index position |
3160 | 3160 | //echo 'Initial character of expression block is '.$opCharacter, PHP_EOL; |
3161 | - if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula{$index+1}]))) { |
|
3161 | + if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula{$index + 1}]))) { |
|
3162 | 3162 | $opCharacter .= $formula{++$index}; |
3163 | 3163 | //echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL; |
3164 | 3164 | } |
@@ -3170,26 +3170,26 @@ discard block |
||
3170 | 3170 | |
3171 | 3171 | if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus? |
3172 | 3172 | //echo 'Element is a Negation operator', PHP_EOL; |
3173 | - $stack->push('Unary Operator', '~'); // Put a negation on the stack |
|
3174 | - ++$index; // and drop the negation symbol |
|
3173 | + $stack->push('Unary Operator', '~'); // Put a negation on the stack |
|
3174 | + ++$index; // and drop the negation symbol |
|
3175 | 3175 | } elseif ($opCharacter == '%' && $expectingOperator) { |
3176 | 3176 | //echo 'Element is a Percentage operator', PHP_EOL; |
3177 | - $stack->push('Unary Operator', '%'); // Put a percentage on the stack |
|
3177 | + $stack->push('Unary Operator', '%'); // Put a percentage on the stack |
|
3178 | 3178 | ++$index; |
3179 | 3179 | } elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded? |
3180 | 3180 | //echo 'Element is a Positive number, not Plus operator', PHP_EOL; |
3181 | - ++$index; // Drop the redundant plus symbol |
|
3181 | + ++$index; // Drop the redundant plus symbol |
|
3182 | 3182 | } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal |
3183 | - return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression |
|
3183 | + return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression |
|
3184 | 3184 | } elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? |
3185 | 3185 | //echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL; |
3186 | 3186 | while ($stack->count() > 0 && |
3187 | 3187 | ($o2 = $stack->last()) && |
3188 | 3188 | isset(self::$operators[$o2['value']]) && |
3189 | 3189 | @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { |
3190 | - $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
3190 | + $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
3191 | 3191 | } |
3192 | - $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack |
|
3192 | + $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack |
|
3193 | 3193 | ++$index; |
3194 | 3194 | $expectingOperator = false; |
3195 | 3195 | } elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis? |
@@ -3203,11 +3203,11 @@ discard block |
||
3203 | 3203 | } |
3204 | 3204 | } |
3205 | 3205 | $d = $stack->last(2); |
3206 | - if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? |
|
3207 | - $functionName = $matches[1]; // Get the function name |
|
3206 | + if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? |
|
3207 | + $functionName = $matches[1]; // Get the function name |
|
3208 | 3208 | //echo 'Closed Function is '.$functionName, PHP_EOL; |
3209 | 3209 | $d = $stack->pop(); |
3210 | - $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack) |
|
3210 | + $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack) |
|
3211 | 3211 | //if ($argumentCount == 0) { |
3212 | 3212 | // echo 'With no arguments', PHP_EOL; |
3213 | 3213 | //} elseif ($argumentCount == 1) { |
@@ -3215,8 +3215,8 @@ discard block |
||
3215 | 3215 | //} else { |
3216 | 3216 | // echo 'With '.$argumentCount.' arguments', PHP_EOL; |
3217 | 3217 | //} |
3218 | - $output[] = $d; // Dump the argument count on the output |
|
3219 | - $output[] = $stack->pop(); // Pop the function and push onto the output |
|
3218 | + $output[] = $d; // Dump the argument count on the output |
|
3219 | + $output[] = $stack->pop(); // Pop the function and push onto the output |
|
3220 | 3220 | if (isset(self::$controlFunctions[$functionName])) { |
3221 | 3221 | //echo 'Built-in function '.$functionName, PHP_EOL; |
3222 | 3222 | $expectedArgumentCount = self::$controlFunctions[$functionName]['argumentCount']; |
@@ -3235,7 +3235,7 @@ discard block |
||
3235 | 3235 | //echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount), PHP_EOL; |
3236 | 3236 | if ($argumentCount > abs($expectedArgumentCount)) { |
3237 | 3237 | $argumentCountError = true; |
3238 | - $expectedArgumentCountString = 'no more than '.abs($expectedArgumentCount); |
|
3238 | + $expectedArgumentCountString = 'no more than ' . abs($expectedArgumentCount); |
|
3239 | 3239 | } |
3240 | 3240 | } else { |
3241 | 3241 | //echo '$expectedArgumentCount is numeric '.$expectedArgumentCount, PHP_EOL; |
@@ -3252,25 +3252,25 @@ discard block |
||
3252 | 3252 | case '+': |
3253 | 3253 | if ($argumentCount < $argMatch[1]) { |
3254 | 3254 | $argumentCountError = true; |
3255 | - $expectedArgumentCountString = $argMatch[1].' or more '; |
|
3255 | + $expectedArgumentCountString = $argMatch[1] . ' or more '; |
|
3256 | 3256 | } |
3257 | 3257 | break; |
3258 | 3258 | case '-': |
3259 | 3259 | if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) { |
3260 | 3260 | $argumentCountError = true; |
3261 | - $expectedArgumentCountString = 'between '.$argMatch[1].' and '.$argMatch[3]; |
|
3261 | + $expectedArgumentCountString = 'between ' . $argMatch[1] . ' and ' . $argMatch[3]; |
|
3262 | 3262 | } |
3263 | 3263 | break; |
3264 | 3264 | case ',': |
3265 | 3265 | if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) { |
3266 | 3266 | $argumentCountError = true; |
3267 | - $expectedArgumentCountString = 'either '.$argMatch[1].' or '.$argMatch[3]; |
|
3267 | + $expectedArgumentCountString = 'either ' . $argMatch[1] . ' or ' . $argMatch[3]; |
|
3268 | 3268 | } |
3269 | 3269 | break; |
3270 | 3270 | } |
3271 | 3271 | } |
3272 | 3272 | if ($argumentCountError) { |
3273 | - return $this->raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString." expected"); |
|
3273 | + return $this->raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, " . $expectedArgumentCountString . " expected"); |
|
3274 | 3274 | } |
3275 | 3275 | } |
3276 | 3276 | ++$index; |
@@ -3280,7 +3280,7 @@ discard block |
||
3280 | 3280 | if ($o2 === null) { |
3281 | 3281 | return $this->raiseFormulaError("Formula Error: Unexpected ,"); |
3282 | 3282 | } else { |
3283 | - $output[] = $o2; // pop the argument expression stuff and push onto the output |
|
3283 | + $output[] = $o2; // pop the argument expression stuff and push onto the output |
|
3284 | 3284 | } |
3285 | 3285 | } |
3286 | 3286 | // If we've a comma when we're expecting an operand, then what we actually have is a null operand; |
@@ -3290,12 +3290,12 @@ discard block |
||
3290 | 3290 | } |
3291 | 3291 | // make sure there was a function |
3292 | 3292 | $d = $stack->last(2); |
3293 | - if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { |
|
3293 | + if (!preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { |
|
3294 | 3294 | return $this->raiseFormulaError("Formula Error: Unexpected ,"); |
3295 | 3295 | } |
3296 | 3296 | $d = $stack->pop(); |
3297 | - $stack->push($d['type'], ++$d['value'], $d['reference']); // increment the argument count |
|
3298 | - $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again |
|
3297 | + $stack->push($d['type'], ++$d['value'], $d['reference']); // increment the argument count |
|
3298 | + $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again |
|
3299 | 3299 | $expectingOperator = false; |
3300 | 3300 | $expectingOperand = true; |
3301 | 3301 | ++$index; |
@@ -3310,24 +3310,24 @@ discard block |
||
3310 | 3310 | $length = strlen($val); |
3311 | 3311 | // echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />'; |
3312 | 3312 | |
3313 | - if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) { |
|
3313 | + if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $val, $matches)) { |
|
3314 | 3314 | $val = preg_replace('/\s/u', '', $val); |
3315 | 3315 | // echo 'Element '.$val.' is a Function<br />'; |
3316 | 3316 | if (isset(self::$phpSpreadsheetFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function |
3317 | 3317 | $stack->push('Function', strtoupper($val)); |
3318 | - $ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index+$length), $amatch); |
|
3318 | + $ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index + $length), $amatch); |
|
3319 | 3319 | if ($ax) { |
3320 | - $stack->push('Operand Count for Function '.strtoupper($val).')', 0); |
|
3320 | + $stack->push('Operand Count for Function ' . strtoupper($val) . ')', 0); |
|
3321 | 3321 | $expectingOperator = true; |
3322 | 3322 | } else { |
3323 | - $stack->push('Operand Count for Function '.strtoupper($val).')', 1); |
|
3323 | + $stack->push('Operand Count for Function ' . strtoupper($val) . ')', 1); |
|
3324 | 3324 | $expectingOperator = false; |
3325 | 3325 | } |
3326 | 3326 | $stack->push('Brace', '('); |
3327 | 3327 | } else { // it's a var w/ implicit multiplication |
3328 | 3328 | $output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => null); |
3329 | 3329 | } |
3330 | - } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $val, $matches)) { |
|
3330 | + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $val, $matches)) { |
|
3331 | 3331 | // echo 'Element '.$val.' is a Cell reference<br />'; |
3332 | 3332 | // Watch for this case-change when modifying to allow cell references in different worksheets... |
3333 | 3333 | // Should only be applied to the actual cell column, not the worksheet name |
@@ -3339,10 +3339,10 @@ discard block |
||
3339 | 3339 | if ($matches[2] == '') { |
3340 | 3340 | // Otherwise, we 'inherit' the worksheet reference from the start cell reference |
3341 | 3341 | // The start of the cell range reference should be the last entry in $output |
3342 | - $startCellRef = $output[count($output)-1]['value']; |
|
3343 | - preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $startCellRef, $startMatches); |
|
3342 | + $startCellRef = $output[count($output) - 1]['value']; |
|
3343 | + preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $startCellRef, $startMatches); |
|
3344 | 3344 | if ($startMatches[2] > '') { |
3345 | - $val = $startMatches[2].'!'.$val; |
|
3345 | + $val = $startMatches[2] . '!' . $val; |
|
3346 | 3346 | } |
3347 | 3347 | } else { |
3348 | 3348 | return $this->raiseFormulaError("3D Range references are not yet supported"); |
@@ -3356,7 +3356,7 @@ discard block |
||
3356 | 3356 | // If the last entry on the stack was a : operator, then we may have a row or column range reference |
3357 | 3357 | $testPrevOp = $stack->last(1); |
3358 | 3358 | if ($testPrevOp['value'] == ':') { |
3359 | - $startRowColRef = $output[count($output)-1]['value']; |
|
3359 | + $startRowColRef = $output[count($output) - 1]['value']; |
|
3360 | 3360 | $rangeWS1 = ''; |
3361 | 3361 | if (strpos('!', $startRowColRef) !== false) { |
3362 | 3362 | list($rangeWS1, $startRowColRef) = explode('!', $startRowColRef); |
@@ -3374,15 +3374,15 @@ discard block |
||
3374 | 3374 | if ((is_integer($startRowColRef)) && (ctype_digit($val)) && |
3375 | 3375 | ($startRowColRef <= 1048576) && ($val <= 1048576)) { |
3376 | 3376 | // Row range |
3377 | - $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 |
|
3378 | - $output[count($output)-1]['value'] = $rangeWS1.'A'.$startRowColRef; |
|
3379 | - $val = $rangeWS2.$endRowColRef.$val; |
|
3377 | + $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 |
|
3378 | + $output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef; |
|
3379 | + $val = $rangeWS2 . $endRowColRef . $val; |
|
3380 | 3380 | } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && |
3381 | 3381 | (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) { |
3382 | 3382 | // Column range |
3383 | - $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 |
|
3384 | - $output[count($output)-1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1'; |
|
3385 | - $val = $rangeWS2.$val.$endRowColRef; |
|
3383 | + $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 |
|
3384 | + $output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1'; |
|
3385 | + $val = $rangeWS2 . $val . $endRowColRef; |
|
3386 | 3386 | } |
3387 | 3387 | } |
3388 | 3388 | |
@@ -3451,16 +3451,16 @@ discard block |
||
3451 | 3451 | // If we're expecting an operator, but only have a space between the previous and next operands (and both are |
3452 | 3452 | // Cell References) then we have an INTERSECTION operator |
3453 | 3453 | // echo 'Possible Intersect Operator<br />'; |
3454 | - if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/Ui', substr($formula, $index), $match)) && |
|
3455 | - ($output[count($output)-1]['type'] == 'Cell Reference')) { |
|
3454 | + if (($expectingOperator) && (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && |
|
3455 | + ($output[count($output) - 1]['type'] == 'Cell Reference')) { |
|
3456 | 3456 | // echo 'Element is an Intersect Operator<br />'; |
3457 | 3457 | while ($stack->count() > 0 && |
3458 | 3458 | ($o2 = $stack->last()) && |
3459 | 3459 | isset(self::$operators[$o2['value']]) && |
3460 | 3460 | @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { |
3461 | - $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
3461 | + $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
3462 | 3462 | } |
3463 | - $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack |
|
3463 | + $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack |
|
3464 | 3464 | $expectingOperator = false; |
3465 | 3465 | } |
3466 | 3466 | } |
@@ -3468,7 +3468,7 @@ discard block |
||
3468 | 3468 | |
3469 | 3469 | while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output |
3470 | 3470 | if ((is_array($op) && $op['value'] == '(') || ($op === '(')) { |
3471 | - return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced |
|
3471 | + return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced |
|
3472 | 3472 | } |
3473 | 3473 | $output[] = $op; |
3474 | 3474 | } |
@@ -3485,7 +3485,7 @@ discard block |
||
3485 | 3485 | $cKeys = array_keys(array_keys($operand[$rowKey])); |
3486 | 3486 | $colKey = array_shift($cKeys); |
3487 | 3487 | if (ctype_upper($colKey)) { |
3488 | - $operandData['reference'] = $colKey.$rowKey; |
|
3488 | + $operandData['reference'] = $colKey . $rowKey; |
|
3489 | 3489 | } |
3490 | 3490 | } |
3491 | 3491 | return $operand; |
@@ -3558,20 +3558,20 @@ discard block |
||
3558 | 3558 | if ($sheet1 == $sheet2) { |
3559 | 3559 | if ($operand1Data['reference'] === null) { |
3560 | 3560 | if ((trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) { |
3561 | - $operand1Data['reference'] = $pCell->getColumn().$operand1Data['value']; |
|
3561 | + $operand1Data['reference'] = $pCell->getColumn() . $operand1Data['value']; |
|
3562 | 3562 | } elseif (trim($operand1Data['reference']) == '') { |
3563 | 3563 | $operand1Data['reference'] = $pCell->getCoordinate(); |
3564 | 3564 | } else { |
3565 | - $operand1Data['reference'] = $operand1Data['value'].$pCell->getRow(); |
|
3565 | + $operand1Data['reference'] = $operand1Data['value'] . $pCell->getRow(); |
|
3566 | 3566 | } |
3567 | 3567 | } |
3568 | 3568 | if ($operand2Data['reference'] === null) { |
3569 | 3569 | if ((trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) { |
3570 | - $operand2Data['reference'] = $pCell->getColumn().$operand2Data['value']; |
|
3570 | + $operand2Data['reference'] = $pCell->getColumn() . $operand2Data['value']; |
|
3571 | 3571 | } elseif (trim($operand2Data['reference']) == '') { |
3572 | 3572 | $operand2Data['reference'] = $pCell->getCoordinate(); |
3573 | 3573 | } else { |
3574 | - $operand2Data['reference'] = $operand2Data['value'].$pCell->getRow(); |
|
3574 | + $operand2Data['reference'] = $operand2Data['value'] . $pCell->getRow(); |
|
3575 | 3575 | } |
3576 | 3576 | } |
3577 | 3577 | |
@@ -3582,7 +3582,7 @@ discard block |
||
3582 | 3582 | $oCol[] = Cell::columnIndexFromString($oCR[0]) - 1; |
3583 | 3583 | $oRow[] = $oCR[1]; |
3584 | 3584 | } |
3585 | - $cellRef = Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.Cell::stringFromColumnIndex(max($oCol)).max($oRow); |
|
3585 | + $cellRef = Cell::stringFromColumnIndex(min($oCol)) . min($oRow) . ':' . Cell::stringFromColumnIndex(max($oCol)) . max($oRow); |
|
3586 | 3586 | if ($pCellParent !== null) { |
3587 | 3587 | $cellValue = $this->extractCellRange($cellRef, $this->spreadsheet->getSheetByName($sheet1), false); |
3588 | 3588 | } else { |
@@ -3632,7 +3632,7 @@ discard block |
||
3632 | 3632 | $result = '#VALUE!'; |
3633 | 3633 | } |
3634 | 3634 | } else { |
3635 | - $result = '"'.str_replace('""', '"', self::unwrapResult($operand1, '"').self::unwrapResult($operand2, '"')).'"'; |
|
3635 | + $result = '"' . str_replace('""', '"', self::unwrapResult($operand1, '"') . self::unwrapResult($operand2, '"')) . '"'; |
|
3636 | 3636 | } |
3637 | 3637 | $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); |
3638 | 3638 | $stack->push('Value', $result); |
@@ -3647,7 +3647,7 @@ discard block |
||
3647 | 3647 | $cellIntersect[$row] = array_intersect_key($operand1[$row], $operand2[$row]); |
3648 | 3648 | } |
3649 | 3649 | } |
3650 | - $cellRef = Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.Cell::stringFromColumnIndex(max($oCol)).max($oRow); |
|
3650 | + $cellRef = Cell::stringFromColumnIndex(min($oCol)) . min($oRow) . ':' . Cell::stringFromColumnIndex(max($oCol)) . max($oRow); |
|
3651 | 3651 | $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect)); |
3652 | 3652 | $stack->push('Value', $cellIntersect, $cellRef); |
3653 | 3653 | break; |
@@ -3684,7 +3684,7 @@ discard block |
||
3684 | 3684 | } else { |
3685 | 3685 | $this->executeNumericBinaryOperation($cellID, $multiplier, $arg, '*', 'arrayTimesEquals', $stack); |
3686 | 3686 | } |
3687 | - } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) { |
|
3687 | + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $token, $matches)) { |
|
3688 | 3688 | $cellRef = null; |
3689 | 3689 | // echo 'Element '.$token.' is a Cell reference<br />'; |
3690 | 3690 | if (isset($matches[8])) { |
@@ -3693,7 +3693,7 @@ discard block |
||
3693 | 3693 | // We can't access the range, so return a REF error |
3694 | 3694 | $cellValue = Calculation\Functions::REF(); |
3695 | 3695 | } else { |
3696 | - $cellRef = $matches[6].$matches[7].':'.$matches[9].$matches[10]; |
|
3696 | + $cellRef = $matches[6] . $matches[7] . ':' . $matches[9] . $matches[10]; |
|
3697 | 3697 | if ($matches[2] > '') { |
3698 | 3698 | $matches[2] = trim($matches[2], "\"'"); |
3699 | 3699 | if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { |
@@ -3727,7 +3727,7 @@ discard block |
||
3727 | 3727 | // We can't access the cell, so return a REF error |
3728 | 3728 | $cellValue = Calculation\Functions::REF(); |
3729 | 3729 | } else { |
3730 | - $cellRef = $matches[6].$matches[7]; |
|
3730 | + $cellRef = $matches[6] . $matches[7]; |
|
3731 | 3731 | if ($matches[2] > '') { |
3732 | 3732 | $matches[2] = trim($matches[2], "\"'"); |
3733 | 3733 | if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { |
@@ -3765,7 +3765,7 @@ discard block |
||
3765 | 3765 | $stack->push('Value', $cellValue, $cellRef); |
3766 | 3766 | |
3767 | 3767 | // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on |
3768 | - } elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $token, $matches)) { |
|
3768 | + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) { |
|
3769 | 3769 | // echo 'Token is a function<br />'; |
3770 | 3770 | $functionName = $matches[1]; |
3771 | 3771 | $argCount = $stack->pop(); |
@@ -3822,7 +3822,7 @@ discard block |
||
3822 | 3822 | if ($functionName != 'MKMATRIX') { |
3823 | 3823 | if ($this->_debugLog->getWriteDebugLog()) { |
3824 | 3824 | krsort($argArrayVals); |
3825 | - $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', implode(self::$localeArgumentSeparator.' ', Calculation\Functions::flattenArray($argArrayVals)), ' )'); |
|
3825 | + $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', implode(self::$localeArgumentSeparator . ' ', Calculation\Functions::flattenArray($argArrayVals)), ' )'); |
|
3826 | 3826 | } |
3827 | 3827 | } |
3828 | 3828 | // Process each argument in turn, building the return value as an array |
@@ -3877,7 +3877,7 @@ discard block |
||
3877 | 3877 | // echo 'Token is a number, boolean, string, null or an Excel error<br />'; |
3878 | 3878 | $stack->push('Value', $token); |
3879 | 3879 | // if the token is a named range, push the named range name onto the stack |
3880 | - } elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) { |
|
3880 | + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) { |
|
3881 | 3881 | // echo 'Token is a named range<br />'; |
3882 | 3882 | $namedRange = $matches[6]; |
3883 | 3883 | // echo 'Named Range is '.$namedRange.'<br />'; |
@@ -4105,8 +4105,8 @@ discard block |
||
4105 | 4105 | } |
4106 | 4106 | } else { |
4107 | 4107 | if ((Calculation\Functions::getCompatibilityMode() != Calculation\Functions::COMPATIBILITY_OPENOFFICE) && |
4108 | - ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1)>0) || |
|
4109 | - (is_string($operand2) && !is_numeric($operand2) && strlen($operand2)>0))) { |
|
4108 | + ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0) || |
|
4109 | + (is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0))) { |
|
4110 | 4110 | $result = Calculation\Functions::VALUE(); |
4111 | 4111 | } else { |
4112 | 4112 | // If we're dealing with non-matrix operations, execute the necessary operation |
@@ -4174,7 +4174,7 @@ discard block |
||
4174 | 4174 | public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) |
4175 | 4175 | { |
4176 | 4176 | // Return value |
4177 | - $returnValue = array (); |
|
4177 | + $returnValue = array(); |
|
4178 | 4178 | |
4179 | 4179 | // echo 'extractCellRange('.$pRange.')', PHP_EOL; |
4180 | 4180 | if ($pSheet !== null) { |
@@ -4191,7 +4191,7 @@ discard block |
||
4191 | 4191 | |
4192 | 4192 | // Extract range |
4193 | 4193 | $aReferences = Cell::extractAllCellReferencesInRange($pRange); |
4194 | - $pRange = $pSheetName.'!'.$pRange; |
|
4194 | + $pRange = $pSheetName . '!' . $pRange; |
|
4195 | 4195 | if (!isset($aReferences[1])) { |
4196 | 4196 | // Single cell in range |
4197 | 4197 | sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow); |
@@ -4232,7 +4232,7 @@ discard block |
||
4232 | 4232 | public function extractNamedRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) |
4233 | 4233 | { |
4234 | 4234 | // Return value |
4235 | - $returnValue = array (); |
|
4235 | + $returnValue = array(); |
|
4236 | 4236 | |
4237 | 4237 | // echo 'extractNamedRange('.$pRange.')<br />'; |
4238 | 4238 | if ($pSheet !== null) { |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | return true; |
111 | 111 | } |
112 | 112 | // Check if the requested entry still exists in Memcache |
113 | - $success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache'); |
|
113 | + $success = $this->memcache->get($this->cachePrefix . $pCoord . '.cache'); |
|
114 | 114 | if ($success === false) { |
115 | 115 | // Entry no longer exists in Memcache, so clear it from the cache array |
116 | 116 | parent::deleteCacheData($pCoord); |
117 | - throw new \PhpSpreadsheet\Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); |
|
117 | + throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in MemCache'); |
|
118 | 118 | } |
119 | 119 | return true; |
120 | 120 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $cacheList = $this->getCellList(); |
204 | 204 | foreach ($cacheList as $cellID) { |
205 | 205 | if ($cellID != $this->currentObjectID) { |
206 | - $obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache'); |
|
206 | + $obj = $this->memcache->get($this->cachePrefix . $cellID . '.cache'); |
|
207 | 207 | if ($obj === false) { |
208 | 208 | // Entry no longer exists in Memcache, so clear it from the cache array |
209 | 209 | parent::deleteCacheData($cellID); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | { |
287 | 287 | $cacheList = $this->getCellList(); |
288 | 288 | foreach ($cacheList as $cellID) { |
289 | - $this->memcache->delete($this->cachePrefix.$cellID . '.cache'); |
|
289 | + $this->memcache->delete($this->cachePrefix . $cellID . '.cache'); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | return true; |
107 | 107 | } |
108 | 108 | // Check if the requested entry still exists in apc |
109 | - $success = apc_fetch($this->cachePrefix.$pCoord.'.cache'); |
|
109 | + $success = apc_fetch($this->cachePrefix . $pCoord . '.cache'); |
|
110 | 110 | if ($success === false) { |
111 | 111 | // Entry no longer exists in APC, so clear it from the cache array |
112 | 112 | parent::deleteCacheData($pCoord); |
113 | - throw new \PhpSpreadsheet\Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); |
|
113 | + throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in APC cache'); |
|
114 | 114 | } |
115 | 115 | return true; |
116 | 116 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | if ($obj === false) { |
139 | 139 | // Entry no longer exists in APC, so clear it from the cache array |
140 | 140 | parent::deleteCacheData($pCoord); |
141 | - throw new \PhpSpreadsheet\Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); |
|
141 | + throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in APC cache'); |
|
142 | 142 | } |
143 | 143 | } else { |
144 | 144 | // Return null if requested entry doesn't exist in cache |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | public function deleteCacheData($pCoord) |
180 | 180 | { |
181 | 181 | // Delete the entry from APC |
182 | - apc_delete($this->cachePrefix.$pCoord.'.cache'); |
|
182 | + apc_delete($this->cachePrefix . $pCoord . '.cache'); |
|
183 | 183 | |
184 | 184 | // Delete the entry from our cell address array |
185 | 185 | parent::deleteCacheData($pCoord); |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | $this->currentObject->detach(); |
55 | 55 | |
56 | 56 | $obj = serialize($this->currentObject); |
57 | - if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) { |
|
58 | - if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) { |
|
57 | + if (wincache_ucache_exists($this->cachePrefix . $this->currentObjectID . '.cache')) { |
|
58 | + if (!wincache_ucache_set($this->cachePrefix . $this->currentObjectID . '.cache', $obj, $this->cacheTime)) { |
|
59 | 59 | $this->__destruct(); |
60 | - throw new \PhpSpreadsheet\Exception('Failed to store cell '.$this->currentObjectID.' in WinCache'); |
|
60 | + throw new \PhpSpreadsheet\Exception('Failed to store cell ' . $this->currentObjectID . ' in WinCache'); |
|
61 | 61 | } |
62 | 62 | } else { |
63 | - if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) { |
|
63 | + if (!wincache_ucache_add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, $this->cacheTime)) { |
|
64 | 64 | $this->__destruct(); |
65 | - throw new \PhpSpreadsheet\Exception('Failed to store cell '.$this->currentObjectID.' in WinCache'); |
|
65 | + throw new \PhpSpreadsheet\Exception('Failed to store cell ' . $this->currentObjectID . ' in WinCache'); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | $this->currentCellIsDirty = false; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | // Check if the requested entry still exists in cache |
111 | - $success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache'); |
|
111 | + $success = wincache_ucache_exists($this->cachePrefix . $pCoord . '.cache'); |
|
112 | 112 | if ($success === false) { |
113 | 113 | // Entry no longer exists in Wincache, so clear it from the cache array |
114 | 114 | parent::deleteCacheData($pCoord); |
115 | - throw new \PhpSpreadsheet\Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); |
|
115 | + throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in WinCache'); |
|
116 | 116 | } |
117 | 117 | return true; |
118 | 118 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | $obj = null; |
139 | 139 | if (parent::isDataSet($pCoord)) { |
140 | 140 | $success = false; |
141 | - $obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success); |
|
141 | + $obj = wincache_ucache_get($this->cachePrefix . $pCoord . '.cache', $success); |
|
142 | 142 | if ($success === false) { |
143 | 143 | // Entry no longer exists in WinCache, so clear it from the cache array |
144 | 144 | parent::deleteCacheData($pCoord); |
145 | - throw new \PhpSpreadsheet\Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); |
|
145 | + throw new \PhpSpreadsheet\Exception('Cell entry ' . $pCoord . ' no longer exists in WinCache'); |
|
146 | 146 | } |
147 | 147 | } else { |
148 | 148 | // Return null if requested entry doesn't exist in cache |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | public function deleteCacheData($pCoord) |
184 | 184 | { |
185 | 185 | // Delete the entry from Wincache |
186 | - wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache'); |
|
186 | + wincache_ucache_delete($this->cachePrefix . $pCoord . '.cache'); |
|
187 | 187 | |
188 | 188 | // Delete the entry from our cell address array |
189 | 189 | parent::deleteCacheData($pCoord); |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | foreach ($cacheList as $cellID) { |
206 | 206 | if ($cellID != $this->currentObjectID) { |
207 | 207 | $success = false; |
208 | - $obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success); |
|
208 | + $obj = wincache_ucache_get($this->cachePrefix . $cellID . '.cache', $success); |
|
209 | 209 | if ($success === false) { |
210 | 210 | // Entry no longer exists in WinCache, so clear it from the cache array |
211 | 211 | parent::deleteCacheData($cellID); |
212 | - throw new \PhpSpreadsheet\Exception('Cell entry '.$cellID.' no longer exists in Wincache'); |
|
212 | + throw new \PhpSpreadsheet\Exception('Cell entry ' . $cellID . ' no longer exists in Wincache'); |
|
213 | 213 | } |
214 | - if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) { |
|
214 | + if (!wincache_ucache_add($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) { |
|
215 | 215 | $this->__destruct(); |
216 | - throw new \PhpSpreadsheet\Exception('Failed to store cell '.$cellID.' in Wincache'); |
|
216 | + throw new \PhpSpreadsheet\Exception('Failed to store cell ' . $cellID . ' in Wincache'); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function __construct(\PhpSpreadsheet\Worksheet $parent, $arguments) |
252 | 252 | { |
253 | - $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; |
|
253 | + $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; |
|
254 | 254 | |
255 | 255 | if (is_null($this->cachePrefix)) { |
256 | 256 | $baseUnique = $this->getUniqueID(); |
257 | - $this->cachePrefix = substr(md5($baseUnique), 0, 8).'.'; |
|
257 | + $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; |
|
258 | 258 | $this->cacheTime = $cacheTime; |
259 | 259 | |
260 | 260 | parent::__construct($parent); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $cacheList = $this->getCellList(); |
270 | 270 | foreach ($cacheList as $cellID) { |
271 | - wincache_ucache_delete($this->cachePrefix.$cellID.'.cache'); |
|
271 | + wincache_ucache_delete($this->cachePrefix . $cellID . '.cache'); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | parent::copyCellCollection($parent); |
147 | 147 | // Get a new id for the new file name |
148 | 148 | $baseUnique = $this->getUniqueID(); |
149 | - $newFileName = $this->cacheDirectory.'/PhpSpreadsheet.'.$baseUnique.'.cache'; |
|
149 | + $newFileName = $this->cacheDirectory . '/PhpSpreadsheet.' . $baseUnique . '.cache'; |
|
150 | 150 | // Copy the existing cell cache file |
151 | 151 | copy($this->fileName, $newFileName); |
152 | 152 | $this->fileName = $newFileName; |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function __construct(\PhpSpreadsheet\Worksheet $parent, $arguments) |
183 | 183 | { |
184 | - $this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null)) |
|
184 | + $this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null)) |
|
185 | 185 | ? $arguments['dir'] |
186 | 186 | : \PhpSpreadsheet\Shared\File::sysGetTempDir(); |
187 | 187 | |
188 | 188 | parent::__construct($parent); |
189 | 189 | if (is_null($this->fileHandle)) { |
190 | 190 | $baseUnique = $this->getUniqueID(); |
191 | - $this->fileName = $this->cacheDirectory.'/PhpSpreadsheet.'.$baseUnique.'.cache'; |
|
191 | + $this->fileName = $this->cacheDirectory . '/PhpSpreadsheet.' . $baseUnique . '.cache'; |
|
192 | 192 | $this->fileHandle = fopen($this->fileName, 'a+'); |
193 | 193 | } |
194 | 194 | } |