@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | /** |
1853 | 1853 | * Set calculation cache expiration time |
1854 | 1854 | * |
1855 | - * @param float $pValue |
|
1855 | + * @param integer $pValue |
|
1856 | 1856 | */ |
1857 | 1857 | public function setCalculationCacheExpirationTime($pValue = 15) { |
1858 | 1858 | self::$_calculationCacheExpirationTime = $pValue; |
@@ -1966,6 +1966,10 @@ discard block |
||
1966 | 1966 | return $formula; |
1967 | 1967 | } |
1968 | 1968 | |
1969 | + /** |
|
1970 | + * @param string $fromSeparator |
|
1971 | + * @param string $toSeparator |
|
1972 | + */ |
|
1969 | 1973 | private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) { |
1970 | 1974 | // Convert any Excel function names to the required language |
1971 | 1975 | if (self::$_localeLanguage !== 'en_us') { |
@@ -2386,7 +2390,7 @@ discard block |
||
2386 | 2390 | * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0 |
2387 | 2391 | * |
2388 | 2392 | * @param mixed &$matrix matrix operand |
2389 | - * @return array An array comprising the number of rows, and number of columns |
|
2393 | + * @return integer[] An array comprising the number of rows, and number of columns |
|
2390 | 2394 | */ |
2391 | 2395 | public static function _getMatrixDimensions(&$matrix) { |
2392 | 2396 | $matrixRows = count($matrix); |
@@ -2409,6 +2413,10 @@ discard block |
||
2409 | 2413 | * |
2410 | 2414 | * @param mixed &$matrix1 First matrix operand |
2411 | 2415 | * @param mixed &$matrix2 Second matrix operand |
2416 | + * @param integer $matrix1Rows |
|
2417 | + * @param integer $matrix1Columns |
|
2418 | + * @param integer $matrix2Rows |
|
2419 | + * @param integer $matrix2Columns |
|
2412 | 2420 | */ |
2413 | 2421 | private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { |
2414 | 2422 | if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { |
@@ -2448,6 +2456,10 @@ discard block |
||
2448 | 2456 | * |
2449 | 2457 | * @param mixed &$matrix1 First matrix operand |
2450 | 2458 | * @param mixed &$matrix2 Second matrix operand |
2459 | + * @param integer $matrix1Rows |
|
2460 | + * @param integer $matrix1Columns |
|
2461 | + * @param integer $matrix2Rows |
|
2462 | + * @param integer $matrix2Columns |
|
2451 | 2463 | */ |
2452 | 2464 | private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { |
2453 | 2465 | if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { |
@@ -2525,7 +2537,7 @@ discard block |
||
2525 | 2537 | * Format type and details of an operand for display in the log (based on operand type) |
2526 | 2538 | * |
2527 | 2539 | * @param mixed $value First matrix operand |
2528 | - * @return mixed |
|
2540 | + * @return string|null |
|
2529 | 2541 | */ |
2530 | 2542 | private function _showTypeDetails($value) { |
2531 | 2543 | if ($this->writeDebugLog) { |
@@ -2558,6 +2570,9 @@ discard block |
||
2558 | 2570 | } // function _showTypeDetails() |
2559 | 2571 | |
2560 | 2572 | |
2573 | + /** |
|
2574 | + * @param string $formula |
|
2575 | + */ |
|
2561 | 2576 | private static function _convertMatrixReferences($formula) { |
2562 | 2577 | static $matrixReplaceFrom = array('{',';','}'); |
2563 | 2578 | static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))'); |
@@ -2615,6 +2630,10 @@ discard block |
||
2615 | 2630 | |
2616 | 2631 | |
2617 | 2632 | // Convert infix to postfix notation |
2633 | + |
|
2634 | + /** |
|
2635 | + * @param string $formula |
|
2636 | + */ |
|
2618 | 2637 | private function _parseFormula($formula, PHPExcel_Cell $pCell = null) { |
2619 | 2638 | if (($formula = self::_convertMatrixReferences(trim($formula))) === false) { |
2620 | 2639 | return FALSE; |
@@ -3001,6 +3020,10 @@ discard block |
||
3001 | 3020 | } |
3002 | 3021 | |
3003 | 3022 | // evaluate postfix notation |
3023 | + |
|
3024 | + /** |
|
3025 | + * @param string $cellID |
|
3026 | + */ |
|
3004 | 3027 | private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) { |
3005 | 3028 | if ($tokens == false) return false; |
3006 | 3029 | |
@@ -3500,6 +3523,9 @@ discard block |
||
3500 | 3523 | } // function _executeBinaryComparisonOperation() |
3501 | 3524 | |
3502 | 3525 | |
3526 | + /** |
|
3527 | + * @param string $matrixFunction |
|
3528 | + */ |
|
3503 | 3529 | private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) { |
3504 | 3530 | // Validate the two operands |
3505 | 3531 | if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return false; |
@@ -3580,6 +3606,9 @@ discard block |
||
3580 | 3606 | } // function _executeNumericBinaryOperation() |
3581 | 3607 | |
3582 | 3608 | |
3609 | + /** |
|
3610 | + * @param string $message |
|
3611 | + */ |
|
3583 | 3612 | private function _writeDebug($message) { |
3584 | 3613 | // Only write the debug log if logging is enabled |
3585 | 3614 | if ($this->writeDebugLog) { |
@@ -27,27 +27,27 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | -if (!defined('CALCULATION_REGEXP_CELLREF')) { |
|
39 | +if ( ! defined('CALCULATION_REGEXP_CELLREF')) { |
|
40 | 40 | // Test for support of \P (multibyte options) in PCRE |
41 | - if(defined('PREG_BAD_UTF8_ERROR')) { |
|
41 | + if (defined('PREG_BAD_UTF8_ERROR')) { |
|
42 | 42 | // Cell reference (cell or range of cells, with or without a sheet reference) |
43 | - define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})'); |
|
43 | + define('CALCULATION_REGEXP_CELLREF', '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})'); |
|
44 | 44 | // Named Range of cells |
45 | - define('CALCULATION_REGEXP_NAMEDRANGE','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)'); |
|
45 | + define('CALCULATION_REGEXP_NAMEDRANGE', '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)'); |
|
46 | 46 | } else { |
47 | 47 | // Cell reference (cell or range of cells, with or without a sheet reference) |
48 | - define('CALCULATION_REGEXP_CELLREF','(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)'); |
|
48 | + define('CALCULATION_REGEXP_CELLREF', '(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)'); |
|
49 | 49 | // Named Range of cells |
50 | - define('CALCULATION_REGEXP_NAMEDRANGE','(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)'); |
|
50 | + define('CALCULATION_REGEXP_NAMEDRANGE', '(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | // String operand |
69 | 69 | const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"'; |
70 | 70 | // Opening bracket |
71 | - const CALCULATION_REGEXP_OPENBRACE = '\('; |
|
71 | + const CALCULATION_REGEXP_OPENBRACE = '\('; |
|
72 | 72 | // Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it) |
73 | - const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('; |
|
73 | + const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('; |
|
74 | 74 | // Cell reference (cell or range of cells, with or without a sheet reference) |
75 | - const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; |
|
75 | + const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; |
|
76 | 76 | // Named Range of cells |
77 | - const CALCULATION_REGEXP_NAMEDRANGE = CALCULATION_REGEXP_NAMEDRANGE; |
|
77 | + const CALCULATION_REGEXP_NAMEDRANGE = CALCULATION_REGEXP_NAMEDRANGE; |
|
78 | 78 | // Error |
79 | - const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; |
|
79 | + const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; |
|
80 | 80 | |
81 | 81 | |
82 | 82 | /** constants */ |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | const RETURN_ARRAY_AS_VALUE = 'value'; |
85 | 85 | const RETURN_ARRAY_AS_ARRAY = 'array'; |
86 | 86 | |
87 | - private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; |
|
87 | + private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; |
|
88 | 88 | |
89 | 89 | |
90 | 90 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @access private |
103 | 103 | * @var array |
104 | 104 | */ |
105 | - private static $_calculationCache = array (); |
|
105 | + private static $_calculationCache = array(); |
|
106 | 106 | |
107 | 107 | |
108 | 108 | /** |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | * @access private |
131 | 131 | * @var array |
132 | 132 | */ |
133 | - private static $_operators = array('+' => true, '-' => true, '*' => true, '/' => true, |
|
134 | - '^' => true, '&' => true, '%' => false, '~' => false, |
|
135 | - '>' => true, '<' => true, '=' => true, '>=' => true, |
|
136 | - '<=' => true, '<>' => true, '|' => true, ':' => true |
|
133 | + private static $_operators = array('+' => true, '-' => true, '*' => true, '/' => true, |
|
134 | + '^' => true, '&' => true, '%' => false, '~' => false, |
|
135 | + '>' => true, '<' => true, '=' => true, '>=' => true, |
|
136 | + '<=' => true, '<>' => true, '|' => true, ':' => true |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | * @access private |
144 | 144 | * @var array |
145 | 145 | */ |
146 | - private static $_binaryOperators = array('+' => true, '-' => true, '*' => true, '/' => true, |
|
147 | - '^' => true, '&' => true, '>' => true, '<' => true, |
|
148 | - '=' => true, '>=' => true, '<=' => true, '<>' => true, |
|
149 | - '|' => true, ':' => true |
|
146 | + private static $_binaryOperators = array('+' => true, '-' => true, '*' => true, '/' => true, |
|
147 | + '^' => true, '&' => true, '>' => true, '<' => true, |
|
148 | + '=' => true, '>=' => true, '<=' => true, '<>' => true, |
|
149 | + '|' => true, ':' => true |
|
150 | 150 | ); |
151 | 151 | |
152 | 152 | /** |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | public $cyclicFormulaCount = 0; |
216 | 216 | |
217 | 217 | |
218 | - private $_savedPrecision = 12; |
|
218 | + private $_savedPrecision = 12; |
|
219 | 219 | |
220 | 220 | |
221 | - private static $_localeLanguage = 'en_us'; // US English (default locale) |
|
222 | - private static $_validLocaleLanguages = array( 'en' // English (default language) |
|
221 | + private static $_localeLanguage = 'en_us'; // US English (default locale) |
|
222 | + private static $_validLocaleLanguages = array('en' // English (default language) |
|
223 | 223 | ); |
224 | 224 | private static $_localeArgumentSeparator = ','; |
225 | 225 | private static $_localeFunctions = array(); |
226 | - public static $_localeBoolean = array( 'TRUE' => 'TRUE', |
|
226 | + public static $_localeBoolean = array('TRUE' => 'TRUE', |
|
227 | 227 | 'FALSE' => 'FALSE', |
228 | 228 | 'NULL' => 'NULL' |
229 | 229 | ); |
@@ -1682,8 +1682,8 @@ discard block |
||
1682 | 1682 | |
1683 | 1683 | private function __construct() { |
1684 | 1684 | $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/'; |
1685 | - foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) { |
|
1686 | - $filename = substr($filename,strlen($localeFileDirectory)+1); |
|
1685 | + foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) { |
|
1686 | + $filename = substr($filename, strlen($localeFileDirectory) + 1); |
|
1687 | 1687 | if ($filename != 'en') { |
1688 | 1688 | self::$_validLocaleLanguages[] = $filename; |
1689 | 1689 | } |
@@ -1692,14 +1692,14 @@ discard block |
||
1692 | 1692 | $setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16; |
1693 | 1693 | $this->_savedPrecision = ini_get('precision'); |
1694 | 1694 | if ($this->_savedPrecision < $setPrecision) { |
1695 | - ini_set('precision',$setPrecision); |
|
1695 | + ini_set('precision', $setPrecision); |
|
1696 | 1696 | } |
1697 | 1697 | } // function __construct() |
1698 | 1698 | |
1699 | 1699 | |
1700 | 1700 | public function __destruct() { |
1701 | 1701 | if ($this->_savedPrecision != ini_get('precision')) { |
1702 | - ini_set('precision',$this->_savedPrecision); |
|
1702 | + ini_set('precision', $this->_savedPrecision); |
|
1703 | 1703 | } |
1704 | 1704 | } |
1705 | 1705 | |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | * @return PHPExcel_Calculation |
1711 | 1711 | */ |
1712 | 1712 | public static function getInstance() { |
1713 | - if (!isset(self::$_instance) || (self::$_instance === NULL)) { |
|
1713 | + if ( ! isset(self::$_instance) || (self::$_instance === NULL)) { |
|
1714 | 1714 | self::$_instance = new PHPExcel_Calculation(); |
1715 | 1715 | } |
1716 | 1716 | |
@@ -1739,7 +1739,7 @@ discard block |
||
1739 | 1739 | * @throws Exception |
1740 | 1740 | */ |
1741 | 1741 | public final function __clone() { |
1742 | - throw new Exception ('Cloning a Singleton is not allowed!'); |
|
1742 | + throw new Exception('Cloning a Singleton is not allowed!'); |
|
1743 | 1743 | } // function __clone() |
1744 | 1744 | |
1745 | 1745 | |
@@ -1876,15 +1876,15 @@ discard block |
||
1876 | 1876 | * |
1877 | 1877 | * @return boolean |
1878 | 1878 | */ |
1879 | - public function setLocale($locale='en_us') { |
|
1879 | + public function setLocale($locale = 'en_us') { |
|
1880 | 1880 | // Identify our locale and language |
1881 | 1881 | $language = $locale = strtolower($locale); |
1882 | - if (strpos($locale,'_') !== false) { |
|
1883 | - list($language) = explode('_',$locale); |
|
1882 | + if (strpos($locale, '_') !== false) { |
|
1883 | + list($language) = explode('_', $locale); |
|
1884 | 1884 | } |
1885 | 1885 | |
1886 | 1886 | // Test whether we have any language data for this language (any locale) |
1887 | - if (in_array($language,self::$_validLocaleLanguages)) { |
|
1887 | + if (in_array($language, self::$_validLocaleLanguages)) { |
|
1888 | 1888 | // initialise language/locale settings |
1889 | 1889 | self::$_localeFunctions = array(); |
1890 | 1890 | self::$_localeArgumentSeparator = ','; |
@@ -1892,20 +1892,20 @@ discard block |
||
1892 | 1892 | // Default is English, if user isn't requesting english, then read the necessary data from the locale files |
1893 | 1893 | if ($locale != 'en_us') { |
1894 | 1894 | // Search for a file with a list of function names for locale |
1895 | - $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'functions'; |
|
1896 | - if (!file_exists($functionNamesFile)) { |
|
1895 | + $functionNamesFile = PHPEXCEL_ROOT.'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'functions'; |
|
1896 | + if ( ! file_exists($functionNamesFile)) { |
|
1897 | 1897 | // If there isn't a locale specific function file, look for a language specific function file |
1898 | - $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions'; |
|
1899 | - if (!file_exists($functionNamesFile)) { |
|
1898 | + $functionNamesFile = PHPEXCEL_ROOT.'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions'; |
|
1899 | + if ( ! file_exists($functionNamesFile)) { |
|
1900 | 1900 | return false; |
1901 | 1901 | } |
1902 | 1902 | } |
1903 | 1903 | // Retrieve the list of locale or language specific function names |
1904 | - $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
1904 | + $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
1905 | 1905 | foreach ($localeFunctions as $localeFunction) { |
1906 | - list($localeFunction) = explode('##',$localeFunction); // Strip out comments |
|
1907 | - if (strpos($localeFunction,'=') !== false) { |
|
1908 | - list($fName,$lfName) = explode('=',$localeFunction); |
|
1906 | + list($localeFunction) = explode('##', $localeFunction); // Strip out comments |
|
1907 | + if (strpos($localeFunction, '=') !== false) { |
|
1908 | + list($fName, $lfName) = explode('=', $localeFunction); |
|
1909 | 1909 | $fName = trim($fName); |
1910 | 1910 | $lfName = trim($lfName); |
1911 | 1911 | if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) { |
@@ -1917,16 +1917,16 @@ discard block |
||
1917 | 1917 | if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; } |
1918 | 1918 | if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; } |
1919 | 1919 | |
1920 | - $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'config'; |
|
1921 | - if (!file_exists($configFile)) { |
|
1922 | - $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config'; |
|
1920 | + $configFile = PHPEXCEL_ROOT.'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'config'; |
|
1921 | + if ( ! file_exists($configFile)) { |
|
1922 | + $configFile = PHPEXCEL_ROOT.'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config'; |
|
1923 | 1923 | } |
1924 | 1924 | if (file_exists($configFile)) { |
1925 | - $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
1925 | + $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
1926 | 1926 | foreach ($localeSettings as $localeSetting) { |
1927 | - list($localeSetting) = explode('##',$localeSetting); // Strip out comments |
|
1928 | - if (strpos($localeSetting,'=') !== false) { |
|
1929 | - list($settingName,$settingValue) = explode('=',$localeSetting); |
|
1927 | + list($localeSetting) = explode('##', $localeSetting); // Strip out comments |
|
1928 | + if (strpos($localeSetting, '=') !== false) { |
|
1929 | + list($settingName, $settingValue) = explode('=', $localeSetting); |
|
1930 | 1930 | $settingName = strtoupper(trim($settingName)); |
1931 | 1931 | switch ($settingName) { |
1932 | 1932 | case 'ARGUMENTSEPARATOR' : |
@@ -1948,48 +1948,48 @@ discard block |
||
1948 | 1948 | |
1949 | 1949 | |
1950 | 1950 | |
1951 | - public static function _translateSeparator($fromSeparator,$toSeparator,$formula,&$inBraces) { |
|
1951 | + public static function _translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces) { |
|
1952 | 1952 | $strlen = mb_strlen($formula); |
1953 | 1953 | for ($i = 0; $i < $strlen; ++$i) { |
1954 | - $chr = mb_substr($formula,$i,1); |
|
1954 | + $chr = mb_substr($formula, $i, 1); |
|
1955 | 1955 | switch ($chr) { |
1956 | 1956 | case '{' : $inBraces = true; |
1957 | 1957 | break; |
1958 | 1958 | case '}' : $inBraces = false; |
1959 | 1959 | break; |
1960 | 1960 | case $fromSeparator : |
1961 | - if (!$inBraces) { |
|
1962 | - $formula = mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1); |
|
1961 | + if ( ! $inBraces) { |
|
1962 | + $formula = mb_substr($formula, 0, $i).$toSeparator.mb_substr($formula, $i + 1); |
|
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | } |
1966 | 1966 | return $formula; |
1967 | 1967 | } |
1968 | 1968 | |
1969 | - private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) { |
|
1969 | + private static function _translateFormula($from, $to, $formula, $fromSeparator, $toSeparator) { |
|
1970 | 1970 | // Convert any Excel function names to the required language |
1971 | 1971 | if (self::$_localeLanguage !== 'en_us') { |
1972 | 1972 | $inBraces = false; |
1973 | 1973 | // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators |
1974 | - if (strpos($formula,'"') !== false) { |
|
1974 | + if (strpos($formula, '"') !== false) { |
|
1975 | 1975 | // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded |
1976 | 1976 | // the formula |
1977 | - $temp = explode('"',$formula); |
|
1977 | + $temp = explode('"', $formula); |
|
1978 | 1978 | $i = false; |
1979 | - foreach($temp as &$value) { |
|
1979 | + foreach ($temp as &$value) { |
|
1980 | 1980 | // Only count/replace in alternating array entries |
1981 | - if ($i = !$i) { |
|
1982 | - $value = preg_replace($from,$to,$value); |
|
1983 | - $value = self::_translateSeparator($fromSeparator,$toSeparator,$value,$inBraces); |
|
1981 | + if ($i = ! $i) { |
|
1982 | + $value = preg_replace($from, $to, $value); |
|
1983 | + $value = self::_translateSeparator($fromSeparator, $toSeparator, $value, $inBraces); |
|
1984 | 1984 | } |
1985 | 1985 | } |
1986 | 1986 | unset($value); |
1987 | 1987 | // Then rebuild the formula string |
1988 | - $formula = implode('"',$temp); |
|
1988 | + $formula = implode('"', $temp); |
|
1989 | 1989 | } else { |
1990 | 1990 | // If there's no quoted strings, then we do a simple count/replace |
1991 | - $formula = preg_replace($from,$to,$formula); |
|
1992 | - $formula = self::_translateSeparator($fromSeparator,$toSeparator,$formula,$inBraces); |
|
1991 | + $formula = preg_replace($from, $to, $formula); |
|
1992 | + $formula = self::_translateSeparator($fromSeparator, $toSeparator, $formula, $inBraces); |
|
1993 | 1993 | } |
1994 | 1994 | } |
1995 | 1995 | |
@@ -2002,10 +2002,10 @@ discard block |
||
2002 | 2002 | public function _translateFormulaToLocale($formula) { |
2003 | 2003 | if (self::$functionReplaceFromExcel === NULL) { |
2004 | 2004 | self::$functionReplaceFromExcel = array(); |
2005 | - foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) { |
|
2005 | + foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) { |
|
2006 | 2006 | self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui'; |
2007 | 2007 | } |
2008 | - foreach(array_keys(self::$_localeBoolean) as $excelBoolean) { |
|
2008 | + foreach (array_keys(self::$_localeBoolean) as $excelBoolean) { |
|
2009 | 2009 | self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; |
2010 | 2010 | } |
2011 | 2011 | |
@@ -2013,49 +2013,49 @@ discard block |
||
2013 | 2013 | |
2014 | 2014 | if (self::$functionReplaceToLocale === NULL) { |
2015 | 2015 | self::$functionReplaceToLocale = array(); |
2016 | - foreach(array_values(self::$_localeFunctions) as $localeFunctionName) { |
|
2016 | + foreach (array_values(self::$_localeFunctions) as $localeFunctionName) { |
|
2017 | 2017 | self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2'; |
2018 | 2018 | } |
2019 | - foreach(array_values(self::$_localeBoolean) as $localeBoolean) { |
|
2019 | + foreach (array_values(self::$_localeBoolean) as $localeBoolean) { |
|
2020 | 2020 | self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2'; |
2021 | 2021 | } |
2022 | 2022 | } |
2023 | 2023 | |
2024 | - return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,',',self::$_localeArgumentSeparator); |
|
2024 | + return self::_translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$_localeArgumentSeparator); |
|
2025 | 2025 | } // function _translateFormulaToLocale() |
2026 | 2026 | |
2027 | 2027 | |
2028 | - private static $functionReplaceFromLocale = null; |
|
2029 | - private static $functionReplaceToExcel = null; |
|
2028 | + private static $functionReplaceFromLocale = null; |
|
2029 | + private static $functionReplaceToExcel = null; |
|
2030 | 2030 | |
2031 | 2031 | public function _translateFormulaToEnglish($formula) { |
2032 | 2032 | if (self::$functionReplaceFromLocale === NULL) { |
2033 | 2033 | self::$functionReplaceFromLocale = array(); |
2034 | - foreach(array_values(self::$_localeFunctions) as $localeFunctionName) { |
|
2034 | + foreach (array_values(self::$_localeFunctions) as $localeFunctionName) { |
|
2035 | 2035 | self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui'; |
2036 | 2036 | } |
2037 | - foreach(array_values(self::$_localeBoolean) as $excelBoolean) { |
|
2037 | + foreach (array_values(self::$_localeBoolean) as $excelBoolean) { |
|
2038 | 2038 | self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; |
2039 | 2039 | } |
2040 | 2040 | } |
2041 | 2041 | |
2042 | 2042 | if (self::$functionReplaceToExcel === NULL) { |
2043 | 2043 | self::$functionReplaceToExcel = array(); |
2044 | - foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) { |
|
2044 | + foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) { |
|
2045 | 2045 | self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2'; |
2046 | 2046 | } |
2047 | - foreach(array_keys(self::$_localeBoolean) as $excelBoolean) { |
|
2047 | + foreach (array_keys(self::$_localeBoolean) as $excelBoolean) { |
|
2048 | 2048 | self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2'; |
2049 | 2049 | } |
2050 | 2050 | } |
2051 | 2051 | |
2052 | - return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,','); |
|
2052 | + return self::_translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$_localeArgumentSeparator, ','); |
|
2053 | 2053 | } // function _translateFormulaToEnglish() |
2054 | 2054 | |
2055 | 2055 | |
2056 | 2056 | public static function _localeFunc($function) { |
2057 | 2057 | if (self::$_localeLanguage !== 'en_us') { |
2058 | - $functionName = trim($function,'('); |
|
2058 | + $functionName = trim($function, '('); |
|
2059 | 2059 | if (isset(self::$_localeFunctions[$functionName])) { |
2060 | 2060 | $brace = ($functionName != $function); |
2061 | 2061 | $function = self::$_localeFunctions[$functionName]; |
@@ -2084,7 +2084,7 @@ discard block |
||
2084 | 2084 | // Return strings wrapped in quotes |
2085 | 2085 | return '"'.$value.'"'; |
2086 | 2086 | // Convert numeric errors to NaN error |
2087 | - } else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { |
|
2087 | + } else if ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { |
|
2088 | 2088 | return PHPExcel_Calculation_Functions::NaN(); |
2089 | 2089 | } |
2090 | 2090 | |
@@ -2100,11 +2100,11 @@ discard block |
||
2100 | 2100 | */ |
2101 | 2101 | public static function _unwrapResult($value) { |
2102 | 2102 | if (is_string($value)) { |
2103 | - if ((isset($value{0})) && ($value{0} == '"') && (substr($value,-1) == '"')) { |
|
2104 | - return substr($value,1,-1); |
|
2103 | + if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) { |
|
2104 | + return substr($value, 1, -1); |
|
2105 | 2105 | } |
2106 | 2106 | // Convert numeric errors to NaN error |
2107 | - } else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { |
|
2107 | + } else if ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { |
|
2108 | 2108 | return PHPExcel_Calculation_Functions::NaN(); |
2109 | 2109 | } |
2110 | 2110 | return $value; |
@@ -2176,11 +2176,11 @@ discard block |
||
2176 | 2176 | // If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it |
2177 | 2177 | $r = array_keys($result); |
2178 | 2178 | $r = array_shift($r); |
2179 | - if (!is_numeric($r)) { return PHPExcel_Calculation_Functions::VALUE(); } |
|
2179 | + if ( ! is_numeric($r)) { return PHPExcel_Calculation_Functions::VALUE(); } |
|
2180 | 2180 | if (is_array($result[$r])) { |
2181 | 2181 | $c = array_keys($result[$r]); |
2182 | 2182 | $c = array_shift($c); |
2183 | - if (!is_numeric($c)) { |
|
2183 | + if ( ! is_numeric($c)) { |
|
2184 | 2184 | return PHPExcel_Calculation_Functions::VALUE(); |
2185 | 2185 | } |
2186 | 2186 | } |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | |
2191 | 2191 | if ($result === NULL) { |
2192 | 2192 | return 0; |
2193 | - } elseif((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) { |
|
2193 | + } elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) { |
|
2194 | 2194 | return PHPExcel_Calculation_Functions::NaN(); |
2195 | 2195 | } |
2196 | 2196 | return $result; |
@@ -2208,9 +2208,9 @@ discard block |
||
2208 | 2208 | // Basic validation that this is indeed a formula |
2209 | 2209 | // We return an empty array if not |
2210 | 2210 | $formula = trim($formula); |
2211 | - if ((!isset($formula{0})) || ($formula{0} != '=')) return array(); |
|
2212 | - $formula = ltrim(substr($formula,1)); |
|
2213 | - if (!isset($formula{0})) return array(); |
|
2211 | + if (( ! isset($formula{0})) || ($formula{0} != '=')) return array(); |
|
2212 | + $formula = ltrim(substr($formula, 1)); |
|
2213 | + if ( ! isset($formula{0})) return array(); |
|
2214 | 2214 | |
2215 | 2215 | // Parse the formula and return the token stack |
2216 | 2216 | return $this->_parseFormula($formula); |
@@ -2224,7 +2224,7 @@ discard block |
||
2224 | 2224 | * @return mixed |
2225 | 2225 | * @throws Exception |
2226 | 2226 | */ |
2227 | - public function calculateFormula($formula, $cellID=null, PHPExcel_Cell $pCell = null) { |
|
2227 | + public function calculateFormula($formula, $cellID = null, PHPExcel_Cell $pCell = null) { |
|
2228 | 2228 | // Initialise the logging settings |
2229 | 2229 | $this->formulaError = null; |
2230 | 2230 | $this->debugLog = $this->debugLogStack = array(); |
@@ -2256,7 +2256,7 @@ discard block |
||
2256 | 2256 | * @return mixed |
2257 | 2257 | * @throws Exception |
2258 | 2258 | */ |
2259 | - public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) { |
|
2259 | + public function _calculateFormulaValue($formula, $cellID = null, PHPExcel_Cell $pCell = null) { |
|
2260 | 2260 | // echo '<b>'.$cellID.'</b><br />'; |
2261 | 2261 | $cellValue = ''; |
2262 | 2262 | |
@@ -2264,8 +2264,8 @@ discard block |
||
2264 | 2264 | // We simply return the "cell value" (formula) if not |
2265 | 2265 | $formula = trim($formula); |
2266 | 2266 | if ($formula{0} != '=') return self::_wrapResult($formula); |
2267 | - $formula = ltrim(substr($formula,1)); |
|
2268 | - if (!isset($formula{0})) return self::_wrapResult($formula); |
|
2267 | + $formula = ltrim(substr($formula, 1)); |
|
2268 | + if ( ! isset($formula{0})) return self::_wrapResult($formula); |
|
2269 | 2269 | |
2270 | 2270 | $wsTitle = "\x00Wrk"; |
2271 | 2271 | if ($pCell !== NULL) { |
@@ -2304,7 +2304,7 @@ discard block |
||
2304 | 2304 | } |
2305 | 2305 | } |
2306 | 2306 | |
2307 | - if ((in_array($wsTitle.'!'.$cellID,$this->debugLogStack)) && ($wsTitle != "\x00Wrk")) { |
|
2307 | + if ((in_array($wsTitle.'!'.$cellID, $this->debugLogStack)) && ($wsTitle != "\x00Wrk")) { |
|
2308 | 2308 | if ($this->cyclicFormulaCount <= 0) { |
2309 | 2309 | return $this->_raiseFormulaError('Cyclic Reference in Formula'); |
2310 | 2310 | } elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) && |
@@ -2352,33 +2352,33 @@ discard block |
||
2352 | 2352 | * 1 = shrink to fit |
2353 | 2353 | * 2 = extend to fit |
2354 | 2354 | */ |
2355 | - private static function _checkMatrixOperands(&$operand1,&$operand2,$resize = 1) { |
|
2355 | + private static function _checkMatrixOperands(&$operand1, &$operand2, $resize = 1) { |
|
2356 | 2356 | // Examine each of the two operands, and turn them into an array if they aren't one already |
2357 | 2357 | // Note that this function should only be called if one or both of the operand is already an array |
2358 | - if (!is_array($operand1)) { |
|
2359 | - list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand2); |
|
2360 | - $operand1 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1)); |
|
2358 | + if ( ! is_array($operand1)) { |
|
2359 | + list($matrixRows, $matrixColumns) = self::_getMatrixDimensions($operand2); |
|
2360 | + $operand1 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand1)); |
|
2361 | 2361 | $resize = 0; |
2362 | - } elseif (!is_array($operand2)) { |
|
2363 | - list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand1); |
|
2364 | - $operand2 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2)); |
|
2362 | + } elseif ( ! is_array($operand2)) { |
|
2363 | + list($matrixRows, $matrixColumns) = self::_getMatrixDimensions($operand1); |
|
2364 | + $operand2 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand2)); |
|
2365 | 2365 | $resize = 0; |
2366 | 2366 | } |
2367 | 2367 | |
2368 | - list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($operand1); |
|
2369 | - list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($operand2); |
|
2368 | + list($matrix1Rows, $matrix1Columns) = self::_getMatrixDimensions($operand1); |
|
2369 | + list($matrix2Rows, $matrix2Columns) = self::_getMatrixDimensions($operand2); |
|
2370 | 2370 | if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) { |
2371 | 2371 | $resize = 1; |
2372 | 2372 | } |
2373 | 2373 | |
2374 | 2374 | if ($resize == 2) { |
2375 | 2375 | // Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger |
2376 | - self::_resizeMatricesExtend($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns); |
|
2376 | + self::_resizeMatricesExtend($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); |
|
2377 | 2377 | } elseif ($resize == 1) { |
2378 | 2378 | // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller |
2379 | - self::_resizeMatricesShrink($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns); |
|
2379 | + self::_resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); |
|
2380 | 2380 | } |
2381 | - return array( $matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns); |
|
2381 | + return array($matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); |
|
2382 | 2382 | } // function _checkMatrixOperands() |
2383 | 2383 | |
2384 | 2384 | |
@@ -2391,16 +2391,16 @@ discard block |
||
2391 | 2391 | public static function _getMatrixDimensions(&$matrix) { |
2392 | 2392 | $matrixRows = count($matrix); |
2393 | 2393 | $matrixColumns = 0; |
2394 | - foreach($matrix as $rowKey => $rowValue) { |
|
2395 | - $matrixColumns = max(count($rowValue),$matrixColumns); |
|
2396 | - if (!is_array($rowValue)) { |
|
2394 | + foreach ($matrix as $rowKey => $rowValue) { |
|
2395 | + $matrixColumns = max(count($rowValue), $matrixColumns); |
|
2396 | + if ( ! is_array($rowValue)) { |
|
2397 | 2397 | $matrix[$rowKey] = array($rowValue); |
2398 | 2398 | } else { |
2399 | 2399 | $matrix[$rowKey] = array_values($rowValue); |
2400 | 2400 | } |
2401 | 2401 | } |
2402 | 2402 | $matrix = array_values($matrix); |
2403 | - return array($matrixRows,$matrixColumns); |
|
2403 | + return array($matrixRows, $matrixColumns); |
|
2404 | 2404 | } // function _getMatrixDimensions() |
2405 | 2405 | |
2406 | 2406 | |
@@ -2410,7 +2410,7 @@ discard block |
||
2410 | 2410 | * @param mixed &$matrix1 First matrix operand |
2411 | 2411 | * @param mixed &$matrix2 Second matrix operand |
2412 | 2412 | */ |
2413 | - private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { |
|
2413 | + private static function _resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) { |
|
2414 | 2414 | if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { |
2415 | 2415 | if ($matrix2Columns < $matrix1Columns) { |
2416 | 2416 | for ($i = 0; $i < $matrix1Rows; ++$i) { |
@@ -2449,18 +2449,18 @@ discard block |
||
2449 | 2449 | * @param mixed &$matrix1 First matrix operand |
2450 | 2450 | * @param mixed &$matrix2 Second matrix operand |
2451 | 2451 | */ |
2452 | - private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { |
|
2452 | + private static function _resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) { |
|
2453 | 2453 | if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { |
2454 | 2454 | if ($matrix2Columns < $matrix1Columns) { |
2455 | 2455 | for ($i = 0; $i < $matrix2Rows; ++$i) { |
2456 | - $x = $matrix2[$i][$matrix2Columns-1]; |
|
2456 | + $x = $matrix2[$i][$matrix2Columns - 1]; |
|
2457 | 2457 | for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) { |
2458 | 2458 | $matrix2[$i][$j] = $x; |
2459 | 2459 | } |
2460 | 2460 | } |
2461 | 2461 | } |
2462 | 2462 | if ($matrix2Rows < $matrix1Rows) { |
2463 | - $x = $matrix2[$matrix2Rows-1]; |
|
2463 | + $x = $matrix2[$matrix2Rows - 1]; |
|
2464 | 2464 | for ($i = 0; $i < $matrix1Rows; ++$i) { |
2465 | 2465 | $matrix2[$i] = $x; |
2466 | 2466 | } |
@@ -2470,14 +2470,14 @@ discard block |
||
2470 | 2470 | if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) { |
2471 | 2471 | if ($matrix1Columns < $matrix2Columns) { |
2472 | 2472 | for ($i = 0; $i < $matrix1Rows; ++$i) { |
2473 | - $x = $matrix1[$i][$matrix1Columns-1]; |
|
2473 | + $x = $matrix1[$i][$matrix1Columns - 1]; |
|
2474 | 2474 | for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) { |
2475 | 2475 | $matrix1[$i][$j] = $x; |
2476 | 2476 | } |
2477 | 2477 | } |
2478 | 2478 | } |
2479 | 2479 | if ($matrix1Rows < $matrix2Rows) { |
2480 | - $x = $matrix1[$matrix1Rows-1]; |
|
2480 | + $x = $matrix1[$matrix1Rows - 1]; |
|
2481 | 2481 | for ($i = 0; $i < $matrix2Rows; ++$i) { |
2482 | 2482 | $matrix1[$i] = $x; |
2483 | 2483 | } |
@@ -2502,18 +2502,18 @@ discard block |
||
2502 | 2502 | if (is_array($value)) { |
2503 | 2503 | $returnMatrix = array(); |
2504 | 2504 | $pad = $rpad = ', '; |
2505 | - foreach($value as $row) { |
|
2505 | + foreach ($value as $row) { |
|
2506 | 2506 | if (is_array($row)) { |
2507 | - $returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row)); |
|
2507 | + $returnMatrix[] = implode($pad, array_map(array($this, '_showValue'), $row)); |
|
2508 | 2508 | $rpad = '; '; |
2509 | 2509 | } else { |
2510 | 2510 | $returnMatrix[] = $this->_showValue($row); |
2511 | 2511 | } |
2512 | 2512 | } |
2513 | - return '{ '.implode($rpad,$returnMatrix).' }'; |
|
2514 | - } elseif(is_string($value) && (trim($value,'"') == $value)) { |
|
2513 | + return '{ '.implode($rpad, $returnMatrix).' }'; |
|
2514 | + } elseif (is_string($value) && (trim($value, '"') == $value)) { |
|
2515 | 2515 | return '"'.$value.'"'; |
2516 | - } elseif(is_bool($value)) { |
|
2516 | + } elseif (is_bool($value)) { |
|
2517 | 2517 | return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE']; |
2518 | 2518 | } |
2519 | 2519 | } |
@@ -2538,11 +2538,11 @@ discard block |
||
2538 | 2538 | return 'a NULL value'; |
2539 | 2539 | } elseif (is_float($value)) { |
2540 | 2540 | $typeString = 'a floating point number'; |
2541 | - } elseif(is_int($value)) { |
|
2541 | + } elseif (is_int($value)) { |
|
2542 | 2542 | $typeString = 'an integer number'; |
2543 | - } elseif(is_bool($value)) { |
|
2543 | + } elseif (is_bool($value)) { |
|
2544 | 2544 | $typeString = 'a boolean'; |
2545 | - } elseif(is_array($value)) { |
|
2545 | + } elseif (is_array($value)) { |
|
2546 | 2546 | $typeString = 'a matrix'; |
2547 | 2547 | } else { |
2548 | 2548 | if ($value == '') { |
@@ -2559,35 +2559,35 @@ discard block |
||
2559 | 2559 | |
2560 | 2560 | |
2561 | 2561 | private static function _convertMatrixReferences($formula) { |
2562 | - static $matrixReplaceFrom = array('{',';','}'); |
|
2563 | - static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))'); |
|
2562 | + static $matrixReplaceFrom = array('{', ';', '}'); |
|
2563 | + static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(', '),MKMATRIX(', '))'); |
|
2564 | 2564 | |
2565 | 2565 | // Convert any Excel matrix references to the MKMATRIX() function |
2566 | - if (strpos($formula,'{') !== false) { |
|
2566 | + if (strpos($formula, '{') !== false) { |
|
2567 | 2567 | // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators |
2568 | - if (strpos($formula,'"') !== false) { |
|
2568 | + if (strpos($formula, '"') !== false) { |
|
2569 | 2569 | // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded |
2570 | 2570 | // the formula |
2571 | - $temp = explode('"',$formula); |
|
2571 | + $temp = explode('"', $formula); |
|
2572 | 2572 | // Open and Closed counts used for trapping mismatched braces in the formula |
2573 | 2573 | $openCount = $closeCount = 0; |
2574 | 2574 | $i = false; |
2575 | - foreach($temp as &$value) { |
|
2575 | + foreach ($temp as &$value) { |
|
2576 | 2576 | // Only count/replace in alternating array entries |
2577 | - if ($i = !$i) { |
|
2578 | - $openCount += substr_count($value,'{'); |
|
2579 | - $closeCount += substr_count($value,'}'); |
|
2580 | - $value = str_replace($matrixReplaceFrom,$matrixReplaceTo,$value); |
|
2577 | + if ($i = ! $i) { |
|
2578 | + $openCount += substr_count($value, '{'); |
|
2579 | + $closeCount += substr_count($value, '}'); |
|
2580 | + $value = str_replace($matrixReplaceFrom, $matrixReplaceTo, $value); |
|
2581 | 2581 | } |
2582 | 2582 | } |
2583 | 2583 | unset($value); |
2584 | 2584 | // Then rebuild the formula string |
2585 | - $formula = implode('"',$temp); |
|
2585 | + $formula = implode('"', $temp); |
|
2586 | 2586 | } else { |
2587 | 2587 | // If there's no quoted strings, then we do a simple count/replace |
2588 | - $openCount = substr_count($formula,'{'); |
|
2589 | - $closeCount = substr_count($formula,'}'); |
|
2590 | - $formula = str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula); |
|
2588 | + $openCount = substr_count($formula, '{'); |
|
2589 | + $closeCount = substr_count($formula, '}'); |
|
2590 | + $formula = str_replace($matrixReplaceFrom, $matrixReplaceTo, $formula); |
|
2591 | 2591 | } |
2592 | 2592 | // Trap for mismatched braces and trigger an appropriate error |
2593 | 2593 | if ($openCount < $closeCount) { |
@@ -2627,28 +2627,28 @@ discard block |
||
2627 | 2627 | // Binary Operators |
2628 | 2628 | // These operators always work on two values |
2629 | 2629 | // Array key is the operator, the value indicates whether this is a left or right associative operator |
2630 | - $operatorAssociativity = array('^' => 0, // Exponentiation |
|
2631 | - '*' => 0, '/' => 0, // Multiplication and Division |
|
2632 | - '+' => 0, '-' => 0, // Addition and Subtraction |
|
2633 | - '&' => 0, // Concatenation |
|
2634 | - '|' => 0, ':' => 0, // Intersect and Range |
|
2630 | + $operatorAssociativity = array('^' => 0, // Exponentiation |
|
2631 | + '*' => 0, '/' => 0, // Multiplication and Division |
|
2632 | + '+' => 0, '-' => 0, // Addition and Subtraction |
|
2633 | + '&' => 0, // Concatenation |
|
2634 | + '|' => 0, ':' => 0, // Intersect and Range |
|
2635 | 2635 | '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison |
2636 | 2636 | ); |
2637 | 2637 | // Comparison (Boolean) Operators |
2638 | 2638 | // These operators work on two values, but always return a boolean result |
2639 | - $comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); |
|
2639 | + $comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true); |
|
2640 | 2640 | |
2641 | 2641 | // Operator Precedence |
2642 | 2642 | // This list includes all valid operators, whether binary (including boolean) or unary (such as %) |
2643 | 2643 | // Array key is the operator, the value is its precedence |
2644 | - $operatorPrecedence = array(':' => 8, // Range |
|
2645 | - '|' => 7, // Intersect |
|
2646 | - '~' => 6, // Negation |
|
2647 | - '%' => 5, // Percentage |
|
2648 | - '^' => 4, // Exponentiation |
|
2649 | - '*' => 3, '/' => 3, // Multiplication and Division |
|
2650 | - '+' => 2, '-' => 2, // Addition and Subtraction |
|
2651 | - '&' => 1, // Concatenation |
|
2644 | + $operatorPrecedence = array(':' => 8, // Range |
|
2645 | + '|' => 7, // Intersect |
|
2646 | + '~' => 6, // Negation |
|
2647 | + '%' => 5, // Percentage |
|
2648 | + '^' => 4, // Exponentiation |
|
2649 | + '*' => 3, '/' => 3, // Multiplication and Division |
|
2650 | + '+' => 2, '-' => 2, // Addition and Subtraction |
|
2651 | + '&' => 1, // Concatenation |
|
2652 | 2652 | '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison |
2653 | 2653 | ); |
2654 | 2654 | |
@@ -2665,17 +2665,17 @@ discard block |
||
2665 | 2665 | $index = 0; |
2666 | 2666 | $stack = new PHPExcel_Token_Stack; |
2667 | 2667 | $output = array(); |
2668 | - $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a |
|
2668 | + $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a |
|
2669 | 2669 | // - is a negation or + is a positive operator rather than an operation |
2670 | - $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand |
|
2670 | + $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand |
|
2671 | 2671 | // should be null in a function call |
2672 | 2672 | // The guts of the lexical parser |
2673 | 2673 | // Loop through the formula extracting each operator and operand in turn |
2674 | - while(true) { |
|
2674 | + while (true) { |
|
2675 | 2675 | // echo 'Assessing Expression <b>'.substr($formula, $index).'</b><br />'; |
2676 | 2676 | $opCharacter = $formula{$index}; // Get the first character of the value at the current index position |
2677 | 2677 | // echo 'Initial character of expression block is '.$opCharacter.'<br />'; |
2678 | - if ((isset($comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset($comparisonOperators[$formula{$index+1}]))) { |
|
2678 | + if ((isset($comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset($comparisonOperators[$formula{$index + 1}]))) { |
|
2679 | 2679 | $opCharacter .= $formula{++$index}; |
2680 | 2680 | // echo 'Initial character of expression block is comparison operator '.$opCharacter.'<br />'; |
2681 | 2681 | } |
@@ -2685,29 +2685,29 @@ discard block |
||
2685 | 2685 | // echo '$isOperandOrFunction is '.(($isOperandOrFunction) ? 'True' : 'False').'<br />'; |
2686 | 2686 | // var_dump($match); |
2687 | 2687 | |
2688 | - if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus? |
|
2688 | + if ($opCharacter == '-' && ! $expectingOperator) { // Is it a negation instead of a minus? |
|
2689 | 2689 | // echo 'Element is a Negation operator<br />'; |
2690 | - $stack->push('Unary Operator','~'); // Put a negation on the stack |
|
2691 | - ++$index; // and drop the negation symbol |
|
2690 | + $stack->push('Unary Operator', '~'); // Put a negation on the stack |
|
2691 | + ++$index; // and drop the negation symbol |
|
2692 | 2692 | } elseif ($opCharacter == '%' && $expectingOperator) { |
2693 | 2693 | // echo 'Element is a Percentage operator<br />'; |
2694 | - $stack->push('Unary Operator','%'); // Put a percentage on the stack |
|
2694 | + $stack->push('Unary Operator', '%'); // Put a percentage on the stack |
|
2695 | 2695 | ++$index; |
2696 | - } elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded? |
|
2696 | + } elseif ($opCharacter == '+' && ! $expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded? |
|
2697 | 2697 | // echo 'Element is a Positive number, not Plus operator<br />'; |
2698 | - ++$index; // Drop the redundant plus symbol |
|
2699 | - } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal |
|
2700 | - return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression |
|
2698 | + ++$index; // Drop the redundant plus symbol |
|
2699 | + } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && ( ! $isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal |
|
2700 | + return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression |
|
2701 | 2701 | |
2702 | 2702 | } elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? |
2703 | 2703 | // echo 'Element with value '.$opCharacter.' is an Operator<br />'; |
2704 | - while($stack->count() > 0 && |
|
2704 | + while ($stack->count() > 0 && |
|
2705 | 2705 | ($o2 = $stack->last()) && |
2706 | 2706 | isset(self::$_operators[$o2['value']]) && |
2707 | 2707 | @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) { |
2708 | - $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
2708 | + $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
2709 | 2709 | } |
2710 | - $stack->push('Binary Operator',$opCharacter); // Finally put our current operator onto the stack |
|
2710 | + $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack |
|
2711 | 2711 | ++$index; |
2712 | 2712 | $expectingOperator = false; |
2713 | 2713 | |
@@ -2720,10 +2720,10 @@ discard block |
||
2720 | 2720 | } |
2721 | 2721 | $d = $stack->last(2); |
2722 | 2722 | if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? |
2723 | - $functionName = $matches[1]; // Get the function name |
|
2723 | + $functionName = $matches[1]; // Get the function name |
|
2724 | 2724 | // echo 'Closed Function is '.$functionName.'<br />'; |
2725 | 2725 | $d = $stack->pop(); |
2726 | - $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack) |
|
2726 | + $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack) |
|
2727 | 2727 | // if ($argumentCount == 0) { |
2728 | 2728 | // echo 'With no arguments<br />'; |
2729 | 2729 | // } elseif ($argumentCount == 1) { |
@@ -2731,8 +2731,8 @@ discard block |
||
2731 | 2731 | // } else { |
2732 | 2732 | // echo 'With '.$argumentCount.' arguments<br />'; |
2733 | 2733 | // } |
2734 | - $output[] = $d; // Dump the argument count on the output |
|
2735 | - $output[] = $stack->pop(); // Pop the function and push onto the output |
|
2734 | + $output[] = $d; // Dump the argument count on the output |
|
2735 | + $output[] = $stack->pop(); // Pop the function and push onto the output |
|
2736 | 2736 | if (isset(self::$_controlFunctions[$functionName])) { |
2737 | 2737 | // echo 'Built-in function '.$functionName.'<br />'; |
2738 | 2738 | $expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount']; |
@@ -2761,7 +2761,7 @@ discard block |
||
2761 | 2761 | } |
2762 | 2762 | } |
2763 | 2763 | } elseif ($expectedArgumentCount != '*') { |
2764 | - $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch); |
|
2764 | + $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/', $expectedArgumentCount, $argMatch); |
|
2765 | 2765 | // print_r($argMatch); |
2766 | 2766 | // echo '<br />'; |
2767 | 2767 | switch ($argMatch[2]) { |
@@ -2795,30 +2795,30 @@ discard block |
||
2795 | 2795 | // echo 'Element is a Function argument separator<br />'; |
2796 | 2796 | while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( |
2797 | 2797 | if ($o2 === NULL) return $this->_raiseFormulaError("Formula Error: Unexpected ,"); |
2798 | - else $output[] = $o2; // pop the argument expression stuff and push onto the output |
|
2798 | + else $output[] = $o2; // pop the argument expression stuff and push onto the output |
|
2799 | 2799 | } |
2800 | 2800 | // If we've a comma when we're expecting an operand, then what we actually have is a null operand; |
2801 | 2801 | // so push a null onto the stack |
2802 | - if (($expectingOperand) || (!$expectingOperator)) { |
|
2802 | + if (($expectingOperand) || ( ! $expectingOperator)) { |
|
2803 | 2803 | $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null); |
2804 | 2804 | } |
2805 | 2805 | // make sure there was a function |
2806 | 2806 | $d = $stack->last(2); |
2807 | - if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) |
|
2807 | + if ( ! preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) |
|
2808 | 2808 | return $this->_raiseFormulaError("Formula Error: Unexpected ,"); |
2809 | 2809 | $d = $stack->pop(); |
2810 | - $stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count |
|
2811 | - $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again |
|
2810 | + $stack->push($d['type'], ++$d['value'], $d['reference']); // increment the argument count |
|
2811 | + $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again |
|
2812 | 2812 | $expectingOperator = false; |
2813 | 2813 | $expectingOperand = true; |
2814 | 2814 | ++$index; |
2815 | 2815 | |
2816 | - } elseif ($opCharacter == '(' && !$expectingOperator) { |
|
2816 | + } elseif ($opCharacter == '(' && ! $expectingOperator) { |
|
2817 | 2817 | // echo 'Element is an Opening Bracket<br />'; |
2818 | 2818 | $stack->push('Brace', '('); |
2819 | 2819 | ++$index; |
2820 | 2820 | |
2821 | - } elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number? |
|
2821 | + } elseif ($isOperandOrFunction && ! $expectingOperator) { // do we now have a function/variable/number? |
|
2822 | 2822 | $expectingOperator = true; |
2823 | 2823 | $expectingOperand = false; |
2824 | 2824 | $val = $match[1]; |
@@ -2826,11 +2826,11 @@ discard block |
||
2826 | 2826 | // echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />'; |
2827 | 2827 | |
2828 | 2828 | if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) { |
2829 | - $val = preg_replace('/\s/','',$val); |
|
2829 | + $val = preg_replace('/\s/', '', $val); |
|
2830 | 2830 | // echo 'Element '.$val.' is a Function<br />'; |
2831 | 2831 | if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function |
2832 | 2832 | $stack->push('Function', strtoupper($val)); |
2833 | - $ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch); |
|
2833 | + $ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index + $length), $amatch); |
|
2834 | 2834 | if ($ax) { |
2835 | 2835 | $stack->push('Operand Count for Function '.strtoupper($val).')', 0); |
2836 | 2836 | $expectingOperator = true; |
@@ -2854,7 +2854,7 @@ discard block |
||
2854 | 2854 | if ($matches[2] == '') { |
2855 | 2855 | // Otherwise, we 'inherit' the worksheet reference from the start cell reference |
2856 | 2856 | // The start of the cell range reference should be the last entry in $output |
2857 | - $startCellRef = $output[count($output)-1]['value']; |
|
2857 | + $startCellRef = $output[count($output) - 1]['value']; |
|
2858 | 2858 | preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $startCellRef, $startMatches); |
2859 | 2859 | if ($startMatches[2] > '') { |
2860 | 2860 | $val = $startMatches[2].'!'.$val; |
@@ -2871,28 +2871,28 @@ discard block |
||
2871 | 2871 | // If the last entry on the stack was a : operator, then we may have a row or column range reference |
2872 | 2872 | $testPrevOp = $stack->last(1); |
2873 | 2873 | if ($testPrevOp['value'] == ':') { |
2874 | - $startRowColRef = $output[count($output)-1]['value']; |
|
2874 | + $startRowColRef = $output[count($output) - 1]['value']; |
|
2875 | 2875 | $rangeWS1 = ''; |
2876 | - if (strpos('!',$startRowColRef) !== false) { |
|
2877 | - list($rangeWS1,$startRowColRef) = explode('!',$startRowColRef); |
|
2876 | + if (strpos('!', $startRowColRef) !== false) { |
|
2877 | + list($rangeWS1, $startRowColRef) = explode('!', $startRowColRef); |
|
2878 | 2878 | } |
2879 | 2879 | if ($rangeWS1 != '') $rangeWS1 .= '!'; |
2880 | 2880 | $rangeWS2 = $rangeWS1; |
2881 | - if (strpos('!',$val) !== false) { |
|
2882 | - list($rangeWS2,$val) = explode('!',$val); |
|
2881 | + if (strpos('!', $val) !== false) { |
|
2882 | + list($rangeWS2, $val) = explode('!', $val); |
|
2883 | 2883 | } |
2884 | 2884 | if ($rangeWS2 != '') $rangeWS2 .= '!'; |
2885 | 2885 | if ((is_integer($startRowColRef)) && (ctype_digit($val)) && |
2886 | 2886 | ($startRowColRef <= 1048576) && ($val <= 1048576)) { |
2887 | 2887 | // Row range |
2888 | - $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 |
|
2889 | - $output[count($output)-1]['value'] = $rangeWS1.'A'.$startRowColRef; |
|
2888 | + $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 |
|
2889 | + $output[count($output) - 1]['value'] = $rangeWS1.'A'.$startRowColRef; |
|
2890 | 2890 | $val = $rangeWS2.$endRowColRef.$val; |
2891 | 2891 | } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && |
2892 | 2892 | (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) { |
2893 | 2893 | // Column range |
2894 | - $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 |
|
2895 | - $output[count($output)-1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1'; |
|
2894 | + $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 |
|
2895 | + $output[count($output) - 1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1'; |
|
2896 | 2896 | $val = $rangeWS2.$val.$endRowColRef; |
2897 | 2897 | } |
2898 | 2898 | } |
@@ -2901,10 +2901,10 @@ discard block |
||
2901 | 2901 | if ($opCharacter == '"') { |
2902 | 2902 | // echo 'Element is a String<br />'; |
2903 | 2903 | // UnEscape any quotes within the string |
2904 | - $val = self::_wrapResult(str_replace('""','"',self::_unwrapResult($val))); |
|
2904 | + $val = self::_wrapResult(str_replace('""', '"', self::_unwrapResult($val))); |
|
2905 | 2905 | } elseif (is_numeric($val)) { |
2906 | 2906 | // echo 'Element is a Number<br />'; |
2907 | - if ((strpos($val,'.') !== false) || (stripos($val,'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { |
|
2907 | + if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { |
|
2908 | 2908 | // echo 'Casting '.$val.' to float<br />'; |
2909 | 2909 | $val = (float) $val; |
2910 | 2910 | } else { |
@@ -2935,7 +2935,7 @@ discard block |
||
2935 | 2935 | } else { |
2936 | 2936 | return $this->_raiseFormulaError("Formula Error: Unexpected ')'"); |
2937 | 2937 | } |
2938 | - } elseif (isset(self::$_operators[$opCharacter]) && !$expectingOperator) { |
|
2938 | + } elseif (isset(self::$_operators[$opCharacter]) && ! $expectingOperator) { |
|
2939 | 2939 | return $this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'"); |
2940 | 2940 | } else { // I don't even want to know what you did to get here |
2941 | 2941 | return $this->_raiseFormulaError("Formula Error: An unexpected error occured"); |
@@ -2962,15 +2962,15 @@ discard block |
||
2962 | 2962 | // Cell References) then we have an INTERSECTION operator |
2963 | 2963 | // echo 'Possible Intersect Operator<br />'; |
2964 | 2964 | if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/Ui', substr($formula, $index), $match)) && |
2965 | - ($output[count($output)-1]['type'] == 'Cell Reference')) { |
|
2965 | + ($output[count($output) - 1]['type'] == 'Cell Reference')) { |
|
2966 | 2966 | // echo 'Element is an Intersect Operator<br />'; |
2967 | - while($stack->count() > 0 && |
|
2967 | + while ($stack->count() > 0 && |
|
2968 | 2968 | ($o2 = $stack->last()) && |
2969 | 2969 | isset(self::$_operators[$o2['value']]) && |
2970 | 2970 | @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) { |
2971 | - $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
2971 | + $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output |
|
2972 | 2972 | } |
2973 | - $stack->push('Binary Operator','|'); // Put an Intersect Operator on the stack |
|
2973 | + $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack |
|
2974 | 2974 | $expectingOperator = false; |
2975 | 2975 | } |
2976 | 2976 | } |
@@ -2978,7 +2978,7 @@ discard block |
||
2978 | 2978 | |
2979 | 2979 | while (($op = $stack->pop()) !== NULL) { // pop everything off the stack and push onto output |
2980 | 2980 | if ((is_array($opCharacter) && $opCharacter['value'] == '(') || ($opCharacter === '(')) |
2981 | - return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced |
|
2981 | + return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced |
|
2982 | 2982 | $output[] = $op; |
2983 | 2983 | } |
2984 | 2984 | return $output; |
@@ -3041,18 +3041,18 @@ discard block |
||
3041 | 3041 | case '<=' : // Less than or Equal to |
3042 | 3042 | case '=' : // Equality |
3043 | 3043 | case '<>' : // Inequality |
3044 | - $this->_executeBinaryComparisonOperation($cellID,$operand1,$operand2,$token,$stack); |
|
3044 | + $this->_executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack); |
|
3045 | 3045 | break; |
3046 | 3046 | // Binary Operators |
3047 | 3047 | case ':' : // Range |
3048 | 3048 | $sheet1 = $sheet2 = ''; |
3049 | - if (strpos($operand1Data['reference'],'!') !== false) { |
|
3050 | - list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']); |
|
3049 | + if (strpos($operand1Data['reference'], '!') !== false) { |
|
3050 | + list($sheet1, $operand1Data['reference']) = explode('!', $operand1Data['reference']); |
|
3051 | 3051 | } else { |
3052 | 3052 | $sheet1 = ($pCellParent !== NULL) ? $pCellParent->getTitle() : ''; |
3053 | 3053 | } |
3054 | - if (strpos($operand2Data['reference'],'!') !== false) { |
|
3055 | - list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']); |
|
3054 | + if (strpos($operand2Data['reference'], '!') !== false) { |
|
3055 | + list($sheet2, $operand2Data['reference']) = explode('!', $operand2Data['reference']); |
|
3056 | 3056 | } else { |
3057 | 3057 | $sheet2 = $sheet1; |
3058 | 3058 | } |
@@ -3076,9 +3076,9 @@ discard block |
||
3076 | 3076 | } |
3077 | 3077 | } |
3078 | 3078 | |
3079 | - $oData = array_merge(explode(':',$operand1Data['reference']),explode(':',$operand2Data['reference'])); |
|
3079 | + $oData = array_merge(explode(':', $operand1Data['reference']), explode(':', $operand2Data['reference'])); |
|
3080 | 3080 | $oCol = $oRow = array(); |
3081 | - foreach($oData as $oDatum) { |
|
3081 | + foreach ($oData as $oDatum) { |
|
3082 | 3082 | $oCR = PHPExcel_Cell::coordinateFromString($oDatum); |
3083 | 3083 | $oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1; |
3084 | 3084 | $oRow[] = $oCR[1]; |
@@ -3089,26 +3089,26 @@ discard block |
||
3089 | 3089 | } else { |
3090 | 3090 | return $this->_raiseFormulaError('Unable to access Cell Reference'); |
3091 | 3091 | } |
3092 | - $stack->push('Cell Reference',$cellValue,$cellRef); |
|
3092 | + $stack->push('Cell Reference', $cellValue, $cellRef); |
|
3093 | 3093 | } else { |
3094 | - $stack->push('Error',PHPExcel_Calculation_Functions::REF(),null); |
|
3094 | + $stack->push('Error', PHPExcel_Calculation_Functions::REF(), null); |
|
3095 | 3095 | } |
3096 | 3096 | |
3097 | 3097 | break; |
3098 | 3098 | case '+' : // Addition |
3099 | - $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'plusEquals',$stack); |
|
3099 | + $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'plusEquals', $stack); |
|
3100 | 3100 | break; |
3101 | 3101 | case '-' : // Subtraction |
3102 | - $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'minusEquals',$stack); |
|
3102 | + $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'minusEquals', $stack); |
|
3103 | 3103 | break; |
3104 | 3104 | case '*' : // Multiplication |
3105 | - $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayTimesEquals',$stack); |
|
3105 | + $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayTimesEquals', $stack); |
|
3106 | 3106 | break; |
3107 | 3107 | case '/' : // Division |
3108 | - $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayRightDivide',$stack); |
|
3108 | + $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayRightDivide', $stack); |
|
3109 | 3109 | break; |
3110 | 3110 | case '^' : // Exponential |
3111 | - $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'power',$stack); |
|
3111 | + $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'power', $stack); |
|
3112 | 3112 | break; |
3113 | 3113 | case '&' : // Concatenation |
3114 | 3114 | // If either of the operands is a matrix, we need to treat them both as matrices |
@@ -3122,7 +3122,7 @@ discard block |
||
3122 | 3122 | } |
3123 | 3123 | if ((is_array($operand1)) || (is_array($operand2))) { |
3124 | 3124 | // Ensure that both operands are arrays/matrices |
3125 | - self::_checkMatrixOperands($operand1,$operand2,2); |
|
3125 | + self::_checkMatrixOperands($operand1, $operand2, 2); |
|
3126 | 3126 | try { |
3127 | 3127 | // Convert operand 1 from a PHP array to a matrix |
3128 | 3128 | $matrix = new PHPExcel_Shared_JAMA_Matrix($operand1); |
@@ -3134,24 +3134,24 @@ discard block |
||
3134 | 3134 | $result = '#VALUE!'; |
3135 | 3135 | } |
3136 | 3136 | } else { |
3137 | - $result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"'; |
|
3137 | + $result = '"'.str_replace('""', '"', self::_unwrapResult($operand1, '"').self::_unwrapResult($operand2, '"')).'"'; |
|
3138 | 3138 | } |
3139 | 3139 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); |
3140 | - $stack->push('Value',$result); |
|
3140 | + $stack->push('Value', $result); |
|
3141 | 3141 | break; |
3142 | 3142 | case '|' : // Intersect |
3143 | - $rowIntersect = array_intersect_key($operand1,$operand2); |
|
3143 | + $rowIntersect = array_intersect_key($operand1, $operand2); |
|
3144 | 3144 | $cellIntersect = $oCol = $oRow = array(); |
3145 | - foreach(array_keys($rowIntersect) as $row) { |
|
3145 | + foreach (array_keys($rowIntersect) as $row) { |
|
3146 | 3146 | $oRow[] = $row; |
3147 | - foreach($rowIntersect[$row] as $col => $data) { |
|
3147 | + foreach ($rowIntersect[$row] as $col => $data) { |
|
3148 | 3148 | $oCol[] = PHPExcel_Cell::columnIndexFromString($col) - 1; |
3149 | - $cellIntersect[$row] = array_intersect_key($operand1[$row],$operand2[$row]); |
|
3149 | + $cellIntersect[$row] = array_intersect_key($operand1[$row], $operand2[$row]); |
|
3150 | 3150 | } |
3151 | 3151 | } |
3152 | 3152 | $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow); |
3153 | 3153 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($cellIntersect)); |
3154 | - $stack->push('Value',$cellIntersect,$cellRef); |
|
3154 | + $stack->push('Value', $cellIntersect, $cellRef); |
|
3155 | 3155 | break; |
3156 | 3156 | } |
3157 | 3157 | |
@@ -3170,7 +3170,7 @@ discard block |
||
3170 | 3170 | $multiplier = 0.01; |
3171 | 3171 | } |
3172 | 3172 | if (is_array($arg)) { |
3173 | - self::_checkMatrixOperands($arg,$multiplier,2); |
|
3173 | + self::_checkMatrixOperands($arg, $multiplier, 2); |
|
3174 | 3174 | try { |
3175 | 3175 | $matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg); |
3176 | 3176 | $matrixResult = $matrix1->arrayTimesEquals($multiplier); |
@@ -3180,9 +3180,9 @@ discard block |
||
3180 | 3180 | $result = '#VALUE!'; |
3181 | 3181 | } |
3182 | 3182 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); |
3183 | - $stack->push('Value',$result); |
|
3183 | + $stack->push('Value', $result); |
|
3184 | 3184 | } else { |
3185 | - $this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack); |
|
3185 | + $this->_executeNumericBinaryOperation($cellID, $multiplier, $arg, '*', 'arrayTimesEquals', $stack); |
|
3186 | 3186 | } |
3187 | 3187 | |
3188 | 3188 | } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) { |
@@ -3196,12 +3196,12 @@ discard block |
||
3196 | 3196 | } else { |
3197 | 3197 | $cellRef = $matches[6].$matches[7].':'.$matches[9].$matches[10]; |
3198 | 3198 | if ($matches[2] > '') { |
3199 | - $matches[2] = trim($matches[2],"\"'"); |
|
3200 | - if ((strpos($matches[2],'[') !== false) || (strpos($matches[2],']') !== false)) { |
|
3199 | + $matches[2] = trim($matches[2], "\"'"); |
|
3200 | + if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { |
|
3201 | 3201 | // It's a Reference to an external workbook (not currently supported) |
3202 | 3202 | return $this->_raiseFormulaError('Unable to access External Workbook'); |
3203 | 3203 | } |
3204 | - $matches[2] = trim($matches[2],"\"'"); |
|
3204 | + $matches[2] = trim($matches[2], "\"'"); |
|
3205 | 3205 | // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />'; |
3206 | 3206 | $this->_writeDebug('Evaluating Cell Range '.$cellRef.' in worksheet '.$matches[2]); |
3207 | 3207 | if ($pCellParent !== NULL) { |
@@ -3230,8 +3230,8 @@ discard block |
||
3230 | 3230 | } else { |
3231 | 3231 | $cellRef = $matches[6].$matches[7]; |
3232 | 3232 | if ($matches[2] > '') { |
3233 | - $matches[2] = trim($matches[2],"\"'"); |
|
3234 | - if ((strpos($matches[2],'[') !== false) || (strpos($matches[2],']') !== false)) { |
|
3233 | + $matches[2] = trim($matches[2], "\"'"); |
|
3234 | + if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { |
|
3235 | 3235 | // It's a Reference to an external workbook (not currently supported) |
3236 | 3236 | return $this->_raiseFormulaError('Unable to access External Workbook'); |
3237 | 3237 | } |
@@ -3262,7 +3262,7 @@ discard block |
||
3262 | 3262 | } |
3263 | 3263 | } |
3264 | 3264 | } |
3265 | - $stack->push('Value',$cellValue,$cellRef); |
|
3265 | + $stack->push('Value', $cellValue, $cellRef); |
|
3266 | 3266 | |
3267 | 3267 | // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on |
3268 | 3268 | } elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $token, $matches)) { |
@@ -3316,7 +3316,7 @@ discard block |
||
3316 | 3316 | if ($functionName != 'MKMATRIX') { |
3317 | 3317 | if ($this->writeDebugLog) { |
3318 | 3318 | krsort($argArrayVals); |
3319 | - $this->_writeDebug('Evaluating '. self::_localeFunc($functionName).'( '.implode(self::$_localeArgumentSeparator.' ',PHPExcel_Calculation_Functions::flattenArray($argArrayVals)).' )'); |
|
3319 | + $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.implode(self::$_localeArgumentSeparator.' ', PHPExcel_Calculation_Functions::flattenArray($argArrayVals)).' )'); |
|
3320 | 3320 | } |
3321 | 3321 | } |
3322 | 3322 | // Process each argument in turn, building the return value as an array |
@@ -3346,20 +3346,20 @@ discard block |
||
3346 | 3346 | if ($passCellReference) { |
3347 | 3347 | $args[] = $pCell; |
3348 | 3348 | } |
3349 | - if (strpos($functionCall,'::') !== false) { |
|
3350 | - $result = call_user_func_array(explode('::',$functionCall),$args); |
|
3349 | + if (strpos($functionCall, '::') !== false) { |
|
3350 | + $result = call_user_func_array(explode('::', $functionCall), $args); |
|
3351 | 3351 | } else { |
3352 | - foreach($args as &$arg) { |
|
3352 | + foreach ($args as &$arg) { |
|
3353 | 3353 | $arg = PHPExcel_Calculation_Functions::flattenSingleValue($arg); |
3354 | 3354 | } |
3355 | 3355 | unset($arg); |
3356 | - $result = call_user_func_array($functionCall,$args); |
|
3356 | + $result = call_user_func_array($functionCall, $args); |
|
3357 | 3357 | } |
3358 | 3358 | // } |
3359 | 3359 | if ($functionName != 'MKMATRIX') { |
3360 | 3360 | $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.$this->_showTypeDetails($result)); |
3361 | 3361 | } |
3362 | - $stack->push('Value',self::_wrapResult($result)); |
|
3362 | + $stack->push('Value', self::_wrapResult($result)); |
|
3363 | 3363 | } |
3364 | 3364 | |
3365 | 3365 | } else { |
@@ -3367,11 +3367,11 @@ discard block |
||
3367 | 3367 | if (isset(self::$_ExcelConstants[strtoupper($token)])) { |
3368 | 3368 | $excelConstant = strtoupper($token); |
3369 | 3369 | // echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />'; |
3370 | - $stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]); |
|
3370 | + $stack->push('Constant Value', self::$_ExcelConstants[$excelConstant]); |
|
3371 | 3371 | $this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.$this->_showTypeDetails(self::$_ExcelConstants[$excelConstant])); |
3372 | 3372 | } elseif ((is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) { |
3373 | 3373 | // echo 'Token is a number, boolean, string, null or an Excel error<br />'; |
3374 | - $stack->push('Value',$token); |
|
3374 | + $stack->push('Value', $token); |
|
3375 | 3375 | // if the token is a named range, push the named range name onto the stack |
3376 | 3376 | } elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) { |
3377 | 3377 | // echo 'Token is a named range<br />'; |
@@ -3381,7 +3381,7 @@ discard block |
||
3381 | 3381 | $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false); |
3382 | 3382 | $pCell->attach($pCellParent); |
3383 | 3383 | $this->_writeDebug('Evaluation Result for named range '.$namedRange.' is '.$this->_showTypeDetails($cellValue)); |
3384 | - $stack->push('Named Range',$cellValue,$namedRange); |
|
3384 | + $stack->push('Named Range', $cellValue, $namedRange); |
|
3385 | 3385 | } else { |
3386 | 3386 | return $this->_raiseFormulaError("undefined variable '$token'"); |
3387 | 3387 | } |
@@ -3399,20 +3399,20 @@ discard block |
||
3399 | 3399 | } // function _processTokenStack() |
3400 | 3400 | |
3401 | 3401 | |
3402 | - private function _validateBinaryOperand($cellID,&$operand,&$stack) { |
|
3402 | + private function _validateBinaryOperand($cellID, &$operand, &$stack) { |
|
3403 | 3403 | // Numbers, matrices and booleans can pass straight through, as they're already valid |
3404 | 3404 | if (is_string($operand)) { |
3405 | 3405 | // We only need special validations for the operand if it is a string |
3406 | 3406 | // Start by stripping off the quotation marks we use to identify true excel string values internally |
3407 | 3407 | if ($operand > '' && $operand{0} == '"') { $operand = self::_unwrapResult($operand); } |
3408 | 3408 | // If the string is a numeric value, we treat it as a numeric, so no further testing |
3409 | - if (!is_numeric($operand)) { |
|
3409 | + if ( ! is_numeric($operand)) { |
|
3410 | 3410 | // If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations |
3411 | 3411 | if ($operand > '' && $operand{0} == '#') { |
3412 | 3412 | $stack->push('Value', $operand); |
3413 | 3413 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($operand)); |
3414 | 3414 | return false; |
3415 | - } elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) { |
|
3415 | + } elseif ( ! PHPExcel_Shared_String::convertToNumberIfFraction($operand)) { |
|
3416 | 3416 | // If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations |
3417 | 3417 | $stack->push('Value', '#VALUE!'); |
3418 | 3418 | $this->_writeDebug('Evaluation Result is a '.$this->_showTypeDetails('#VALUE!')); |
@@ -3426,29 +3426,29 @@ discard block |
||
3426 | 3426 | } // function _validateBinaryOperand() |
3427 | 3427 | |
3428 | 3428 | |
3429 | - private function _executeBinaryComparisonOperation($cellID,$operand1,$operand2,$operation,&$stack,$recursingArrays=false) { |
|
3429 | + private function _executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays = false) { |
|
3430 | 3430 | // If we're dealing with matrix operations, we want a matrix result |
3431 | 3431 | if ((is_array($operand1)) || (is_array($operand2))) { |
3432 | 3432 | $result = array(); |
3433 | - if ((is_array($operand1)) && (!is_array($operand2))) { |
|
3434 | - foreach($operand1 as $x => $operandData) { |
|
3433 | + if ((is_array($operand1)) && ( ! is_array($operand2))) { |
|
3434 | + foreach ($operand1 as $x => $operandData) { |
|
3435 | 3435 | $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2)); |
3436 | - $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack); |
|
3436 | + $this->_executeBinaryComparisonOperation($cellID, $operandData, $operand2, $operation, $stack); |
|
3437 | 3437 | $r = $stack->pop(); |
3438 | 3438 | $result[$x] = $r['value']; |
3439 | 3439 | } |
3440 | - } elseif ((!is_array($operand1)) && (is_array($operand2))) { |
|
3441 | - foreach($operand2 as $x => $operandData) { |
|
3440 | + } elseif (( ! is_array($operand1)) && (is_array($operand2))) { |
|
3441 | + foreach ($operand2 as $x => $operandData) { |
|
3442 | 3442 | $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData)); |
3443 | - $this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack); |
|
3443 | + $this->_executeBinaryComparisonOperation($cellID, $operand1, $operandData, $operation, $stack); |
|
3444 | 3444 | $r = $stack->pop(); |
3445 | 3445 | $result[$x] = $r['value']; |
3446 | 3446 | } |
3447 | 3447 | } else { |
3448 | - if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); } |
|
3449 | - foreach($operand1 as $x => $operandData) { |
|
3448 | + if ( ! $recursingArrays) { self::_checkMatrixOperands($operand1, $operand2, 2); } |
|
3449 | + foreach ($operand1 as $x => $operandData) { |
|
3450 | 3450 | $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x])); |
3451 | - $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true); |
|
3451 | + $this->_executeBinaryComparisonOperation($cellID, $operandData, $operand2[$x], $operation, $stack, true); |
|
3452 | 3452 | $r = $stack->pop(); |
3453 | 3453 | $result[$x] = $r['value']; |
3454 | 3454 | } |
@@ -3456,7 +3456,7 @@ discard block |
||
3456 | 3456 | // Log the result details |
3457 | 3457 | $this->_writeDebug('Comparison Evaluation Result is '.$this->_showTypeDetails($result)); |
3458 | 3458 | // And push the result onto the stack |
3459 | - $stack->push('Array',$result); |
|
3459 | + $stack->push('Array', $result); |
|
3460 | 3460 | return true; |
3461 | 3461 | } |
3462 | 3462 | |
@@ -3495,15 +3495,15 @@ discard block |
||
3495 | 3495 | // Log the result details |
3496 | 3496 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); |
3497 | 3497 | // And push the result onto the stack |
3498 | - $stack->push('Value',$result); |
|
3498 | + $stack->push('Value', $result); |
|
3499 | 3499 | return true; |
3500 | 3500 | } // function _executeBinaryComparisonOperation() |
3501 | 3501 | |
3502 | 3502 | |
3503 | - private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) { |
|
3503 | + private function _executeNumericBinaryOperation($cellID, $operand1, $operand2, $operation, $matrixFunction, &$stack) { |
|
3504 | 3504 | // Validate the two operands |
3505 | - if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return false; |
|
3506 | - if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return false; |
|
3505 | + if ( ! $this->_validateBinaryOperand($cellID, $operand1, $stack)) return false; |
|
3506 | + if ( ! $this->_validateBinaryOperand($cellID, $operand2, $stack)) return false; |
|
3507 | 3507 | |
3508 | 3508 | $executeMatrixOperation = false; |
3509 | 3509 | // If either of the operands is a matrix, we need to treat them both as matrices |
@@ -3513,7 +3513,7 @@ discard block |
||
3513 | 3513 | // Ensure that both operands are arrays/matrices |
3514 | 3514 | $executeMatrixOperation = true; |
3515 | 3515 | $mSize = array(); |
3516 | - list($mSize[],$mSize[],$mSize[],$mSize[]) = self::_checkMatrixOperands($operand1,$operand2,2); |
|
3516 | + list($mSize[], $mSize[], $mSize[], $mSize[]) = self::_checkMatrixOperands($operand1, $operand2, 2); |
|
3517 | 3517 | |
3518 | 3518 | // But if they're both single cell matrices, then we can treat them as simple values |
3519 | 3519 | if (array_sum($mSize) == 4) { |
@@ -3536,37 +3536,37 @@ discard block |
||
3536 | 3536 | } |
3537 | 3537 | } else { |
3538 | 3538 | if ((PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) && |
3539 | - ((is_string($operand1) && !is_numeric($operand1)) || (is_string($operand2) && !is_numeric($operand2)))) { |
|
3539 | + ((is_string($operand1) && ! is_numeric($operand1)) || (is_string($operand2) && ! is_numeric($operand2)))) { |
|
3540 | 3540 | $result = PHPExcel_Calculation_Functions::VALUE(); |
3541 | 3541 | } else { |
3542 | 3542 | // If we're dealing with non-matrix operations, execute the necessary operation |
3543 | 3543 | switch ($operation) { |
3544 | 3544 | // Addition |
3545 | 3545 | case '+': |
3546 | - $result = $operand1+$operand2; |
|
3546 | + $result = $operand1 + $operand2; |
|
3547 | 3547 | break; |
3548 | 3548 | // Subtraction |
3549 | 3549 | case '-': |
3550 | - $result = $operand1-$operand2; |
|
3550 | + $result = $operand1 - $operand2; |
|
3551 | 3551 | break; |
3552 | 3552 | // Multiplication |
3553 | 3553 | case '*': |
3554 | - $result = $operand1*$operand2; |
|
3554 | + $result = $operand1 * $operand2; |
|
3555 | 3555 | break; |
3556 | 3556 | // Division |
3557 | 3557 | case '/': |
3558 | 3558 | if ($operand2 == 0) { |
3559 | 3559 | // Trap for Divide by Zero error |
3560 | - $stack->push('Value','#DIV/0!'); |
|
3560 | + $stack->push('Value', '#DIV/0!'); |
|
3561 | 3561 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails('#DIV/0!')); |
3562 | 3562 | return false; |
3563 | 3563 | } else { |
3564 | - $result = $operand1/$operand2; |
|
3564 | + $result = $operand1 / $operand2; |
|
3565 | 3565 | } |
3566 | 3566 | break; |
3567 | 3567 | // Power |
3568 | 3568 | case '^': |
3569 | - $result = pow($operand1,$operand2); |
|
3569 | + $result = pow($operand1, $operand2); |
|
3570 | 3570 | break; |
3571 | 3571 | } |
3572 | 3572 | } |
@@ -3575,7 +3575,7 @@ discard block |
||
3575 | 3575 | // Log the result details |
3576 | 3576 | $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); |
3577 | 3577 | // And push the result onto the stack |
3578 | - $stack->push('Value',$result); |
|
3578 | + $stack->push('Value', $result); |
|
3579 | 3579 | return true; |
3580 | 3580 | } // function _executeNumericBinaryOperation() |
3581 | 3581 | |
@@ -3584,9 +3584,9 @@ discard block |
||
3584 | 3584 | // Only write the debug log if logging is enabled |
3585 | 3585 | if ($this->writeDebugLog) { |
3586 | 3586 | if ($this->echoDebugLog) { |
3587 | - echo implode(' -> ',$this->debugLogStack).' -> '.$message,'<br />'; |
|
3587 | + echo implode(' -> ', $this->debugLogStack).' -> '.$message, '<br />'; |
|
3588 | 3588 | } |
3589 | - $this->debugLog[] = implode(' -> ',$this->debugLogStack).' -> '.$message; |
|
3589 | + $this->debugLog[] = implode(' -> ', $this->debugLogStack).' -> '.$message; |
|
3590 | 3590 | } |
3591 | 3591 | } // function _writeDebug() |
3592 | 3592 | |
@@ -3595,7 +3595,7 @@ discard block |
||
3595 | 3595 | protected function _raiseFormulaError($errorMessage) { |
3596 | 3596 | $this->formulaError = $errorMessage; |
3597 | 3597 | $this->debugLogStack = array(); |
3598 | - if (!$this->suppressFormulaErrors) throw new Exception($errorMessage); |
|
3598 | + if ( ! $this->suppressFormulaErrors) throw new Exception($errorMessage); |
|
3599 | 3599 | trigger_error($errorMessage, E_USER_ERROR); |
3600 | 3600 | } // function _raiseFormulaError() |
3601 | 3601 | |
@@ -3608,15 +3608,15 @@ discard block |
||
3608 | 3608 | * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. |
3609 | 3609 | * @throws Exception |
3610 | 3610 | */ |
3611 | - public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog=true) { |
|
3611 | + public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog = true) { |
|
3612 | 3612 | // Return value |
3613 | - $returnValue = array (); |
|
3613 | + $returnValue = array(); |
|
3614 | 3614 | |
3615 | 3615 | // echo 'extractCellRange('.$pRange.')<br />'; |
3616 | 3616 | if ($pSheet !== NULL) { |
3617 | 3617 | // echo 'Passed sheet name is '.$pSheet->getTitle().'<br />'; |
3618 | 3618 | // echo 'Range reference is '.$pRange.'<br />'; |
3619 | - if (strpos ($pRange, '!') !== false) { |
|
3619 | + if (strpos($pRange, '!') !== false) { |
|
3620 | 3620 | // echo '$pRange reference includes sheet reference<br />'; |
3621 | 3621 | $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true); |
3622 | 3622 | $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]); |
@@ -3628,9 +3628,9 @@ discard block |
||
3628 | 3628 | // Extract range |
3629 | 3629 | $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); |
3630 | 3630 | $pRange = $pSheet->getTitle().'!'.$pRange; |
3631 | - if (!isset($aReferences[1])) { |
|
3631 | + if ( ! isset($aReferences[1])) { |
|
3632 | 3632 | // Single cell in range |
3633 | - list($currentCol,$currentRow) = sscanf($aReferences[0],'%[A-Z]%d'); |
|
3633 | + list($currentCol, $currentRow) = sscanf($aReferences[0], '%[A-Z]%d'); |
|
3634 | 3634 | if ($pSheet->cellExists($aReferences[0])) { |
3635 | 3635 | $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); |
3636 | 3636 | } else { |
@@ -3640,7 +3640,7 @@ discard block |
||
3640 | 3640 | // Extract cell data for all cells in the range |
3641 | 3641 | foreach ($aReferences as $reference) { |
3642 | 3642 | // Extract range |
3643 | - list($currentCol,$currentRow) = sscanf($reference,'%[A-Z]%d'); |
|
3643 | + list($currentCol, $currentRow) = sscanf($reference, '%[A-Z]%d'); |
|
3644 | 3644 | |
3645 | 3645 | if ($pSheet->cellExists($reference)) { |
3646 | 3646 | $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); |
@@ -3664,15 +3664,15 @@ discard block |
||
3664 | 3664 | * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. |
3665 | 3665 | * @throws Exception |
3666 | 3666 | */ |
3667 | - public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog=true) { |
|
3667 | + public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog = true) { |
|
3668 | 3668 | // Return value |
3669 | - $returnValue = array (); |
|
3669 | + $returnValue = array(); |
|
3670 | 3670 | |
3671 | 3671 | // echo 'extractNamedRange('.$pRange.')<br />'; |
3672 | 3672 | if ($pSheet !== NULL) { |
3673 | 3673 | // echo 'Current sheet name is '.$pSheet->getTitle().'<br />'; |
3674 | 3674 | // echo 'Range reference is '.$pRange.'<br />'; |
3675 | - if (strpos ($pRange, '!') !== false) { |
|
3675 | + if (strpos($pRange, '!') !== false) { |
|
3676 | 3676 | // echo '$pRange reference includes sheet reference<br />'; |
3677 | 3677 | $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true); |
3678 | 3678 | $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]); |
@@ -3690,9 +3690,9 @@ discard block |
||
3690 | 3690 | $splitRange = PHPExcel_Cell::splitRange($pRange); |
3691 | 3691 | // Convert row and column references |
3692 | 3692 | if (ctype_alpha($splitRange[0][0])) { |
3693 | - $pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow(); |
|
3694 | - } elseif(ctype_digit($splitRange[0][0])) { |
|
3695 | - $pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1]; |
|
3693 | + $pRange = $splitRange[0][0].'1:'.$splitRange[0][1].$namedRange->getWorksheet()->getHighestRow(); |
|
3694 | + } elseif (ctype_digit($splitRange[0][0])) { |
|
3695 | + $pRange = 'A'.$splitRange[0][0].':'.$namedRange->getWorksheet()->getHighestColumn().$splitRange[0][1]; |
|
3696 | 3696 | } |
3697 | 3697 | // echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />'; |
3698 | 3698 | |
@@ -3710,9 +3710,9 @@ discard block |
||
3710 | 3710 | // Extract range |
3711 | 3711 | $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); |
3712 | 3712 | // var_dump($aReferences); |
3713 | - if (!isset($aReferences[1])) { |
|
3713 | + if ( ! isset($aReferences[1])) { |
|
3714 | 3714 | // Single cell (or single column or row) in range |
3715 | - list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]); |
|
3715 | + list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]); |
|
3716 | 3716 | if ($pSheet->cellExists($aReferences[0])) { |
3717 | 3717 | $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); |
3718 | 3718 | } else { |
@@ -3722,7 +3722,7 @@ discard block |
||
3722 | 3722 | // Extract cell data for all cells in the range |
3723 | 3723 | foreach ($aReferences as $reference) { |
3724 | 3724 | // Extract range |
3725 | - list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference); |
|
3725 | + list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference); |
|
3726 | 3726 | // echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />'; |
3727 | 3727 | if ($pSheet->cellExists($reference)) { |
3728 | 3728 | $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); |
@@ -3747,7 +3747,7 @@ discard block |
||
3747 | 3747 | * @return boolean |
3748 | 3748 | */ |
3749 | 3749 | public function isImplemented($pFunction = '') { |
3750 | - $pFunction = strtoupper ($pFunction); |
|
3750 | + $pFunction = strtoupper($pFunction); |
|
3751 | 3751 | if (isset(self::$_PHPExcelFunctions[$pFunction])) { |
3752 | 3752 | return (self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY'); |
3753 | 3753 | } else { |
@@ -3765,7 +3765,7 @@ discard block |
||
3765 | 3765 | // Return value |
3766 | 3766 | $returnValue = array(); |
3767 | 3767 | // Loop functions |
3768 | - foreach(self::$_PHPExcelFunctions as $functionName => $function) { |
|
3768 | + foreach (self::$_PHPExcelFunctions as $functionName => $function) { |
|
3769 | 3769 | if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') { |
3770 | 3770 | $returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'], |
3771 | 3771 | $functionName, |
@@ -3797,7 +3797,7 @@ discard block |
||
3797 | 3797 | // Return value |
3798 | 3798 | $returnValue = array(); |
3799 | 3799 | // Loop functions |
3800 | - foreach(self::$_PHPExcelFunctions as $functionName => $function) { |
|
3800 | + foreach (self::$_PHPExcelFunctions as $functionName => $function) { |
|
3801 | 3801 | if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') { |
3802 | 3802 | $returnValue[] = $functionName; |
3803 | 3803 | } |
@@ -3824,7 +3824,7 @@ discard block |
||
3824 | 3824 | } // function count() |
3825 | 3825 | |
3826 | 3826 | |
3827 | - public function push($type,$value,$reference=null) { |
|
3827 | + public function push($type, $value, $reference = null) { |
|
3828 | 3828 | $this->_stack[$this->_count++] = array('type' => $type, |
3829 | 3829 | 'value' => $value, |
3830 | 3830 | 'reference' => $reference |
@@ -3846,11 +3846,11 @@ discard block |
||
3846 | 3846 | } // function pop() |
3847 | 3847 | |
3848 | 3848 | |
3849 | - public function last($n=1) { |
|
3850 | - if ($this->_count-$n < 0) { |
|
3849 | + public function last($n = 1) { |
|
3850 | + if ($this->_count - $n < 0) { |
|
3851 | 3851 | return null; |
3852 | 3852 | } |
3853 | - return $this->_stack[$this->_count-$n]; |
|
3853 | + return $this->_stack[$this->_count - $n]; |
|
3854 | 3854 | } // function last() |
3855 | 3855 | |
3856 | 3856 |
@@ -2208,9 +2208,13 @@ discard block |
||
2208 | 2208 | // Basic validation that this is indeed a formula |
2209 | 2209 | // We return an empty array if not |
2210 | 2210 | $formula = trim($formula); |
2211 | - if ((!isset($formula{0})) || ($formula{0} != '=')) return array(); |
|
2211 | + if ((!isset($formula{0})) || ($formula{0} != '=')) { |
|
2212 | + return array(); |
|
2213 | + } |
|
2212 | 2214 | $formula = ltrim(substr($formula,1)); |
2213 | - if (!isset($formula{0})) return array(); |
|
2215 | + if (!isset($formula{0})) { |
|
2216 | + return array(); |
|
2217 | + } |
|
2214 | 2218 | |
2215 | 2219 | // Parse the formula and return the token stack |
2216 | 2220 | return $this->_parseFormula($formula); |
@@ -2263,9 +2267,13 @@ discard block |
||
2263 | 2267 | // Basic validation that this is indeed a formula |
2264 | 2268 | // We simply return the "cell value" (formula) if not |
2265 | 2269 | $formula = trim($formula); |
2266 | - if ($formula{0} != '=') return self::_wrapResult($formula); |
|
2270 | + if ($formula{0} != '=') { |
|
2271 | + return self::_wrapResult($formula); |
|
2272 | + } |
|
2267 | 2273 | $formula = ltrim(substr($formula,1)); |
2268 | - if (!isset($formula{0})) return self::_wrapResult($formula); |
|
2274 | + if (!isset($formula{0})) { |
|
2275 | + return self::_wrapResult($formula); |
|
2276 | + } |
|
2269 | 2277 | |
2270 | 2278 | $wsTitle = "\x00Wrk"; |
2271 | 2279 | if ($pCell !== NULL) { |
@@ -2715,8 +2723,11 @@ discard block |
||
2715 | 2723 | // echo 'Element is a Closing bracket<br />'; |
2716 | 2724 | $expectingOperand = false; |
2717 | 2725 | while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( |
2718 | - if ($o2 === NULL) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"'); |
|
2719 | - else $output[] = $o2; |
|
2726 | + if ($o2 === NULL) { |
|
2727 | + return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"'); |
|
2728 | + } else { |
|
2729 | + $output[] = $o2; |
|
2730 | + } |
|
2720 | 2731 | } |
2721 | 2732 | $d = $stack->last(2); |
2722 | 2733 | if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? |
@@ -2794,8 +2805,12 @@ discard block |
||
2794 | 2805 | } elseif ($opCharacter == ',') { // Is this the separator for function arguments? |
2795 | 2806 | // echo 'Element is a Function argument separator<br />'; |
2796 | 2807 | while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( |
2797 | - if ($o2 === NULL) return $this->_raiseFormulaError("Formula Error: Unexpected ,"); |
|
2798 | - else $output[] = $o2; // pop the argument expression stuff and push onto the output |
|
2808 | + if ($o2 === NULL) { |
|
2809 | + return $this->_raiseFormulaError("Formula Error: Unexpected ,"); |
|
2810 | + } else { |
|
2811 | + $output[] = $o2; |
|
2812 | + } |
|
2813 | + // pop the argument expression stuff and push onto the output |
|
2799 | 2814 | } |
2800 | 2815 | // If we've a comma when we're expecting an operand, then what we actually have is a null operand; |
2801 | 2816 | // so push a null onto the stack |
@@ -2804,8 +2819,9 @@ discard block |
||
2804 | 2819 | } |
2805 | 2820 | // make sure there was a function |
2806 | 2821 | $d = $stack->last(2); |
2807 | - if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) |
|
2808 | - return $this->_raiseFormulaError("Formula Error: Unexpected ,"); |
|
2822 | + if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { |
|
2823 | + return $this->_raiseFormulaError("Formula Error: Unexpected ,"); |
|
2824 | + } |
|
2809 | 2825 | $d = $stack->pop(); |
2810 | 2826 | $stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count |
2811 | 2827 | $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again |
@@ -2876,12 +2892,16 @@ discard block |
||
2876 | 2892 | if (strpos('!',$startRowColRef) !== false) { |
2877 | 2893 | list($rangeWS1,$startRowColRef) = explode('!',$startRowColRef); |
2878 | 2894 | } |
2879 | - if ($rangeWS1 != '') $rangeWS1 .= '!'; |
|
2895 | + if ($rangeWS1 != '') { |
|
2896 | + $rangeWS1 .= '!'; |
|
2897 | + } |
|
2880 | 2898 | $rangeWS2 = $rangeWS1; |
2881 | 2899 | if (strpos('!',$val) !== false) { |
2882 | 2900 | list($rangeWS2,$val) = explode('!',$val); |
2883 | 2901 | } |
2884 | - if ($rangeWS2 != '') $rangeWS2 .= '!'; |
|
2902 | + if ($rangeWS2 != '') { |
|
2903 | + $rangeWS2 .= '!'; |
|
2904 | + } |
|
2885 | 2905 | if ((is_integer($startRowColRef)) && (ctype_digit($val)) && |
2886 | 2906 | ($startRowColRef <= 1048576) && ($val <= 1048576)) { |
2887 | 2907 | // Row range |
@@ -2977,8 +2997,10 @@ discard block |
||
2977 | 2997 | } |
2978 | 2998 | |
2979 | 2999 | while (($op = $stack->pop()) !== NULL) { // pop everything off the stack and push onto output |
2980 | - if ((is_array($opCharacter) && $opCharacter['value'] == '(') || ($opCharacter === '(')) |
|
2981 | - return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced |
|
3000 | + if ((is_array($opCharacter) && $opCharacter['value'] == '(') || ($opCharacter === '(')) { |
|
3001 | + return $this->_raiseFormulaError("Formula Error: Expecting ')'"); |
|
3002 | + } |
|
3003 | + // if there are any opening braces on the stack, then braces were unbalanced |
|
2982 | 3004 | $output[] = $op; |
2983 | 3005 | } |
2984 | 3006 | return $output; |
@@ -3002,7 +3024,9 @@ discard block |
||
3002 | 3024 | |
3003 | 3025 | // evaluate postfix notation |
3004 | 3026 | private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) { |
3005 | - if ($tokens == false) return false; |
|
3027 | + if ($tokens == false) { |
|
3028 | + return false; |
|
3029 | + } |
|
3006 | 3030 | |
3007 | 3031 | // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet), |
3008 | 3032 | // so we store the parent worksheet so that we can re-attach it when necessary |
@@ -3019,8 +3043,12 @@ discard block |
||
3019 | 3043 | if (isset(self::$_binaryOperators[$token])) { |
3020 | 3044 | // echo 'Token is a binary operator<br />'; |
3021 | 3045 | // We must have two operands, error if we don't |
3022 | - if (($operand2Data = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); |
|
3023 | - if (($operand1Data = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); |
|
3046 | + if (($operand2Data = $stack->pop()) === NULL) { |
|
3047 | + return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); |
|
3048 | + } |
|
3049 | + if (($operand1Data = $stack->pop()) === NULL) { |
|
3050 | + return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); |
|
3051 | + } |
|
3024 | 3052 | |
3025 | 3053 | $operand1 = self::_dataTestReference($operand1Data); |
3026 | 3054 | $operand2 = self::_dataTestReference($operand2Data); |
@@ -3158,7 +3186,9 @@ discard block |
||
3158 | 3186 | // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on |
3159 | 3187 | } elseif (($token === '~') || ($token === '%')) { |
3160 | 3188 | // echo 'Token is a unary operator<br />'; |
3161 | - if (($arg = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); |
|
3189 | + if (($arg = $stack->pop()) === NULL) { |
|
3190 | + return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); |
|
3191 | + } |
|
3162 | 3192 | $arg = $arg['value']; |
3163 | 3193 | if ($token === '~') { |
3164 | 3194 | // echo 'Token is a negation operator<br />'; |
@@ -3388,7 +3418,9 @@ discard block |
||
3388 | 3418 | } |
3389 | 3419 | } |
3390 | 3420 | // when we're out of tokens, the stack should have a single element, the final result |
3391 | - if ($stack->count() != 1) return $this->_raiseFormulaError("internal error"); |
|
3421 | + if ($stack->count() != 1) { |
|
3422 | + return $this->_raiseFormulaError("internal error"); |
|
3423 | + } |
|
3392 | 3424 | $output = $stack->pop(); |
3393 | 3425 | $output = $output['value']; |
3394 | 3426 | |
@@ -3502,8 +3534,12 @@ discard block |
||
3502 | 3534 | |
3503 | 3535 | private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) { |
3504 | 3536 | // Validate the two operands |
3505 | - if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return false; |
|
3506 | - if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return false; |
|
3537 | + if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) { |
|
3538 | + return false; |
|
3539 | + } |
|
3540 | + if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) { |
|
3541 | + return false; |
|
3542 | + } |
|
3507 | 3543 | |
3508 | 3544 | $executeMatrixOperation = false; |
3509 | 3545 | // If either of the operands is a matrix, we need to treat them both as matrices |
@@ -3595,7 +3631,9 @@ discard block |
||
3595 | 3631 | protected function _raiseFormulaError($errorMessage) { |
3596 | 3632 | $this->formulaError = $errorMessage; |
3597 | 3633 | $this->debugLogStack = array(); |
3598 | - if (!$this->suppressFormulaErrors) throw new Exception($errorMessage); |
|
3634 | + if (!$this->suppressFormulaErrors) { |
|
3635 | + throw new Exception($errorMessage); |
|
3636 | + } |
|
3599 | 3637 | trigger_error($errorMessage, E_USER_ERROR); |
3600 | 3638 | } // function _raiseFormulaError() |
3601 | 3639 |
@@ -56,6 +56,9 @@ discard block |
||
56 | 56 | } // function _isLeapYear() |
57 | 57 | |
58 | 58 | |
59 | + /** |
|
60 | + * @param boolean $methodUS |
|
61 | + */ |
|
59 | 62 | private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) { |
60 | 63 | if ($startDay == 31) { |
61 | 64 | --$startDay; |
@@ -443,7 +446,7 @@ discard block |
||
443 | 446 | * |
444 | 447 | * @access public |
445 | 448 | * @category Date/Time Functions |
446 | - * @param string $dateValue Text that represents a date in a Microsoft Excel date format. |
|
449 | + * @param integer $dateValue Text that represents a date in a Microsoft Excel date format. |
|
447 | 450 | * For example, "1/30/2008" or "30-Jan-2008" are text strings within |
448 | 451 | * quotation marks that represent dates. Using the default date |
449 | 452 | * system in Excel for Windows, date_text must represent a date from |
@@ -584,9 +587,9 @@ discard block |
||
584 | 587 | /** |
585 | 588 | * DATEDIF |
586 | 589 | * |
587 | - * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
|
590 | + * @param integer $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
|
588 | 591 | * or a standard date string |
589 | - * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
|
592 | + * @param integer $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
|
590 | 593 | * or a standard date string |
591 | 594 | * @param string $unit |
592 | 595 | * @return integer Interval between the dates |
@@ -692,9 +695,9 @@ discard block |
||
692 | 695 | * |
693 | 696 | * @access public |
694 | 697 | * @category Date/Time Functions |
695 | - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
|
698 | + * @param integer $startDate Excel date serial value (float), PHP date timestamp (integer), |
|
696 | 699 | * PHP DateTime object, or a standard date string |
697 | - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
|
700 | + * @param integer $endDate Excel date serial value (float), PHP date timestamp (integer), |
|
698 | 701 | * PHP DateTime object, or a standard date string |
699 | 702 | * @param boolean $method US or European Method |
700 | 703 | * FALSE or omitted: U.S. (NASD) method. If the starting date is |
@@ -748,9 +751,9 @@ discard block |
||
748 | 751 | * |
749 | 752 | * @access public |
750 | 753 | * @category Date/Time Functions |
751 | - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
|
754 | + * @param integer $startDate Excel date serial value (float), PHP date timestamp (integer), |
|
752 | 755 | * PHP DateTime object, or a standard date string |
753 | - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
|
756 | + * @param integer $endDate Excel date serial value (float), PHP date timestamp (integer), |
|
754 | 757 | * PHP DateTime object, or a standard date string |
755 | 758 | * @param integer $method Method used for the calculation |
756 | 759 | * 0 or omitted US (NASD) 30/360 |
@@ -849,10 +852,6 @@ discard block |
||
849 | 852 | * PHP DateTime object, or a standard date string |
850 | 853 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
851 | 854 | * PHP DateTime object, or a standard date string |
852 | - * @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date |
|
853 | - * timestamp (integer), PHP DateTime object, or a standard date |
|
854 | - * strings that will be excluded from the working calendar, such |
|
855 | - * as state and federal holidays and floating holidays. |
|
856 | 855 | * @return integer Interval between the dates |
857 | 856 | */ |
858 | 857 | public static function NETWORKDAYS($startDate,$endDate) { |
@@ -930,10 +929,6 @@ discard block |
||
930 | 929 | * @param integer $endDays The number of nonweekend and nonholiday days before or after |
931 | 930 | * startDate. A positive value for days yields a future date; a |
932 | 931 | * negative value yields a past date. |
933 | - * @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date |
|
934 | - * timestamp (integer), PHP DateTime object, or a standard date |
|
935 | - * strings that will be excluded from the working calendar, such |
|
936 | - * as state and federal holidays and floating holidays. |
|
937 | 932 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
938 | 933 | * depending on the value of the ReturnDateType flag |
939 | 934 | */ |
@@ -1036,7 +1031,7 @@ discard block |
||
1036 | 1031 | * Excel Function: |
1037 | 1032 | * DAY(dateValue) |
1038 | 1033 | * |
1039 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1034 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1040 | 1035 | * PHP DateTime object, or a standard date string |
1041 | 1036 | * @return int Day of the month |
1042 | 1037 | */ |
@@ -1067,7 +1062,7 @@ discard block |
||
1067 | 1062 | * Excel Function: |
1068 | 1063 | * WEEKDAY(dateValue[,style]) |
1069 | 1064 | * |
1070 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1065 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1071 | 1066 | * PHP DateTime object, or a standard date string |
1072 | 1067 | * @param int $style A number that determines the type of return value |
1073 | 1068 | * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). |
@@ -1134,9 +1129,9 @@ discard block |
||
1134 | 1129 | * Excel Function: |
1135 | 1130 | * WEEKNUM(dateValue[,style]) |
1136 | 1131 | * |
1137 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1132 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1138 | 1133 | * PHP DateTime object, or a standard date string |
1139 | - * @param boolean $method Week begins on Sunday or Monday |
|
1134 | + * @param integer $method Week begins on Sunday or Monday |
|
1140 | 1135 | * 1 or omitted Week begins on Sunday. |
1141 | 1136 | * 2 Week begins on Monday. |
1142 | 1137 | * @return int Week Number |
@@ -1181,7 +1176,7 @@ discard block |
||
1181 | 1176 | * Excel Function: |
1182 | 1177 | * MONTH(dateValue) |
1183 | 1178 | * |
1184 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1179 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1185 | 1180 | * PHP DateTime object, or a standard date string |
1186 | 1181 | * @return int Month of the year |
1187 | 1182 | */ |
@@ -1210,7 +1205,7 @@ discard block |
||
1210 | 1205 | * Excel Function: |
1211 | 1206 | * YEAR(dateValue) |
1212 | 1207 | * |
1213 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1208 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1214 | 1209 | * PHP DateTime object, or a standard date string |
1215 | 1210 | * @return int Year |
1216 | 1211 | */ |
@@ -1239,7 +1234,7 @@ discard block |
||
1239 | 1234 | * Excel Function: |
1240 | 1235 | * HOUR(timeValue) |
1241 | 1236 | * |
1242 | - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
|
1237 | + * @param integer $timeValue Excel date serial value (float), PHP date timestamp (integer), |
|
1243 | 1238 | * PHP DateTime object, or a standard time string |
1244 | 1239 | * @return int Hour |
1245 | 1240 | */ |
@@ -1279,7 +1274,7 @@ discard block |
||
1279 | 1274 | * Excel Function: |
1280 | 1275 | * MINUTE(timeValue) |
1281 | 1276 | * |
1282 | - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
|
1277 | + * @param integer $timeValue Excel date serial value (float), PHP date timestamp (integer), |
|
1283 | 1278 | * PHP DateTime object, or a standard time string |
1284 | 1279 | * @return int Minute |
1285 | 1280 | */ |
@@ -1319,7 +1314,7 @@ discard block |
||
1319 | 1314 | * Excel Function: |
1320 | 1315 | * SECOND(timeValue) |
1321 | 1316 | * |
1322 | - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
|
1317 | + * @param integer $timeValue Excel date serial value (float), PHP date timestamp (integer), |
|
1323 | 1318 | * PHP DateTime object, or a standard time string |
1324 | 1319 | * @return int Second |
1325 | 1320 | */ |
@@ -1361,7 +1356,7 @@ discard block |
||
1361 | 1356 | * Excel Function: |
1362 | 1357 | * EDATE(dateValue,adjustmentMonths) |
1363 | 1358 | * |
1364 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1359 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1365 | 1360 | * PHP DateTime object, or a standard date string |
1366 | 1361 | * @param int $adjustmentMonths The number of months before or after start_date. |
1367 | 1362 | * A positive value for months yields a future date; |
@@ -1406,7 +1401,7 @@ discard block |
||
1406 | 1401 | * Excel Function: |
1407 | 1402 | * EOMONTH(dateValue,adjustmentMonths) |
1408 | 1403 | * |
1409 | - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1404 | + * @param integer $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1410 | 1405 | * PHP DateTime object, or a standard date string |
1411 | 1406 | * @param int $adjustmentMonths The number of months before or after start_date. |
1412 | 1407 | * A positive value for months yields a future date; |
@@ -789,7 +789,7 @@ |
||
789 | 789 | $endDay = self::DAYOFMONTH($endDate); |
790 | 790 | if (($startMonth < 3) || |
791 | 791 | (($endMonth * 100 + $endDay) >= (2 * 100 + 29))) { |
792 | - $leapDays += 1; |
|
792 | + $leapDays += 1; |
|
793 | 793 | } |
794 | 794 | } |
795 | 795 | } else { |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) { |
60 | 60 | if ($startDay == 31) { |
61 | 61 | --$startDay; |
62 | - } elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !self::_isLeapYear($startYear))))) { |
|
62 | + } elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && ! self::_isLeapYear($startYear))))) { |
|
63 | 63 | $startDay = 30; |
64 | 64 | } |
65 | 65 | if ($endDay == 31) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return mixed Excel date/time serial value, or string if error |
88 | 88 | */ |
89 | 89 | public static function _getDateValue($dateValue) { |
90 | - if (!is_numeric($dateValue)) { |
|
90 | + if ( ! is_numeric($dateValue)) { |
|
91 | 91 | if ((is_string($dateValue)) && |
92 | 92 | (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) { |
93 | 93 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -274,32 +274,32 @@ discard block |
||
274 | 274 | * depending on the value of the ReturnDateType flag |
275 | 275 | */ |
276 | 276 | public static function DATE($year = 0, $month = 1, $day = 1) { |
277 | - $year = PHPExcel_Calculation_Functions::flattenSingleValue($year); |
|
278 | - $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); |
|
279 | - $day = PHPExcel_Calculation_Functions::flattenSingleValue($day); |
|
280 | - |
|
281 | - $year = ($year !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0; |
|
282 | - $month = ($month !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0; |
|
283 | - $day = ($day !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0; |
|
284 | - if ((!is_numeric($year)) || |
|
285 | - (!is_numeric($month)) || |
|
286 | - (!is_numeric($day))) { |
|
277 | + $year = PHPExcel_Calculation_Functions::flattenSingleValue($year); |
|
278 | + $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); |
|
279 | + $day = PHPExcel_Calculation_Functions::flattenSingleValue($day); |
|
280 | + |
|
281 | + $year = ($year !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0; |
|
282 | + $month = ($month !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0; |
|
283 | + $day = ($day !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0; |
|
284 | + if (( ! is_numeric($year)) || |
|
285 | + ( ! is_numeric($month)) || |
|
286 | + ( ! is_numeric($day))) { |
|
287 | 287 | return PHPExcel_Calculation_Functions::VALUE(); |
288 | 288 | } |
289 | - $year = (integer) $year; |
|
290 | - $month = (integer) $month; |
|
291 | - $day = (integer) $day; |
|
289 | + $year = (integer) $year; |
|
290 | + $month = (integer) $month; |
|
291 | + $day = (integer) $day; |
|
292 | 292 | |
293 | 293 | $baseYear = PHPExcel_Shared_Date::getExcelCalendar(); |
294 | 294 | // Validate parameters |
295 | - if ($year < ($baseYear-1900)) { |
|
295 | + if ($year < ($baseYear - 1900)) { |
|
296 | 296 | return PHPExcel_Calculation_Functions::NaN(); |
297 | 297 | } |
298 | - if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) { |
|
298 | + if ((($baseYear - 1900) != 0) && ($year < $baseYear) && ($year >= 1900)) { |
|
299 | 299 | return PHPExcel_Calculation_Functions::NaN(); |
300 | 300 | } |
301 | 301 | |
302 | - if (($year < $baseYear) && ($year >= ($baseYear-1900))) { |
|
302 | + if (($year < $baseYear) && ($year >= ($baseYear - 1900))) { |
|
303 | 303 | $year += 1900; |
304 | 304 | } |
305 | 305 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * depending on the value of the ReturnDateType flag |
361 | 361 | */ |
362 | 362 | public static function TIME($hour = 0, $minute = 0, $second = 0) { |
363 | - $hour = PHPExcel_Calculation_Functions::flattenSingleValue($hour); |
|
363 | + $hour = PHPExcel_Calculation_Functions::flattenSingleValue($hour); |
|
364 | 364 | $minute = PHPExcel_Calculation_Functions::flattenSingleValue($minute); |
365 | 365 | $second = PHPExcel_Calculation_Functions::flattenSingleValue($second); |
366 | 366 | |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | if ($minute == '') { $minute = 0; } |
369 | 369 | if ($second == '') { $second = 0; } |
370 | 370 | |
371 | - if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) { |
|
371 | + if (( ! is_numeric($hour)) || ( ! is_numeric($minute)) || ( ! is_numeric($second))) { |
|
372 | 372 | return PHPExcel_Calculation_Functions::VALUE(); |
373 | 373 | } |
374 | - $hour = (integer) $hour; |
|
374 | + $hour = (integer) $hour; |
|
375 | 375 | $minute = (integer) $minute; |
376 | 376 | $second = (integer) $second; |
377 | 377 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | } |
409 | 409 | return (float) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); |
410 | 410 | case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : |
411 | - return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 |
|
411 | + return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 |
|
412 | 412 | case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : |
413 | 413 | $dayAdjust = 0; |
414 | 414 | if ($hour < 0) { |
@@ -455,15 +455,15 @@ discard block |
||
455 | 455 | * depending on the value of the ReturnDateType flag |
456 | 456 | */ |
457 | 457 | public static function DATEVALUE($dateValue = 1) { |
458 | - $dateValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($dateValue),'"'); |
|
458 | + $dateValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($dateValue), '"'); |
|
459 | 459 | // Strip any ordinals because they're allowed in Excel (English only) |
460 | - $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui','$1$3',$dateValue); |
|
460 | + $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue); |
|
461 | 461 | // Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany) |
462 | - $dateValue = str_replace(array('/','.','-',' '),array(' ',' ',' ',' '),$dateValue); |
|
462 | + $dateValue = str_replace(array('/', '.', '-', ' '), array(' ', ' ', ' ', ' '), $dateValue); |
|
463 | 463 | |
464 | 464 | $yearFound = false; |
465 | - $t1 = explode(' ',$dateValue); |
|
466 | - foreach($t1 as &$t) { |
|
465 | + $t1 = explode(' ', $dateValue); |
|
466 | + foreach ($t1 as &$t) { |
|
467 | 467 | if ((is_numeric($t)) && ($t > 31)) { |
468 | 468 | if ($yearFound) { |
469 | 469 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -473,23 +473,23 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | } |
476 | - if ((count($t1) == 1) && (strpos($t,':') != false)) { |
|
476 | + if ((count($t1) == 1) && (strpos($t, ':') != false)) { |
|
477 | 477 | // We've been fed a time value without any date |
478 | 478 | return 0.0; |
479 | 479 | } elseif (count($t1) == 2) { |
480 | 480 | // We only have two parts of the date: either day/month or month/year |
481 | 481 | if ($yearFound) { |
482 | - array_unshift($t1,1); |
|
482 | + array_unshift($t1, 1); |
|
483 | 483 | } else { |
484 | - array_push($t1,date('Y')); |
|
484 | + array_push($t1, date('Y')); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | unset($t); |
488 | - $dateValue = implode(' ',$t1); |
|
488 | + $dateValue = implode(' ', $t1); |
|
489 | 489 | |
490 | 490 | $PHPDateArray = date_parse($dateValue); |
491 | 491 | if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) { |
492 | - $testVal1 = strtok($dateValue,'- '); |
|
492 | + $testVal1 = strtok($dateValue, '- '); |
|
493 | 493 | if ($testVal1 !== False) { |
494 | 494 | $testVal2 = strtok('- '); |
495 | 495 | if ($testVal2 !== False) { |
@@ -514,12 +514,12 @@ discard block |
||
514 | 514 | |
515 | 515 | if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) { |
516 | 516 | // Execute function |
517 | - if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); } |
|
517 | + if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); } |
|
518 | 518 | if ($PHPDateArray['year'] < 1900) |
519 | 519 | return PHPExcel_Calculation_Functions::VALUE(); |
520 | - if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); } |
|
521 | - if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); } |
|
522 | - $excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second'])); |
|
520 | + if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); } |
|
521 | + if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); } |
|
522 | + $excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'], $PHPDateArray['month'], $PHPDateArray['day'], $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second'])); |
|
523 | 523 | |
524 | 524 | switch (PHPExcel_Calculation_Functions::getReturnDateType()) { |
525 | 525 | case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : |
@@ -557,22 +557,22 @@ discard block |
||
557 | 557 | * depending on the value of the ReturnDateType flag |
558 | 558 | */ |
559 | 559 | public static function TIMEVALUE($timeValue) { |
560 | - $timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue),'"'); |
|
561 | - $timeValue = str_replace(array('/','.'),array('-','-'),$timeValue); |
|
560 | + $timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue), '"'); |
|
561 | + $timeValue = str_replace(array('/', '.'), array('-', '-'), $timeValue); |
|
562 | 562 | |
563 | 563 | $PHPDateArray = date_parse($timeValue); |
564 | 564 | if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) { |
565 | 565 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
566 | - $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']); |
|
566 | + $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'], $PHPDateArray['month'], $PHPDateArray['day'], $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']); |
|
567 | 567 | } else { |
568 | - $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900,1,1,$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']) - 1; |
|
568 | + $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1; |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | switch (PHPExcel_Calculation_Functions::getReturnDateType()) { |
572 | 572 | case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : |
573 | 573 | return (float) $excelDateValue; |
574 | 574 | case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC : |
575 | - return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;; |
|
575 | + return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue + 25569) - 3600; ; |
|
576 | 576 | case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT : |
577 | 577 | return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']); |
578 | 578 | } |
@@ -592,9 +592,9 @@ discard block |
||
592 | 592 | * @return integer Interval between the dates |
593 | 593 | */ |
594 | 594 | public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') { |
595 | - $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
596 | - $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
|
597 | - $unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit)); |
|
595 | + $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
596 | + $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
|
597 | + $unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit)); |
|
598 | 598 | |
599 | 599 | if (is_string($startDate = self::_getDateValue($startDate))) { |
600 | 600 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | * @return integer Number of days between start date and end date |
711 | 711 | */ |
712 | 712 | public static function DAYS360($startDate = 0, $endDate = 0, $method = false) { |
713 | - $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
714 | - $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
|
713 | + $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
714 | + $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
|
715 | 715 | |
716 | 716 | if (is_string($startDate = self::_getDateValue($startDate))) { |
717 | 717 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $endMonth = $PHPEndDateObject->format('n'); |
732 | 732 | $endYear = $PHPEndDateObject->format('Y'); |
733 | 733 | |
734 | - return self::_dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method); |
|
734 | + return self::_dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, ! $method); |
|
735 | 735 | } // function DAYS360() |
736 | 736 | |
737 | 737 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | * @return float fraction of the year |
762 | 762 | */ |
763 | 763 | public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) { |
764 | - $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
764 | + $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
765 | 765 | $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
766 | 766 | $method = PHPExcel_Calculation_Functions::flattenSingleValue($method); |
767 | 767 | |
@@ -772,12 +772,12 @@ discard block |
||
772 | 772 | return PHPExcel_Calculation_Functions::VALUE(); |
773 | 773 | } |
774 | 774 | |
775 | - if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) { |
|
776 | - switch($method) { |
|
775 | + if (((is_numeric($method)) && ( ! is_string($method))) || ($method == '')) { |
|
776 | + switch ($method) { |
|
777 | 777 | case 0 : |
778 | - return self::DAYS360($startDate,$endDate) / 360; |
|
778 | + return self::DAYS360($startDate, $endDate) / 360; |
|
779 | 779 | case 1 : |
780 | - $days = self::DATEDIF($startDate,$endDate); |
|
780 | + $days = self::DATEDIF($startDate, $endDate); |
|
781 | 781 | $startYear = self::YEAR($startDate); |
782 | 782 | $endYear = self::YEAR($endDate); |
783 | 783 | $years = $endYear - $startYear + 1; |
@@ -793,14 +793,14 @@ discard block |
||
793 | 793 | } |
794 | 794 | } |
795 | 795 | } else { |
796 | - for($year = $startYear; $year <= $endYear; ++$year) { |
|
796 | + for ($year = $startYear; $year <= $endYear; ++$year) { |
|
797 | 797 | if ($year == $startYear) { |
798 | 798 | $startMonth = self::MONTHOFYEAR($startDate); |
799 | 799 | $startDay = self::DAYOFMONTH($startDate); |
800 | 800 | if ($startMonth < 3) { |
801 | 801 | $leapDays += (self::_isLeapYear($year)) ? 1 : 0; |
802 | 802 | } |
803 | - } elseif($year == $endYear) { |
|
803 | + } elseif ($year == $endYear) { |
|
804 | 804 | $endMonth = self::MONTHOFYEAR($endDate); |
805 | 805 | $endDay = self::DAYOFMONTH($endDate); |
806 | 806 | if (($endMonth * 100 + $endDay) >= (2 * 100 + 29)) { |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | } |
822 | 822 | return $days / (365 + $leapDays); |
823 | 823 | case 2 : |
824 | - return self::DATEDIF($startDate,$endDate) / 360; |
|
824 | + return self::DATEDIF($startDate, $endDate) / 360; |
|
825 | 825 | case 3 : |
826 | - return self::DATEDIF($startDate,$endDate) / 365; |
|
826 | + return self::DATEDIF($startDate, $endDate) / 365; |
|
827 | 827 | case 4 : |
828 | - return self::DAYS360($startDate,$endDate,True) / 360; |
|
828 | + return self::DAYS360($startDate, $endDate, True) / 360; |
|
829 | 829 | } |
830 | 830 | } |
831 | 831 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -855,10 +855,10 @@ discard block |
||
855 | 855 | * as state and federal holidays and floating holidays. |
856 | 856 | * @return integer Interval between the dates |
857 | 857 | */ |
858 | - public static function NETWORKDAYS($startDate,$endDate) { |
|
858 | + public static function NETWORKDAYS($startDate, $endDate) { |
|
859 | 859 | // Retrieve the mandatory start and end date that are referenced in the function definition |
860 | - $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
861 | - $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
|
860 | + $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
861 | + $endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate); |
|
862 | 862 | // Flush the mandatory start and end date that are referenced in the function definition, and get the optional days |
863 | 863 | $dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
864 | 864 | array_shift($dateArgs); |
@@ -880,9 +880,9 @@ discard block |
||
880 | 880 | } |
881 | 881 | |
882 | 882 | // Execute function |
883 | - $startDoW = 6 - self::DAYOFWEEK($startDate,2); |
|
883 | + $startDoW = 6 - self::DAYOFWEEK($startDate, 2); |
|
884 | 884 | if ($startDoW < 0) { $startDoW = 0; } |
885 | - $endDoW = self::DAYOFWEEK($endDate,2); |
|
885 | + $endDoW = self::DAYOFWEEK($endDate, 2); |
|
886 | 886 | if ($endDoW >= 6) { $endDoW = 0; } |
887 | 887 | |
888 | 888 | $wholeWeekDays = floor(($endDate - $startDate) / 7) * 5; |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | return PHPExcel_Calculation_Functions::VALUE(); |
899 | 899 | } |
900 | 900 | if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) { |
901 | - if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) { |
|
901 | + if ((self::DAYOFWEEK($holidayDate, 2) < 6) && ( ! in_array($holidayDate, $holidayCountedArray))) { |
|
902 | 902 | --$partWeekDays; |
903 | 903 | $holidayCountedArray[] = $holidayDate; |
904 | 904 | } |
@@ -937,16 +937,16 @@ discard block |
||
937 | 937 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
938 | 938 | * depending on the value of the ReturnDateType flag |
939 | 939 | */ |
940 | - public static function WORKDAY($startDate,$endDays) { |
|
940 | + public static function WORKDAY($startDate, $endDays) { |
|
941 | 941 | // Retrieve the mandatory start date and days that are referenced in the function definition |
942 | - $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
943 | - $endDays = PHPExcel_Calculation_Functions::flattenSingleValue($endDays); |
|
942 | + $startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate); |
|
943 | + $endDays = PHPExcel_Calculation_Functions::flattenSingleValue($endDays); |
|
944 | 944 | // Flush the mandatory start date and days that are referenced in the function definition, and get the optional days |
945 | 945 | $dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
946 | 946 | array_shift($dateArgs); |
947 | 947 | array_shift($dateArgs); |
948 | 948 | |
949 | - if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) { |
|
949 | + if ((is_string($startDate = self::_getDateValue($startDate))) || ( ! is_numeric($endDays))) { |
|
950 | 950 | return PHPExcel_Calculation_Functions::VALUE(); |
951 | 951 | } |
952 | 952 | $startDate = (float) floor($startDate); |
@@ -958,9 +958,9 @@ discard block |
||
958 | 958 | |
959 | 959 | // Adjust the start date if it falls over a weekend |
960 | 960 | |
961 | - $startDoW = self::DAYOFWEEK($startDate,3); |
|
962 | - if (self::DAYOFWEEK($startDate,3) >= 5) { |
|
963 | - $startDate += ($decrementing) ? -$startDoW + 4: 7 - $startDoW; |
|
961 | + $startDoW = self::DAYOFWEEK($startDate, 3); |
|
962 | + if (self::DAYOFWEEK($startDate, 3) >= 5) { |
|
963 | + $startDate += ($decrementing) ? -$startDoW + 4 : 7 - $startDoW; |
|
964 | 964 | ($decrementing) ? $endDays++ : $endDays--; |
965 | 965 | } |
966 | 966 | |
@@ -968,20 +968,20 @@ discard block |
||
968 | 968 | $endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5); |
969 | 969 | |
970 | 970 | // Adjust the calculated end date if it falls over a weekend |
971 | - $endDoW = self::DAYOFWEEK($endDate,3); |
|
971 | + $endDoW = self::DAYOFWEEK($endDate, 3); |
|
972 | 972 | if ($endDoW >= 5) { |
973 | - $endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW; |
|
973 | + $endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW; |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | // Test any extra holiday parameters |
977 | - if (!empty($dateArgs)) { |
|
977 | + if ( ! empty($dateArgs)) { |
|
978 | 978 | $holidayCountedArray = $holidayDates = array(); |
979 | 979 | foreach ($dateArgs as $holidayDate) { |
980 | 980 | if (($holidayDate !== NULL) && (trim($holidayDate) > '')) { |
981 | 981 | if (is_string($holidayDate = self::_getDateValue($holidayDate))) { |
982 | 982 | return PHPExcel_Calculation_Functions::VALUE(); |
983 | 983 | } |
984 | - if (self::DAYOFWEEK($holidayDate,3) < 5) { |
|
984 | + if (self::DAYOFWEEK($holidayDate, 3) < 5) { |
|
985 | 985 | $holidayDates[] = $holidayDate; |
986 | 986 | } |
987 | 987 | } |
@@ -994,23 +994,23 @@ discard block |
||
994 | 994 | foreach ($holidayDates as $holidayDate) { |
995 | 995 | if ($decrementing) { |
996 | 996 | if (($holidayDate <= $startDate) && ($holidayDate >= $endDate)) { |
997 | - if (!in_array($holidayDate,$holidayCountedArray)) { |
|
997 | + if ( ! in_array($holidayDate, $holidayCountedArray)) { |
|
998 | 998 | --$endDate; |
999 | 999 | $holidayCountedArray[] = $holidayDate; |
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | } else { |
1003 | 1003 | if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) { |
1004 | - if (!in_array($holidayDate,$holidayCountedArray)) { |
|
1004 | + if ( ! in_array($holidayDate, $holidayCountedArray)) { |
|
1005 | 1005 | ++$endDate; |
1006 | 1006 | $holidayCountedArray[] = $holidayDate; |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | // Adjust the calculated end date if it falls over a weekend |
1011 | - $endDoW = self::DAYOFWEEK($endDate,3); |
|
1011 | + $endDoW = self::DAYOFWEEK($endDate, 3); |
|
1012 | 1012 | if ($endDoW >= 5) { |
1013 | - $endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW; |
|
1013 | + $endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW; |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | } |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | * @return int Day of the month |
1042 | 1042 | */ |
1043 | 1043 | public static function DAYOFMONTH($dateValue = 1) { |
1044 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1044 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1045 | 1045 | |
1046 | 1046 | if (is_string($dateValue = self::_getDateValue($dateValue))) { |
1047 | 1047 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -1076,10 +1076,10 @@ discard block |
||
1076 | 1076 | * @return int Day of the week value |
1077 | 1077 | */ |
1078 | 1078 | public static function DAYOFWEEK($dateValue = 1, $style = 1) { |
1079 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1080 | - $style = PHPExcel_Calculation_Functions::flattenSingleValue($style); |
|
1079 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1080 | + $style = PHPExcel_Calculation_Functions::flattenSingleValue($style); |
|
1081 | 1081 | |
1082 | - if (!is_numeric($style)) { |
|
1082 | + if ( ! is_numeric($style)) { |
|
1083 | 1083 | return PHPExcel_Calculation_Functions::VALUE(); |
1084 | 1084 | } elseif (($style < 1) || ($style > 3)) { |
1085 | 1085 | return PHPExcel_Calculation_Functions::NaN(); |
@@ -1142,10 +1142,10 @@ discard block |
||
1142 | 1142 | * @return int Week Number |
1143 | 1143 | */ |
1144 | 1144 | public static function WEEKOFYEAR($dateValue = 1, $method = 1) { |
1145 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1146 | - $method = PHPExcel_Calculation_Functions::flattenSingleValue($method); |
|
1145 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1146 | + $method = PHPExcel_Calculation_Functions::flattenSingleValue($method); |
|
1147 | 1147 | |
1148 | - if (!is_numeric($method)) { |
|
1148 | + if ( ! is_numeric($method)) { |
|
1149 | 1149 | return PHPExcel_Calculation_Functions::VALUE(); |
1150 | 1150 | } elseif (($method < 1) || ($method > 2)) { |
1151 | 1151 | return PHPExcel_Calculation_Functions::NaN(); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | * @return int Month of the year |
1187 | 1187 | */ |
1188 | 1188 | public static function MONTHOFYEAR($dateValue = 1) { |
1189 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1189 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1190 | 1190 | |
1191 | 1191 | if (is_string($dateValue = self::_getDateValue($dateValue))) { |
1192 | 1192 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | * @return int Year |
1216 | 1216 | */ |
1217 | 1217 | public static function YEAR($dateValue = 1) { |
1218 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1218 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1219 | 1219 | |
1220 | 1220 | if (is_string($dateValue = self::_getDateValue($dateValue))) { |
1221 | 1221 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -1244,11 +1244,11 @@ discard block |
||
1244 | 1244 | * @return int Hour |
1245 | 1245 | */ |
1246 | 1246 | public static function HOUROFDAY($timeValue = 0) { |
1247 | - $timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); |
|
1247 | + $timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); |
|
1248 | 1248 | |
1249 | - if (!is_numeric($timeValue)) { |
|
1249 | + if ( ! is_numeric($timeValue)) { |
|
1250 | 1250 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
1251 | - $testVal = strtok($timeValue,'/-: '); |
|
1251 | + $testVal = strtok($timeValue, '/-: '); |
|
1252 | 1252 | if (strlen($testVal) < strlen($timeValue)) { |
1253 | 1253 | return PHPExcel_Calculation_Functions::VALUE(); |
1254 | 1254 | } |
@@ -1260,13 +1260,13 @@ discard block |
||
1260 | 1260 | } |
1261 | 1261 | // Execute function |
1262 | 1262 | if ($timeValue >= 1) { |
1263 | - $timeValue = fmod($timeValue,1); |
|
1263 | + $timeValue = fmod($timeValue, 1); |
|
1264 | 1264 | } elseif ($timeValue < 0.0) { |
1265 | 1265 | return PHPExcel_Calculation_Functions::NaN(); |
1266 | 1266 | } |
1267 | 1267 | $timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue); |
1268 | 1268 | |
1269 | - return (int) gmdate('G',$timeValue); |
|
1269 | + return (int) gmdate('G', $timeValue); |
|
1270 | 1270 | } // function HOUROFDAY() |
1271 | 1271 | |
1272 | 1272 | |
@@ -1284,11 +1284,11 @@ discard block |
||
1284 | 1284 | * @return int Minute |
1285 | 1285 | */ |
1286 | 1286 | public static function MINUTEOFHOUR($timeValue = 0) { |
1287 | - $timeValue = $timeTester = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); |
|
1287 | + $timeValue = $timeTester = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); |
|
1288 | 1288 | |
1289 | - if (!is_numeric($timeValue)) { |
|
1289 | + if ( ! is_numeric($timeValue)) { |
|
1290 | 1290 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
1291 | - $testVal = strtok($timeValue,'/-: '); |
|
1291 | + $testVal = strtok($timeValue, '/-: '); |
|
1292 | 1292 | if (strlen($testVal) < strlen($timeValue)) { |
1293 | 1293 | return PHPExcel_Calculation_Functions::VALUE(); |
1294 | 1294 | } |
@@ -1300,13 +1300,13 @@ discard block |
||
1300 | 1300 | } |
1301 | 1301 | // Execute function |
1302 | 1302 | if ($timeValue >= 1) { |
1303 | - $timeValue = fmod($timeValue,1); |
|
1303 | + $timeValue = fmod($timeValue, 1); |
|
1304 | 1304 | } elseif ($timeValue < 0.0) { |
1305 | 1305 | return PHPExcel_Calculation_Functions::NaN(); |
1306 | 1306 | } |
1307 | 1307 | $timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue); |
1308 | 1308 | |
1309 | - return (int) gmdate('i',$timeValue); |
|
1309 | + return (int) gmdate('i', $timeValue); |
|
1310 | 1310 | } // function MINUTEOFHOUR() |
1311 | 1311 | |
1312 | 1312 | |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | * @return int Second |
1325 | 1325 | */ |
1326 | 1326 | public static function SECONDOFMINUTE($timeValue = 0) { |
1327 | - $timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); |
|
1327 | + $timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue); |
|
1328 | 1328 | |
1329 | - if (!is_numeric($timeValue)) { |
|
1329 | + if ( ! is_numeric($timeValue)) { |
|
1330 | 1330 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
1331 | - $testVal = strtok($timeValue,'/-: '); |
|
1331 | + $testVal = strtok($timeValue, '/-: '); |
|
1332 | 1332 | if (strlen($testVal) < strlen($timeValue)) { |
1333 | 1333 | return PHPExcel_Calculation_Functions::VALUE(); |
1334 | 1334 | } |
@@ -1340,13 +1340,13 @@ discard block |
||
1340 | 1340 | } |
1341 | 1341 | // Execute function |
1342 | 1342 | if ($timeValue >= 1) { |
1343 | - $timeValue = fmod($timeValue,1); |
|
1343 | + $timeValue = fmod($timeValue, 1); |
|
1344 | 1344 | } elseif ($timeValue < 0.0) { |
1345 | 1345 | return PHPExcel_Calculation_Functions::NaN(); |
1346 | 1346 | } |
1347 | 1347 | $timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue); |
1348 | 1348 | |
1349 | - return (int) gmdate('s',$timeValue); |
|
1349 | + return (int) gmdate('s', $timeValue); |
|
1350 | 1350 | } // function SECONDOFMINUTE() |
1351 | 1351 | |
1352 | 1352 | |
@@ -1370,10 +1370,10 @@ discard block |
||
1370 | 1370 | * depending on the value of the ReturnDateType flag |
1371 | 1371 | */ |
1372 | 1372 | public static function EDATE($dateValue = 1, $adjustmentMonths = 0) { |
1373 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1374 | - $adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths); |
|
1373 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1374 | + $adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths); |
|
1375 | 1375 | |
1376 | - if (!is_numeric($adjustmentMonths)) { |
|
1376 | + if ( ! is_numeric($adjustmentMonths)) { |
|
1377 | 1377 | return PHPExcel_Calculation_Functions::VALUE(); |
1378 | 1378 | } |
1379 | 1379 | $adjustmentMonths = floor($adjustmentMonths); |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | // Execute function |
1386 | - $PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths); |
|
1386 | + $PHPDateObject = self::_adjustDateByMonths($dateValue, $adjustmentMonths); |
|
1387 | 1387 | |
1388 | 1388 | switch (PHPExcel_Calculation_Functions::getReturnDateType()) { |
1389 | 1389 | case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL : |
@@ -1415,10 +1415,10 @@ discard block |
||
1415 | 1415 | * depending on the value of the ReturnDateType flag |
1416 | 1416 | */ |
1417 | 1417 | public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) { |
1418 | - $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1419 | - $adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths); |
|
1418 | + $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); |
|
1419 | + $adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths); |
|
1420 | 1420 | |
1421 | - if (!is_numeric($adjustmentMonths)) { |
|
1421 | + if ( ! is_numeric($adjustmentMonths)) { |
|
1422 | 1422 | return PHPExcel_Calculation_Functions::VALUE(); |
1423 | 1423 | } |
1424 | 1424 | $adjustmentMonths = floor($adjustmentMonths); |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | // Execute function |
1431 | - $PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths+1); |
|
1431 | + $PHPDateObject = self::_adjustDateByMonths($dateValue, $adjustmentMonths + 1); |
|
1432 | 1432 | $adjustDays = (int) $PHPDateObject->format('d'); |
1433 | 1433 | $adjustDaysString = '-'.$adjustDays.' days'; |
1434 | 1434 | $PHPDateObject->modify($adjustDaysString); |
@@ -515,8 +515,9 @@ discard block |
||
515 | 515 | if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) { |
516 | 516 | // Execute function |
517 | 517 | if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); } |
518 | - if ($PHPDateArray['year'] < 1900) |
|
519 | - return PHPExcel_Calculation_Functions::VALUE(); |
|
518 | + if ($PHPDateArray['year'] < 1900) { |
|
519 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
520 | + } |
|
520 | 521 | if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); } |
521 | 522 | if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); } |
522 | 523 | $excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second'])); |
@@ -656,7 +657,9 @@ discard block |
||
656 | 657 | break; |
657 | 658 | case 'YM': |
658 | 659 | $retVal = intval($endMonths - $startMonths); |
659 | - if ($retVal < 0) $retVal = 12 + $retVal; |
|
660 | + if ($retVal < 0) { |
|
661 | + $retVal = 12 + $retVal; |
|
662 | + } |
|
660 | 663 | // We're only interested in full months |
661 | 664 | if ($endDays < $startDays) { |
662 | 665 | --$retVal; |
@@ -757,6 +757,9 @@ discard block |
||
757 | 757 | } |
758 | 758 | |
759 | 759 | |
760 | + /** |
|
761 | + * @param string $xVal |
|
762 | + */ |
|
760 | 763 | private static function _nbrConversionFormat($xVal,$places) { |
761 | 764 | if (!is_null($places)) { |
762 | 765 | if (strlen($xVal) <= $places) { |
@@ -1716,7 +1719,7 @@ discard block |
||
1716 | 1719 | * @access public |
1717 | 1720 | * @category Engineering Functions |
1718 | 1721 | * @param string $complexNumber The complex number for which you want the real coefficient. |
1719 | - * @return float |
|
1722 | + * @return string |
|
1720 | 1723 | */ |
1721 | 1724 | public static function IMREAL($complexNumber) { |
1722 | 1725 | $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); |
@@ -2121,7 +2124,6 @@ discard block |
||
2121 | 2124 | * Excel Function: |
2122 | 2125 | * IMSUM(complexNumber[,complexNumber[,...]]) |
2123 | 2126 | * |
2124 | - * @param string $complexNumber,... Series of complex numbers to add |
|
2125 | 2127 | * @return string |
2126 | 2128 | */ |
2127 | 2129 | public static function IMSUM() { |
@@ -2157,7 +2159,6 @@ discard block |
||
2157 | 2159 | * Excel Function: |
2158 | 2160 | * IMPRODUCT(complexNumber[,complexNumber[,...]]) |
2159 | 2161 | * |
2160 | - * @param string $complexNumber,... Series of complex numbers to multiply |
|
2161 | 2162 | * @return string |
2162 | 2163 | */ |
2163 | 2164 | public static function IMPRODUCT() { |
@@ -2197,7 +2198,7 @@ discard block |
||
2197 | 2198 | * DELTA(a[,b]) |
2198 | 2199 | * |
2199 | 2200 | * @param float $a The first number. |
2200 | - * @param float $b The second number. If omitted, b is assumed to be zero. |
|
2201 | + * @param integer $b The second number. If omitted, b is assumed to be zero. |
|
2201 | 2202 | * @return int |
2202 | 2203 | */ |
2203 | 2204 | public static function DELTA($a, $b=0) { |
@@ -2219,7 +2220,7 @@ discard block |
||
2219 | 2220 | * functions you calculate the count of values that exceed a threshold. |
2220 | 2221 | * |
2221 | 2222 | * @param float $number The value to test against step. |
2222 | - * @param float $step The threshold value. |
|
2223 | + * @param integer $step The threshold value. |
|
2223 | 2224 | * If you omit a value for step, GESTEP uses zero. |
2224 | 2225 | * @return int |
2225 | 2226 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -54,69 +54,69 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var mixed[] |
56 | 56 | */ |
57 | - private static $_conversionUnits = array( 'g' => array( 'Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True ), |
|
58 | - 'sg' => array( 'Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False ), |
|
59 | - 'lbm' => array( 'Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False ), |
|
60 | - 'u' => array( 'Group' => 'Mass', 'Unit Name' => 'U (atomic mass unit)', 'AllowPrefix' => True ), |
|
61 | - 'ozm' => array( 'Group' => 'Mass', 'Unit Name' => 'Ounce mass (avoirdupois)', 'AllowPrefix' => False ), |
|
62 | - 'm' => array( 'Group' => 'Distance', 'Unit Name' => 'Meter', 'AllowPrefix' => True ), |
|
63 | - 'mi' => array( 'Group' => 'Distance', 'Unit Name' => 'Statute mile', 'AllowPrefix' => False ), |
|
64 | - 'Nmi' => array( 'Group' => 'Distance', 'Unit Name' => 'Nautical mile', 'AllowPrefix' => False ), |
|
65 | - 'in' => array( 'Group' => 'Distance', 'Unit Name' => 'Inch', 'AllowPrefix' => False ), |
|
66 | - 'ft' => array( 'Group' => 'Distance', 'Unit Name' => 'Foot', 'AllowPrefix' => False ), |
|
67 | - 'yd' => array( 'Group' => 'Distance', 'Unit Name' => 'Yard', 'AllowPrefix' => False ), |
|
68 | - 'ang' => array( 'Group' => 'Distance', 'Unit Name' => 'Angstrom', 'AllowPrefix' => True ), |
|
69 | - 'Pica' => array( 'Group' => 'Distance', 'Unit Name' => 'Pica (1/72 in)', 'AllowPrefix' => False ), |
|
70 | - 'yr' => array( 'Group' => 'Time', 'Unit Name' => 'Year', 'AllowPrefix' => False ), |
|
71 | - 'day' => array( 'Group' => 'Time', 'Unit Name' => 'Day', 'AllowPrefix' => False ), |
|
72 | - 'hr' => array( 'Group' => 'Time', 'Unit Name' => 'Hour', 'AllowPrefix' => False ), |
|
73 | - 'mn' => array( 'Group' => 'Time', 'Unit Name' => 'Minute', 'AllowPrefix' => False ), |
|
74 | - 'sec' => array( 'Group' => 'Time', 'Unit Name' => 'Second', 'AllowPrefix' => True ), |
|
75 | - 'Pa' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ), |
|
76 | - 'p' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ), |
|
77 | - 'atm' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ), |
|
78 | - 'at' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ), |
|
79 | - 'mmHg' => array( 'Group' => 'Pressure', 'Unit Name' => 'mm of Mercury', 'AllowPrefix' => True ), |
|
80 | - 'N' => array( 'Group' => 'Force', 'Unit Name' => 'Newton', 'AllowPrefix' => True ), |
|
81 | - 'dyn' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ), |
|
82 | - 'dy' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ), |
|
83 | - 'lbf' => array( 'Group' => 'Force', 'Unit Name' => 'Pound force', 'AllowPrefix' => False ), |
|
84 | - 'J' => array( 'Group' => 'Energy', 'Unit Name' => 'Joule', 'AllowPrefix' => True ), |
|
85 | - 'e' => array( 'Group' => 'Energy', 'Unit Name' => 'Erg', 'AllowPrefix' => True ), |
|
86 | - 'c' => array( 'Group' => 'Energy', 'Unit Name' => 'Thermodynamic calorie', 'AllowPrefix' => True ), |
|
87 | - 'cal' => array( 'Group' => 'Energy', 'Unit Name' => 'IT calorie', 'AllowPrefix' => True ), |
|
88 | - 'eV' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ), |
|
89 | - 'ev' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ), |
|
90 | - 'HPh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ), |
|
91 | - 'hh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ), |
|
92 | - 'Wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ), |
|
93 | - 'wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ), |
|
94 | - 'flb' => array( 'Group' => 'Energy', 'Unit Name' => 'Foot-pound', 'AllowPrefix' => False ), |
|
95 | - 'BTU' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ), |
|
96 | - 'btu' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ), |
|
97 | - 'HP' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ), |
|
98 | - 'h' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ), |
|
99 | - 'W' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ), |
|
100 | - 'w' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ), |
|
101 | - 'T' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Tesla', 'AllowPrefix' => True ), |
|
102 | - 'ga' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Gauss', 'AllowPrefix' => True ), |
|
103 | - 'C' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ), |
|
104 | - 'cel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ), |
|
105 | - 'F' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ), |
|
106 | - 'fah' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ), |
|
107 | - 'K' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ), |
|
108 | - 'kel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ), |
|
109 | - 'tsp' => array( 'Group' => 'Liquid', 'Unit Name' => 'Teaspoon', 'AllowPrefix' => False ), |
|
110 | - 'tbs' => array( 'Group' => 'Liquid', 'Unit Name' => 'Tablespoon', 'AllowPrefix' => False ), |
|
111 | - 'oz' => array( 'Group' => 'Liquid', 'Unit Name' => 'Fluid Ounce', 'AllowPrefix' => False ), |
|
112 | - 'cup' => array( 'Group' => 'Liquid', 'Unit Name' => 'Cup', 'AllowPrefix' => False ), |
|
113 | - 'pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ), |
|
114 | - 'us_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ), |
|
115 | - 'uk_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.K. Pint', 'AllowPrefix' => False ), |
|
116 | - 'qt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Quart', 'AllowPrefix' => False ), |
|
117 | - 'gal' => array( 'Group' => 'Liquid', 'Unit Name' => 'Gallon', 'AllowPrefix' => False ), |
|
118 | - 'l' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True ), |
|
119 | - 'lt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True ) |
|
57 | + private static $_conversionUnits = array('g' => array('Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True), |
|
58 | + 'sg' => array('Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False), |
|
59 | + 'lbm' => array('Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False), |
|
60 | + 'u' => array('Group' => 'Mass', 'Unit Name' => 'U (atomic mass unit)', 'AllowPrefix' => True), |
|
61 | + 'ozm' => array('Group' => 'Mass', 'Unit Name' => 'Ounce mass (avoirdupois)', 'AllowPrefix' => False), |
|
62 | + 'm' => array('Group' => 'Distance', 'Unit Name' => 'Meter', 'AllowPrefix' => True), |
|
63 | + 'mi' => array('Group' => 'Distance', 'Unit Name' => 'Statute mile', 'AllowPrefix' => False), |
|
64 | + 'Nmi' => array('Group' => 'Distance', 'Unit Name' => 'Nautical mile', 'AllowPrefix' => False), |
|
65 | + 'in' => array('Group' => 'Distance', 'Unit Name' => 'Inch', 'AllowPrefix' => False), |
|
66 | + 'ft' => array('Group' => 'Distance', 'Unit Name' => 'Foot', 'AllowPrefix' => False), |
|
67 | + 'yd' => array('Group' => 'Distance', 'Unit Name' => 'Yard', 'AllowPrefix' => False), |
|
68 | + 'ang' => array('Group' => 'Distance', 'Unit Name' => 'Angstrom', 'AllowPrefix' => True), |
|
69 | + 'Pica' => array('Group' => 'Distance', 'Unit Name' => 'Pica (1/72 in)', 'AllowPrefix' => False), |
|
70 | + 'yr' => array('Group' => 'Time', 'Unit Name' => 'Year', 'AllowPrefix' => False), |
|
71 | + 'day' => array('Group' => 'Time', 'Unit Name' => 'Day', 'AllowPrefix' => False), |
|
72 | + 'hr' => array('Group' => 'Time', 'Unit Name' => 'Hour', 'AllowPrefix' => False), |
|
73 | + 'mn' => array('Group' => 'Time', 'Unit Name' => 'Minute', 'AllowPrefix' => False), |
|
74 | + 'sec' => array('Group' => 'Time', 'Unit Name' => 'Second', 'AllowPrefix' => True), |
|
75 | + 'Pa' => array('Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True), |
|
76 | + 'p' => array('Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True), |
|
77 | + 'atm' => array('Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True), |
|
78 | + 'at' => array('Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True), |
|
79 | + 'mmHg' => array('Group' => 'Pressure', 'Unit Name' => 'mm of Mercury', 'AllowPrefix' => True), |
|
80 | + 'N' => array('Group' => 'Force', 'Unit Name' => 'Newton', 'AllowPrefix' => True), |
|
81 | + 'dyn' => array('Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True), |
|
82 | + 'dy' => array('Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True), |
|
83 | + 'lbf' => array('Group' => 'Force', 'Unit Name' => 'Pound force', 'AllowPrefix' => False), |
|
84 | + 'J' => array('Group' => 'Energy', 'Unit Name' => 'Joule', 'AllowPrefix' => True), |
|
85 | + 'e' => array('Group' => 'Energy', 'Unit Name' => 'Erg', 'AllowPrefix' => True), |
|
86 | + 'c' => array('Group' => 'Energy', 'Unit Name' => 'Thermodynamic calorie', 'AllowPrefix' => True), |
|
87 | + 'cal' => array('Group' => 'Energy', 'Unit Name' => 'IT calorie', 'AllowPrefix' => True), |
|
88 | + 'eV' => array('Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True), |
|
89 | + 'ev' => array('Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True), |
|
90 | + 'HPh' => array('Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False), |
|
91 | + 'hh' => array('Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False), |
|
92 | + 'Wh' => array('Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True), |
|
93 | + 'wh' => array('Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True), |
|
94 | + 'flb' => array('Group' => 'Energy', 'Unit Name' => 'Foot-pound', 'AllowPrefix' => False), |
|
95 | + 'BTU' => array('Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False), |
|
96 | + 'btu' => array('Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False), |
|
97 | + 'HP' => array('Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False), |
|
98 | + 'h' => array('Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False), |
|
99 | + 'W' => array('Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True), |
|
100 | + 'w' => array('Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True), |
|
101 | + 'T' => array('Group' => 'Magnetism', 'Unit Name' => 'Tesla', 'AllowPrefix' => True), |
|
102 | + 'ga' => array('Group' => 'Magnetism', 'Unit Name' => 'Gauss', 'AllowPrefix' => True), |
|
103 | + 'C' => array('Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False), |
|
104 | + 'cel' => array('Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False), |
|
105 | + 'F' => array('Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False), |
|
106 | + 'fah' => array('Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False), |
|
107 | + 'K' => array('Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False), |
|
108 | + 'kel' => array('Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False), |
|
109 | + 'tsp' => array('Group' => 'Liquid', 'Unit Name' => 'Teaspoon', 'AllowPrefix' => False), |
|
110 | + 'tbs' => array('Group' => 'Liquid', 'Unit Name' => 'Tablespoon', 'AllowPrefix' => False), |
|
111 | + 'oz' => array('Group' => 'Liquid', 'Unit Name' => 'Fluid Ounce', 'AllowPrefix' => False), |
|
112 | + 'cup' => array('Group' => 'Liquid', 'Unit Name' => 'Cup', 'AllowPrefix' => False), |
|
113 | + 'pt' => array('Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False), |
|
114 | + 'us_pt' => array('Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False), |
|
115 | + 'uk_pt' => array('Group' => 'Liquid', 'Unit Name' => 'U.K. Pint', 'AllowPrefix' => False), |
|
116 | + 'qt' => array('Group' => 'Liquid', 'Unit Name' => 'Quart', 'AllowPrefix' => False), |
|
117 | + 'gal' => array('Group' => 'Liquid', 'Unit Name' => 'Gallon', 'AllowPrefix' => False), |
|
118 | + 'l' => array('Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True), |
|
119 | + 'lt' => array('Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True) |
|
120 | 120 | ); |
121 | 121 | |
122 | 122 | /** |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @var mixed[] |
126 | 126 | */ |
127 | - private static $_conversionMultipliers = array( 'Y' => array( 'multiplier' => 1E24, 'name' => 'yotta' ), |
|
128 | - 'Z' => array( 'multiplier' => 1E21, 'name' => 'zetta' ), |
|
129 | - 'E' => array( 'multiplier' => 1E18, 'name' => 'exa' ), |
|
130 | - 'P' => array( 'multiplier' => 1E15, 'name' => 'peta' ), |
|
131 | - 'T' => array( 'multiplier' => 1E12, 'name' => 'tera' ), |
|
132 | - 'G' => array( 'multiplier' => 1E9, 'name' => 'giga' ), |
|
133 | - 'M' => array( 'multiplier' => 1E6, 'name' => 'mega' ), |
|
134 | - 'k' => array( 'multiplier' => 1E3, 'name' => 'kilo' ), |
|
135 | - 'h' => array( 'multiplier' => 1E2, 'name' => 'hecto' ), |
|
136 | - 'e' => array( 'multiplier' => 1E1, 'name' => 'deka' ), |
|
137 | - 'd' => array( 'multiplier' => 1E-1, 'name' => 'deci' ), |
|
138 | - 'c' => array( 'multiplier' => 1E-2, 'name' => 'centi' ), |
|
139 | - 'm' => array( 'multiplier' => 1E-3, 'name' => 'milli' ), |
|
140 | - 'u' => array( 'multiplier' => 1E-6, 'name' => 'micro' ), |
|
141 | - 'n' => array( 'multiplier' => 1E-9, 'name' => 'nano' ), |
|
142 | - 'p' => array( 'multiplier' => 1E-12, 'name' => 'pico' ), |
|
143 | - 'f' => array( 'multiplier' => 1E-15, 'name' => 'femto' ), |
|
144 | - 'a' => array( 'multiplier' => 1E-18, 'name' => 'atto' ), |
|
145 | - 'z' => array( 'multiplier' => 1E-21, 'name' => 'zepto' ), |
|
146 | - 'y' => array( 'multiplier' => 1E-24, 'name' => 'yocto' ) |
|
127 | + private static $_conversionMultipliers = array('Y' => array('multiplier' => 1E24, 'name' => 'yotta'), |
|
128 | + 'Z' => array('multiplier' => 1E21, 'name' => 'zetta'), |
|
129 | + 'E' => array('multiplier' => 1E18, 'name' => 'exa'), |
|
130 | + 'P' => array('multiplier' => 1E15, 'name' => 'peta'), |
|
131 | + 'T' => array('multiplier' => 1E12, 'name' => 'tera'), |
|
132 | + 'G' => array('multiplier' => 1E9, 'name' => 'giga'), |
|
133 | + 'M' => array('multiplier' => 1E6, 'name' => 'mega'), |
|
134 | + 'k' => array('multiplier' => 1E3, 'name' => 'kilo'), |
|
135 | + 'h' => array('multiplier' => 1E2, 'name' => 'hecto'), |
|
136 | + 'e' => array('multiplier' => 1E1, 'name' => 'deka'), |
|
137 | + 'd' => array('multiplier' => 1E-1, 'name' => 'deci'), |
|
138 | + 'c' => array('multiplier' => 1E-2, 'name' => 'centi'), |
|
139 | + 'm' => array('multiplier' => 1E-3, 'name' => 'milli'), |
|
140 | + 'u' => array('multiplier' => 1E-6, 'name' => 'micro'), |
|
141 | + 'n' => array('multiplier' => 1E-9, 'name' => 'nano'), |
|
142 | + 'p' => array('multiplier' => 1E-12, 'name' => 'pico'), |
|
143 | + 'f' => array('multiplier' => 1E-15, 'name' => 'femto'), |
|
144 | + 'a' => array('multiplier' => 1E-18, 'name' => 'atto'), |
|
145 | + 'z' => array('multiplier' => 1E-21, 'name' => 'zepto'), |
|
146 | + 'y' => array('multiplier' => 1E-24, 'name' => 'yocto') |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | /** |
@@ -151,38 +151,38 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @var mixed[] |
153 | 153 | */ |
154 | - private static $_unitConversions = array( 'Mass' => array( 'g' => array( 'g' => 1.0, |
|
154 | + private static $_unitConversions = array('Mass' => array('g' => array('g' => 1.0, |
|
155 | 155 | 'sg' => 6.85220500053478E-05, |
156 | 156 | 'lbm' => 2.20462291469134E-03, |
157 | 157 | 'u' => 6.02217000000000E+23, |
158 | 158 | 'ozm' => 3.52739718003627E-02 |
159 | 159 | ), |
160 | - 'sg' => array( 'g' => 1.45938424189287E+04, |
|
160 | + 'sg' => array('g' => 1.45938424189287E+04, |
|
161 | 161 | 'sg' => 1.0, |
162 | 162 | 'lbm' => 3.21739194101647E+01, |
163 | 163 | 'u' => 8.78866000000000E+27, |
164 | 164 | 'ozm' => 5.14782785944229E+02 |
165 | 165 | ), |
166 | - 'lbm' => array( 'g' => 4.5359230974881148E+02, |
|
166 | + 'lbm' => array('g' => 4.5359230974881148E+02, |
|
167 | 167 | 'sg' => 3.10810749306493E-02, |
168 | 168 | 'lbm' => 1.0, |
169 | 169 | 'u' => 2.73161000000000E+26, |
170 | 170 | 'ozm' => 1.60000023429410E+01 |
171 | 171 | ), |
172 | - 'u' => array( 'g' => 1.66053100460465E-24, |
|
172 | + 'u' => array('g' => 1.66053100460465E-24, |
|
173 | 173 | 'sg' => 1.13782988532950E-28, |
174 | 174 | 'lbm' => 3.66084470330684E-27, |
175 | 175 | 'u' => 1.0, |
176 | 176 | 'ozm' => 5.85735238300524E-26 |
177 | 177 | ), |
178 | - 'ozm' => array( 'g' => 2.83495152079732E+01, |
|
178 | + 'ozm' => array('g' => 2.83495152079732E+01, |
|
179 | 179 | 'sg' => 1.94256689870811E-03, |
180 | 180 | 'lbm' => 6.24999908478882E-02, |
181 | 181 | 'u' => 1.70725600000000E+25, |
182 | 182 | 'ozm' => 1.0 |
183 | 183 | ) |
184 | 184 | ), |
185 | - 'Distance' => array( 'm' => array( 'm' => 1.0, |
|
185 | + 'Distance' => array('m' => array('m' => 1.0, |
|
186 | 186 | 'mi' => 6.21371192237334E-04, |
187 | 187 | 'Nmi' => 5.39956803455724E-04, |
188 | 188 | 'in' => 3.93700787401575E+01, |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'ang' => 1.00000000000000E+10, |
192 | 192 | 'Pica' => 2.83464566929116E+03 |
193 | 193 | ), |
194 | - 'mi' => array( 'm' => 1.60934400000000E+03, |
|
194 | + 'mi' => array('m' => 1.60934400000000E+03, |
|
195 | 195 | 'mi' => 1.0, |
196 | 196 | 'Nmi' => 8.68976241900648E-01, |
197 | 197 | 'in' => 6.33600000000000E+04, |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | 'ang' => 1.60934400000000E+13, |
201 | 201 | 'Pica' => 4.56191999999971E+06 |
202 | 202 | ), |
203 | - 'Nmi' => array( 'm' => 1.85200000000000E+03, |
|
203 | + 'Nmi' => array('m' => 1.85200000000000E+03, |
|
204 | 204 | 'mi' => 1.15077944802354E+00, |
205 | 205 | 'Nmi' => 1.0, |
206 | 206 | 'in' => 7.29133858267717E+04, |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | 'ang' => 1.85200000000000E+13, |
210 | 210 | 'Pica' => 5.24976377952723E+06 |
211 | 211 | ), |
212 | - 'in' => array( 'm' => 2.54000000000000E-02, |
|
212 | + 'in' => array('m' => 2.54000000000000E-02, |
|
213 | 213 | 'mi' => 1.57828282828283E-05, |
214 | 214 | 'Nmi' => 1.37149028077754E-05, |
215 | 215 | 'in' => 1.0, |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | 'ang' => 2.54000000000000E+08, |
219 | 219 | 'Pica' => 7.19999999999955E+01 |
220 | 220 | ), |
221 | - 'ft' => array( 'm' => 3.04800000000000E-01, |
|
221 | + 'ft' => array('m' => 3.04800000000000E-01, |
|
222 | 222 | 'mi' => 1.89393939393939E-04, |
223 | 223 | 'Nmi' => 1.64578833693305E-04, |
224 | 224 | 'in' => 1.20000000000000E+01, |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'ang' => 3.04800000000000E+09, |
228 | 228 | 'Pica' => 8.63999999999946E+02 |
229 | 229 | ), |
230 | - 'yd' => array( 'm' => 9.14400000300000E-01, |
|
230 | + 'yd' => array('m' => 9.14400000300000E-01, |
|
231 | 231 | 'mi' => 5.68181818368230E-04, |
232 | 232 | 'Nmi' => 4.93736501241901E-04, |
233 | 233 | 'in' => 3.60000000118110E+01, |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | 'ang' => 9.14400000300000E+09, |
237 | 237 | 'Pica' => 2.59200000085023E+03 |
238 | 238 | ), |
239 | - 'ang' => array( 'm' => 1.00000000000000E-10, |
|
239 | + 'ang' => array('m' => 1.00000000000000E-10, |
|
240 | 240 | 'mi' => 6.21371192237334E-14, |
241 | 241 | 'Nmi' => 5.39956803455724E-14, |
242 | 242 | 'in' => 3.93700787401575E-09, |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'ang' => 1.0, |
246 | 246 | 'Pica' => 2.83464566929116E-07 |
247 | 247 | ), |
248 | - 'Pica' => array( 'm' => 3.52777777777800E-04, |
|
248 | + 'Pica' => array('m' => 3.52777777777800E-04, |
|
249 | 249 | 'mi' => 2.19205948372629E-07, |
250 | 250 | 'Nmi' => 1.90484761219114E-07, |
251 | 251 | 'in' => 1.38888888888898E-02, |
@@ -255,90 +255,90 @@ discard block |
||
255 | 255 | 'Pica' => 1.0 |
256 | 256 | ) |
257 | 257 | ), |
258 | - 'Time' => array( 'yr' => array( 'yr' => 1.0, |
|
258 | + 'Time' => array('yr' => array('yr' => 1.0, |
|
259 | 259 | 'day' => 365.25, |
260 | 260 | 'hr' => 8766.0, |
261 | 261 | 'mn' => 525960.0, |
262 | 262 | 'sec' => 31557600.0 |
263 | 263 | ), |
264 | - 'day' => array( 'yr' => 2.73785078713210E-03, |
|
264 | + 'day' => array('yr' => 2.73785078713210E-03, |
|
265 | 265 | 'day' => 1.0, |
266 | 266 | 'hr' => 24.0, |
267 | 267 | 'mn' => 1440.0, |
268 | 268 | 'sec' => 86400.0 |
269 | 269 | ), |
270 | - 'hr' => array( 'yr' => 1.14077116130504E-04, |
|
270 | + 'hr' => array('yr' => 1.14077116130504E-04, |
|
271 | 271 | 'day' => 4.16666666666667E-02, |
272 | 272 | 'hr' => 1.0, |
273 | 273 | 'mn' => 60.0, |
274 | 274 | 'sec' => 3600.0 |
275 | 275 | ), |
276 | - 'mn' => array( 'yr' => 1.90128526884174E-06, |
|
276 | + 'mn' => array('yr' => 1.90128526884174E-06, |
|
277 | 277 | 'day' => 6.94444444444444E-04, |
278 | 278 | 'hr' => 1.66666666666667E-02, |
279 | 279 | 'mn' => 1.0, |
280 | 280 | 'sec' => 60.0 |
281 | 281 | ), |
282 | - 'sec' => array( 'yr' => 3.16880878140289E-08, |
|
282 | + 'sec' => array('yr' => 3.16880878140289E-08, |
|
283 | 283 | 'day' => 1.15740740740741E-05, |
284 | 284 | 'hr' => 2.77777777777778E-04, |
285 | 285 | 'mn' => 1.66666666666667E-02, |
286 | 286 | 'sec' => 1.0 |
287 | 287 | ) |
288 | 288 | ), |
289 | - 'Pressure' => array( 'Pa' => array( 'Pa' => 1.0, |
|
289 | + 'Pressure' => array('Pa' => array('Pa' => 1.0, |
|
290 | 290 | 'p' => 1.0, |
291 | 291 | 'atm' => 9.86923299998193E-06, |
292 | 292 | 'at' => 9.86923299998193E-06, |
293 | 293 | 'mmHg' => 7.50061707998627E-03 |
294 | 294 | ), |
295 | - 'p' => array( 'Pa' => 1.0, |
|
295 | + 'p' => array('Pa' => 1.0, |
|
296 | 296 | 'p' => 1.0, |
297 | 297 | 'atm' => 9.86923299998193E-06, |
298 | 298 | 'at' => 9.86923299998193E-06, |
299 | 299 | 'mmHg' => 7.50061707998627E-03 |
300 | 300 | ), |
301 | - 'atm' => array( 'Pa' => 1.01324996583000E+05, |
|
301 | + 'atm' => array('Pa' => 1.01324996583000E+05, |
|
302 | 302 | 'p' => 1.01324996583000E+05, |
303 | 303 | 'atm' => 1.0, |
304 | 304 | 'at' => 1.0, |
305 | 305 | 'mmHg' => 760.0 |
306 | 306 | ), |
307 | - 'at' => array( 'Pa' => 1.01324996583000E+05, |
|
307 | + 'at' => array('Pa' => 1.01324996583000E+05, |
|
308 | 308 | 'p' => 1.01324996583000E+05, |
309 | 309 | 'atm' => 1.0, |
310 | 310 | 'at' => 1.0, |
311 | 311 | 'mmHg' => 760.0 |
312 | 312 | ), |
313 | - 'mmHg' => array( 'Pa' => 1.33322363925000E+02, |
|
313 | + 'mmHg' => array('Pa' => 1.33322363925000E+02, |
|
314 | 314 | 'p' => 1.33322363925000E+02, |
315 | 315 | 'atm' => 1.31578947368421E-03, |
316 | 316 | 'at' => 1.31578947368421E-03, |
317 | 317 | 'mmHg' => 1.0 |
318 | 318 | ) |
319 | 319 | ), |
320 | - 'Force' => array( 'N' => array( 'N' => 1.0, |
|
320 | + 'Force' => array('N' => array('N' => 1.0, |
|
321 | 321 | 'dyn' => 1.0E+5, |
322 | 322 | 'dy' => 1.0E+5, |
323 | 323 | 'lbf' => 2.24808923655339E-01 |
324 | 324 | ), |
325 | - 'dyn' => array( 'N' => 1.0E-5, |
|
325 | + 'dyn' => array('N' => 1.0E-5, |
|
326 | 326 | 'dyn' => 1.0, |
327 | 327 | 'dy' => 1.0, |
328 | 328 | 'lbf' => 2.24808923655339E-06 |
329 | 329 | ), |
330 | - 'dy' => array( 'N' => 1.0E-5, |
|
330 | + 'dy' => array('N' => 1.0E-5, |
|
331 | 331 | 'dyn' => 1.0, |
332 | 332 | 'dy' => 1.0, |
333 | 333 | 'lbf' => 2.24808923655339E-06 |
334 | 334 | ), |
335 | - 'lbf' => array( 'N' => 4.448222, |
|
335 | + 'lbf' => array('N' => 4.448222, |
|
336 | 336 | 'dyn' => 4.448222E+5, |
337 | 337 | 'dy' => 4.448222E+5, |
338 | 338 | 'lbf' => 1.0 |
339 | 339 | ) |
340 | 340 | ), |
341 | - 'Energy' => array( 'J' => array( 'J' => 1.0, |
|
341 | + 'Energy' => array('J' => array('J' => 1.0, |
|
342 | 342 | 'e' => 9.99999519343231E+06, |
343 | 343 | 'c' => 2.39006249473467E-01, |
344 | 344 | 'cal' => 2.38846190642017E-01, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | 'BTU' => 9.47815067349015E-04, |
353 | 353 | 'btu' => 9.47815067349015E-04 |
354 | 354 | ), |
355 | - 'e' => array( 'J' => 1.00000048065700E-07, |
|
355 | + 'e' => array('J' => 1.00000048065700E-07, |
|
356 | 356 | 'e' => 1.0, |
357 | 357 | 'c' => 2.39006364353494E-08, |
358 | 358 | 'cal' => 2.38846305445111E-08, |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | 'BTU' => 9.47815522922962E-11, |
367 | 367 | 'btu' => 9.47815522922962E-11 |
368 | 368 | ), |
369 | - 'c' => array( 'J' => 4.18399101363672E+00, |
|
369 | + 'c' => array('J' => 4.18399101363672E+00, |
|
370 | 370 | 'e' => 4.18398900257312E+07, |
371 | 371 | 'c' => 1.0, |
372 | 372 | 'cal' => 9.99330315287563E-01, |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'BTU' => 3.96564972437776E-03, |
381 | 381 | 'btu' => 3.96564972437776E-03 |
382 | 382 | ), |
383 | - 'cal' => array( 'J' => 4.18679484613929E+00, |
|
383 | + 'cal' => array('J' => 4.18679484613929E+00, |
|
384 | 384 | 'e' => 4.18679283372801E+07, |
385 | 385 | 'c' => 1.00067013349059E+00, |
386 | 386 | 'cal' => 1.0, |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | 'BTU' => 3.96830723907002E-03, |
395 | 395 | 'btu' => 3.96830723907002E-03 |
396 | 396 | ), |
397 | - 'eV' => array( 'J' => 1.60219000146921E-19, |
|
397 | + 'eV' => array('J' => 1.60219000146921E-19, |
|
398 | 398 | 'e' => 1.60218923136574E-12, |
399 | 399 | 'c' => 3.82933423195043E-20, |
400 | 400 | 'cal' => 3.82676978535648E-20, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'BTU' => 1.51857982414846E-22, |
409 | 409 | 'btu' => 1.51857982414846E-22 |
410 | 410 | ), |
411 | - 'ev' => array( 'J' => 1.60219000146921E-19, |
|
411 | + 'ev' => array('J' => 1.60219000146921E-19, |
|
412 | 412 | 'e' => 1.60218923136574E-12, |
413 | 413 | 'c' => 3.82933423195043E-20, |
414 | 414 | 'cal' => 3.82676978535648E-20, |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | 'BTU' => 1.51857982414846E-22, |
423 | 423 | 'btu' => 1.51857982414846E-22 |
424 | 424 | ), |
425 | - 'HPh' => array( 'J' => 2.68451741316170E+06, |
|
425 | + 'HPh' => array('J' => 2.68451741316170E+06, |
|
426 | 426 | 'e' => 2.68451612283024E+13, |
427 | 427 | 'c' => 6.41616438565991E+05, |
428 | 428 | 'cal' => 6.41186757845835E+05, |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'BTU' => 2.54442605275546E+03, |
437 | 437 | 'btu' => 2.54442605275546E+03 |
438 | 438 | ), |
439 | - 'hh' => array( 'J' => 2.68451741316170E+06, |
|
439 | + 'hh' => array('J' => 2.68451741316170E+06, |
|
440 | 440 | 'e' => 2.68451612283024E+13, |
441 | 441 | 'c' => 6.41616438565991E+05, |
442 | 442 | 'cal' => 6.41186757845835E+05, |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | 'BTU' => 2.54442605275546E+03, |
451 | 451 | 'btu' => 2.54442605275546E+03 |
452 | 452 | ), |
453 | - 'Wh' => array( 'J' => 3.59999820554720E+03, |
|
453 | + 'Wh' => array('J' => 3.59999820554720E+03, |
|
454 | 454 | 'e' => 3.59999647518369E+10, |
455 | 455 | 'c' => 8.60422069219046E+02, |
456 | 456 | 'cal' => 8.59845857713046E+02, |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | 'BTU' => 3.41213254164705E+00, |
465 | 465 | 'btu' => 3.41213254164705E+00 |
466 | 466 | ), |
467 | - 'wh' => array( 'J' => 3.59999820554720E+03, |
|
467 | + 'wh' => array('J' => 3.59999820554720E+03, |
|
468 | 468 | 'e' => 3.59999647518369E+10, |
469 | 469 | 'c' => 8.60422069219046E+02, |
470 | 470 | 'cal' => 8.59845857713046E+02, |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | 'BTU' => 3.41213254164705E+00, |
479 | 479 | 'btu' => 3.41213254164705E+00 |
480 | 480 | ), |
481 | - 'flb' => array( 'J' => 4.21400003236424E-02, |
|
481 | + 'flb' => array('J' => 4.21400003236424E-02, |
|
482 | 482 | 'e' => 4.21399800687660E+05, |
483 | 483 | 'c' => 1.00717234301644E-02, |
484 | 484 | 'cal' => 1.00649785509554E-02, |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | 'BTU' => 3.99409272448406E-05, |
493 | 493 | 'btu' => 3.99409272448406E-05 |
494 | 494 | ), |
495 | - 'BTU' => array( 'J' => 1.05505813786749E+03, |
|
495 | + 'BTU' => array('J' => 1.05505813786749E+03, |
|
496 | 496 | 'e' => 1.05505763074665E+10, |
497 | 497 | 'c' => 2.52165488508168E+02, |
498 | 498 | 'cal' => 2.51996617135510E+02, |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | 'BTU' => 1.0, |
507 | 507 | 'btu' => 1.0, |
508 | 508 | ), |
509 | - 'btu' => array( 'J' => 1.05505813786749E+03, |
|
509 | + 'btu' => array('J' => 1.05505813786749E+03, |
|
510 | 510 | 'e' => 1.05505763074665E+10, |
511 | 511 | 'c' => 2.52165488508168E+02, |
512 | 512 | 'cal' => 2.51996617135510E+02, |
@@ -521,35 +521,35 @@ discard block |
||
521 | 521 | 'btu' => 1.0, |
522 | 522 | ) |
523 | 523 | ), |
524 | - 'Power' => array( 'HP' => array( 'HP' => 1.0, |
|
524 | + 'Power' => array('HP' => array('HP' => 1.0, |
|
525 | 525 | 'h' => 1.0, |
526 | 526 | 'W' => 7.45701000000000E+02, |
527 | 527 | 'w' => 7.45701000000000E+02 |
528 | 528 | ), |
529 | - 'h' => array( 'HP' => 1.0, |
|
529 | + 'h' => array('HP' => 1.0, |
|
530 | 530 | 'h' => 1.0, |
531 | 531 | 'W' => 7.45701000000000E+02, |
532 | 532 | 'w' => 7.45701000000000E+02 |
533 | 533 | ), |
534 | - 'W' => array( 'HP' => 1.34102006031908E-03, |
|
534 | + 'W' => array('HP' => 1.34102006031908E-03, |
|
535 | 535 | 'h' => 1.34102006031908E-03, |
536 | 536 | 'W' => 1.0, |
537 | 537 | 'w' => 1.0 |
538 | 538 | ), |
539 | - 'w' => array( 'HP' => 1.34102006031908E-03, |
|
539 | + 'w' => array('HP' => 1.34102006031908E-03, |
|
540 | 540 | 'h' => 1.34102006031908E-03, |
541 | 541 | 'W' => 1.0, |
542 | 542 | 'w' => 1.0 |
543 | 543 | ) |
544 | 544 | ), |
545 | - 'Magnetism' => array( 'T' => array( 'T' => 1.0, |
|
545 | + 'Magnetism' => array('T' => array('T' => 1.0, |
|
546 | 546 | 'ga' => 10000.0 |
547 | 547 | ), |
548 | - 'ga' => array( 'T' => 0.0001, |
|
548 | + 'ga' => array('T' => 0.0001, |
|
549 | 549 | 'ga' => 1.0 |
550 | 550 | ) |
551 | 551 | ), |
552 | - 'Liquid' => array( 'tsp' => array( 'tsp' => 1.0, |
|
552 | + 'Liquid' => array('tsp' => array('tsp' => 1.0, |
|
553 | 553 | 'tbs' => 3.33333333333333E-01, |
554 | 554 | 'oz' => 1.66666666666667E-01, |
555 | 555 | 'cup' => 2.08333333333333E-02, |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | 'l' => 4.92999408400710E-03, |
562 | 562 | 'lt' => 4.92999408400710E-03 |
563 | 563 | ), |
564 | - 'tbs' => array( 'tsp' => 3.00000000000000E+00, |
|
564 | + 'tbs' => array('tsp' => 3.00000000000000E+00, |
|
565 | 565 | 'tbs' => 1.0, |
566 | 566 | 'oz' => 5.00000000000000E-01, |
567 | 567 | 'cup' => 6.25000000000000E-02, |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | 'l' => 1.47899822520213E-02, |
574 | 574 | 'lt' => 1.47899822520213E-02 |
575 | 575 | ), |
576 | - 'oz' => array( 'tsp' => 6.00000000000000E+00, |
|
576 | + 'oz' => array('tsp' => 6.00000000000000E+00, |
|
577 | 577 | 'tbs' => 2.00000000000000E+00, |
578 | 578 | 'oz' => 1.0, |
579 | 579 | 'cup' => 1.25000000000000E-01, |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | 'l' => 2.95799645040426E-02, |
586 | 586 | 'lt' => 2.95799645040426E-02 |
587 | 587 | ), |
588 | - 'cup' => array( 'tsp' => 4.80000000000000E+01, |
|
588 | + 'cup' => array('tsp' => 4.80000000000000E+01, |
|
589 | 589 | 'tbs' => 1.60000000000000E+01, |
590 | 590 | 'oz' => 8.00000000000000E+00, |
591 | 591 | 'cup' => 1.0, |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | 'l' => 2.36639716032341E-01, |
598 | 598 | 'lt' => 2.36639716032341E-01 |
599 | 599 | ), |
600 | - 'pt' => array( 'tsp' => 9.60000000000000E+01, |
|
600 | + 'pt' => array('tsp' => 9.60000000000000E+01, |
|
601 | 601 | 'tbs' => 3.20000000000000E+01, |
602 | 602 | 'oz' => 1.60000000000000E+01, |
603 | 603 | 'cup' => 2.00000000000000E+00, |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | 'l' => 4.73279432064682E-01, |
610 | 610 | 'lt' => 4.73279432064682E-01 |
611 | 611 | ), |
612 | - 'us_pt' => array( 'tsp' => 9.60000000000000E+01, |
|
612 | + 'us_pt' => array('tsp' => 9.60000000000000E+01, |
|
613 | 613 | 'tbs' => 3.20000000000000E+01, |
614 | 614 | 'oz' => 1.60000000000000E+01, |
615 | 615 | 'cup' => 2.00000000000000E+00, |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | 'l' => 4.73279432064682E-01, |
622 | 622 | 'lt' => 4.73279432064682E-01 |
623 | 623 | ), |
624 | - 'uk_pt' => array( 'tsp' => 1.15266000000000E+02, |
|
624 | + 'uk_pt' => array('tsp' => 1.15266000000000E+02, |
|
625 | 625 | 'tbs' => 3.84220000000000E+01, |
626 | 626 | 'oz' => 1.92110000000000E+01, |
627 | 627 | 'cup' => 2.40137500000000E+00, |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'l' => 5.68260698087162E-01, |
634 | 634 | 'lt' => 5.68260698087162E-01 |
635 | 635 | ), |
636 | - 'qt' => array( 'tsp' => 1.92000000000000E+02, |
|
636 | + 'qt' => array('tsp' => 1.92000000000000E+02, |
|
637 | 637 | 'tbs' => 6.40000000000000E+01, |
638 | 638 | 'oz' => 3.20000000000000E+01, |
639 | 639 | 'cup' => 4.00000000000000E+00, |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | 'l' => 9.46558864129363E-01, |
646 | 646 | 'lt' => 9.46558864129363E-01 |
647 | 647 | ), |
648 | - 'gal' => array( 'tsp' => 7.68000000000000E+02, |
|
648 | + 'gal' => array('tsp' => 7.68000000000000E+02, |
|
649 | 649 | 'tbs' => 2.56000000000000E+02, |
650 | 650 | 'oz' => 1.28000000000000E+02, |
651 | 651 | 'cup' => 1.60000000000000E+01, |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | 'l' => 3.78623545651745E+00, |
658 | 658 | 'lt' => 3.78623545651745E+00 |
659 | 659 | ), |
660 | - 'l' => array( 'tsp' => 2.02840000000000E+02, |
|
660 | + 'l' => array('tsp' => 2.02840000000000E+02, |
|
661 | 661 | 'tbs' => 6.76133333333333E+01, |
662 | 662 | 'oz' => 3.38066666666667E+01, |
663 | 663 | 'cup' => 4.22583333333333E+00, |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | 'l' => 1.0, |
670 | 670 | 'lt' => 1.0 |
671 | 671 | ), |
672 | - 'lt' => array( 'tsp' => 2.02840000000000E+02, |
|
672 | + 'lt' => array('tsp' => 2.02840000000000E+02, |
|
673 | 673 | 'tbs' => 6.76133333333333E+01, |
674 | 674 | 'oz' => 3.38066666666667E+01, |
675 | 675 | 'cup' => 4.22583333333333E+00, |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | |
699 | 699 | $realNumber = $imaginary = 0; |
700 | 700 | // Extract the suffix, if there is one |
701 | - $suffix = substr($workString,-1); |
|
702 | - if (!is_numeric($suffix)) { |
|
703 | - $workString = substr($workString,0,-1); |
|
701 | + $suffix = substr($workString, -1); |
|
702 | + if ( ! is_numeric($suffix)) { |
|
703 | + $workString = substr($workString, 0, -1); |
|
704 | 704 | } else { |
705 | 705 | $suffix = ''; |
706 | 706 | } |
@@ -712,15 +712,15 @@ discard block |
||
712 | 712 | } |
713 | 713 | $power = ''; |
714 | 714 | $realNumber = strtok($workString, '+-'); |
715 | - if (strtoupper(substr($realNumber,-1)) == 'E') { |
|
715 | + if (strtoupper(substr($realNumber, -1)) == 'E') { |
|
716 | 716 | $power = strtok('+-'); |
717 | 717 | ++$leadingSign; |
718 | 718 | } |
719 | 719 | |
720 | - $realNumber = substr($workString,0,strlen($realNumber)+strlen($power)+$leadingSign); |
|
720 | + $realNumber = substr($workString, 0, strlen($realNumber) + strlen($power) + $leadingSign); |
|
721 | 721 | |
722 | 722 | if ($suffix != '') { |
723 | - $imaginary = substr($workString,strlen($realNumber)); |
|
723 | + $imaginary = substr($workString, strlen($realNumber)); |
|
724 | 724 | |
725 | 725 | if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) { |
726 | 726 | $imaginary = $realNumber.'1'; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | - return array( 'real' => $realNumber, |
|
736 | + return array('real' => $realNumber, |
|
737 | 737 | 'imaginary' => $imaginary, |
738 | 738 | 'suffix' => $suffix |
739 | 739 | ); |
@@ -749,24 +749,24 @@ discard block |
||
749 | 749 | * @return string The "cleaned" complex number |
750 | 750 | */ |
751 | 751 | private static function _cleanComplex($complexNumber) { |
752 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
753 | - if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1); |
|
752 | + if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber, 1); |
|
753 | + if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber, 1); |
|
754 | 754 | if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber; |
755 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
755 | + if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber, 1); |
|
756 | 756 | return $complexNumber; |
757 | 757 | } |
758 | 758 | |
759 | 759 | |
760 | - private static function _nbrConversionFormat($xVal,$places) { |
|
761 | - if (!is_null($places)) { |
|
760 | + private static function _nbrConversionFormat($xVal, $places) { |
|
761 | + if ( ! is_null($places)) { |
|
762 | 762 | if (strlen($xVal) <= $places) { |
763 | - return substr(str_pad($xVal,$places,'0',STR_PAD_LEFT),-10); |
|
763 | + return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10); |
|
764 | 764 | } else { |
765 | 765 | return PHPExcel_Calculation_Functions::NaN(); |
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
769 | - return substr($xVal,-10); |
|
769 | + return substr($xVal, -10); |
|
770 | 770 | } // function _nbrConversionFormat() |
771 | 771 | |
772 | 772 | |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | * |
793 | 793 | */ |
794 | 794 | public static function BESSELI($x, $ord) { |
795 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
796 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
795 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
796 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
797 | 797 | |
798 | 798 | if ((is_numeric($x)) && (is_numeric($ord))) { |
799 | - $ord = floor($ord); |
|
799 | + $ord = floor($ord); |
|
800 | 800 | if ($ord < 0) { |
801 | 801 | return PHPExcel_Calculation_Functions::NaN(); |
802 | 802 | } |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | * |
847 | 847 | */ |
848 | 848 | public static function BESSELJ($x, $ord) { |
849 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
850 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
849 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
850 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
851 | 851 | |
852 | 852 | if ((is_numeric($x)) && (is_numeric($ord))) { |
853 | - $ord = floor($ord); |
|
853 | + $ord = floor($ord); |
|
854 | 854 | if ($ord < 0) { |
855 | 855 | return PHPExcel_Calculation_Functions::NaN(); |
856 | 856 | } |
@@ -937,26 +937,26 @@ discard block |
||
937 | 937 | * |
938 | 938 | */ |
939 | 939 | public static function BESSELK($x, $ord) { |
940 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
941 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
940 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
941 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
942 | 942 | |
943 | 943 | if ((is_numeric($x)) && (is_numeric($ord))) { |
944 | 944 | if (($ord < 0) || ($x == 0.0)) { |
945 | 945 | return PHPExcel_Calculation_Functions::NaN(); |
946 | 946 | } |
947 | 947 | |
948 | - switch(floor($ord)) { |
|
948 | + switch (floor($ord)) { |
|
949 | 949 | case 0 : return self::_Besselk0($x); |
950 | 950 | break; |
951 | 951 | case 1 : return self::_Besselk1($x); |
952 | 952 | break; |
953 | - default : $fTox = 2 / $x; |
|
954 | - $fBkm = self::_Besselk0($x); |
|
955 | - $fBk = self::_Besselk1($x); |
|
953 | + default : $fTox = 2 / $x; |
|
954 | + $fBkm = self::_Besselk0($x); |
|
955 | + $fBk = self::_Besselk1($x); |
|
956 | 956 | for ($n = 1; $n < $ord; ++$n) { |
957 | 957 | $fBkp = $fBkm + $n * $fTox * $fBk; |
958 | 958 | $fBkm = $fBk; |
959 | - $fBk = $fBkp; |
|
959 | + $fBk = $fBkp; |
|
960 | 960 | } |
961 | 961 | } |
962 | 962 | return (is_nan($fBk)) ? PHPExcel_Calculation_Functions::NaN() : $fBk; |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | (-0.4237922726e7 + $y * 0.8511937935e4))))); |
991 | 991 | $f2 = 0.2499580570e14 + $y * (0.4244419664e12 + $y * (0.3733650367e10 + $y * (0.2245904002e8 + $y * |
992 | 992 | (0.1020426050e6 + $y * (0.3549632885e3 + $y))))); |
993 | - $fRet = $f1 / $f2 + 0.636619772 * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum); |
|
993 | + $fRet = $f1 / $f2 + 0.636619772 * (self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum); |
|
994 | 994 | } else { |
995 | 995 | // $z = 8.0 / $fNum; |
996 | 996 | // $y = ($z * $z); |
@@ -1026,26 +1026,26 @@ discard block |
||
1026 | 1026 | * @return float |
1027 | 1027 | */ |
1028 | 1028 | public static function BESSELY($x, $ord) { |
1029 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1030 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
1029 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1030 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
1031 | 1031 | |
1032 | 1032 | if ((is_numeric($x)) && (is_numeric($ord))) { |
1033 | 1033 | if (($ord < 0) || ($x == 0.0)) { |
1034 | 1034 | return PHPExcel_Calculation_Functions::NaN(); |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - switch(floor($ord)) { |
|
1037 | + switch (floor($ord)) { |
|
1038 | 1038 | case 0 : return self::_Bessely0($x); |
1039 | 1039 | break; |
1040 | 1040 | case 1 : return self::_Bessely1($x); |
1041 | 1041 | break; |
1042 | - default: $fTox = 2 / $x; |
|
1043 | - $fBym = self::_Bessely0($x); |
|
1044 | - $fBy = self::_Bessely1($x); |
|
1042 | + default: $fTox = 2 / $x; |
|
1043 | + $fBym = self::_Bessely0($x); |
|
1044 | + $fBy = self::_Bessely1($x); |
|
1045 | 1045 | for ($n = 1; $n < $ord; ++$n) { |
1046 | 1046 | $fByp = $n * $fTox * $fBy - $fBym; |
1047 | 1047 | $fBym = $fBy; |
1048 | - $fBy = $fByp; |
|
1048 | + $fBy = $fByp; |
|
1049 | 1049 | } |
1050 | 1050 | } |
1051 | 1051 | return (is_nan($fBy)) ? PHPExcel_Calculation_Functions::NaN() : $fBy; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | * @return string |
1074 | 1074 | */ |
1075 | 1075 | public static function BINTODEC($x) { |
1076 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1076 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1077 | 1077 | |
1078 | 1078 | if (is_bool($x)) { |
1079 | 1079 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1086,15 +1086,15 @@ discard block |
||
1086 | 1086 | $x = floor($x); |
1087 | 1087 | } |
1088 | 1088 | $x = (string) $x; |
1089 | - if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { |
|
1089 | + if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { |
|
1090 | 1090 | return PHPExcel_Calculation_Functions::NaN(); |
1091 | 1091 | } |
1092 | 1092 | if (strlen($x) > 10) { |
1093 | 1093 | return PHPExcel_Calculation_Functions::NaN(); |
1094 | 1094 | } elseif (strlen($x) == 10) { |
1095 | 1095 | // Two's Complement |
1096 | - $x = substr($x,-9); |
|
1097 | - return '-'.(512-bindec($x)); |
|
1096 | + $x = substr($x, -9); |
|
1097 | + return '-'.(512 - bindec($x)); |
|
1098 | 1098 | } |
1099 | 1099 | return bindec($x); |
1100 | 1100 | } // function BINTODEC() |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | * If places is negative, BIN2HEX returns the #NUM! error value. |
1125 | 1125 | * @return string |
1126 | 1126 | */ |
1127 | - public static function BINTOHEX($x, $places=NULL) { |
|
1128 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1129 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1127 | + public static function BINTOHEX($x, $places = NULL) { |
|
1128 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1129 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1130 | 1130 | |
1131 | 1131 | if (is_bool($x)) { |
1132 | 1132 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1139,18 +1139,18 @@ discard block |
||
1139 | 1139 | $x = floor($x); |
1140 | 1140 | } |
1141 | 1141 | $x = (string) $x; |
1142 | - if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { |
|
1142 | + if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { |
|
1143 | 1143 | return PHPExcel_Calculation_Functions::NaN(); |
1144 | 1144 | } |
1145 | 1145 | if (strlen($x) > 10) { |
1146 | 1146 | return PHPExcel_Calculation_Functions::NaN(); |
1147 | 1147 | } elseif (strlen($x) == 10) { |
1148 | 1148 | // Two's Complement |
1149 | - return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2); |
|
1149 | + return str_repeat('F', 8).substr(strtoupper(dechex(bindec(substr($x, -9)))), -2); |
|
1150 | 1150 | } |
1151 | 1151 | $hexVal = (string) strtoupper(dechex(bindec($x))); |
1152 | 1152 | |
1153 | - return self::_nbrConversionFormat($hexVal,$places); |
|
1153 | + return self::_nbrConversionFormat($hexVal, $places); |
|
1154 | 1154 | } // function BINTOHEX() |
1155 | 1155 | |
1156 | 1156 | |
@@ -1178,9 +1178,9 @@ discard block |
||
1178 | 1178 | * If places is negative, BIN2OCT returns the #NUM! error value. |
1179 | 1179 | * @return string |
1180 | 1180 | */ |
1181 | - public static function BINTOOCT($x, $places=NULL) { |
|
1182 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1183 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1181 | + public static function BINTOOCT($x, $places = NULL) { |
|
1182 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1183 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1184 | 1184 | |
1185 | 1185 | if (is_bool($x)) { |
1186 | 1186 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1193,18 +1193,18 @@ discard block |
||
1193 | 1193 | $x = floor($x); |
1194 | 1194 | } |
1195 | 1195 | $x = (string) $x; |
1196 | - if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { |
|
1196 | + if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { |
|
1197 | 1197 | return PHPExcel_Calculation_Functions::NaN(); |
1198 | 1198 | } |
1199 | 1199 | if (strlen($x) > 10) { |
1200 | 1200 | return PHPExcel_Calculation_Functions::NaN(); |
1201 | 1201 | } elseif (strlen($x) == 10) { |
1202 | 1202 | // Two's Complement |
1203 | - return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3); |
|
1203 | + return str_repeat('7', 7).substr(strtoupper(decoct(bindec(substr($x, -9)))), -3); |
|
1204 | 1204 | } |
1205 | 1205 | $octVal = (string) decoct(bindec($x)); |
1206 | 1206 | |
1207 | - return self::_nbrConversionFormat($octVal,$places); |
|
1207 | + return self::_nbrConversionFormat($octVal, $places); |
|
1208 | 1208 | } // function BINTOOCT() |
1209 | 1209 | |
1210 | 1210 | |
@@ -1236,9 +1236,9 @@ discard block |
||
1236 | 1236 | * If places is zero or negative, DEC2BIN returns the #NUM! error value. |
1237 | 1237 | * @return string |
1238 | 1238 | */ |
1239 | - public static function DECTOBIN($x, $places=NULL) { |
|
1240 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1241 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1239 | + public static function DECTOBIN($x, $places = NULL) { |
|
1240 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1241 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1242 | 1242 | |
1243 | 1243 | if (is_bool($x)) { |
1244 | 1244 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1248,19 +1248,19 @@ discard block |
||
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | $x = (string) $x; |
1251 | - if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { |
|
1251 | + if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1252 | 1252 | return PHPExcel_Calculation_Functions::VALUE(); |
1253 | 1253 | } |
1254 | 1254 | $x = (string) floor($x); |
1255 | 1255 | $r = decbin($x); |
1256 | 1256 | if (strlen($r) == 32) { |
1257 | 1257 | // Two's Complement |
1258 | - $r = substr($r,-10); |
|
1258 | + $r = substr($r, -10); |
|
1259 | 1259 | } elseif (strlen($r) > 11) { |
1260 | 1260 | return PHPExcel_Calculation_Functions::NaN(); |
1261 | 1261 | } |
1262 | 1262 | |
1263 | - return self::_nbrConversionFormat($r,$places); |
|
1263 | + return self::_nbrConversionFormat($r, $places); |
|
1264 | 1264 | } // function DECTOBIN() |
1265 | 1265 | |
1266 | 1266 | |
@@ -1292,9 +1292,9 @@ discard block |
||
1292 | 1292 | * If places is zero or negative, DEC2HEX returns the #NUM! error value. |
1293 | 1293 | * @return string |
1294 | 1294 | */ |
1295 | - public static function DECTOHEX($x, $places=null) { |
|
1296 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1297 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1295 | + public static function DECTOHEX($x, $places = null) { |
|
1296 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1297 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1298 | 1298 | |
1299 | 1299 | if (is_bool($x)) { |
1300 | 1300 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | } |
1305 | 1305 | } |
1306 | 1306 | $x = (string) $x; |
1307 | - if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { |
|
1307 | + if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1308 | 1308 | return PHPExcel_Calculation_Functions::VALUE(); |
1309 | 1309 | } |
1310 | 1310 | $x = (string) floor($x); |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | $r = 'FF'.$r; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | - return self::_nbrConversionFormat($r,$places); |
|
1317 | + return self::_nbrConversionFormat($r, $places); |
|
1318 | 1318 | } // function DECTOHEX() |
1319 | 1319 | |
1320 | 1320 | |
@@ -1346,9 +1346,9 @@ discard block |
||
1346 | 1346 | * If places is zero or negative, DEC2OCT returns the #NUM! error value. |
1347 | 1347 | * @return string |
1348 | 1348 | */ |
1349 | - public static function DECTOOCT($x, $places=null) { |
|
1350 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1351 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1349 | + public static function DECTOOCT($x, $places = null) { |
|
1350 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1351 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1352 | 1352 | |
1353 | 1353 | if (is_bool($x)) { |
1354 | 1354 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1358,17 +1358,17 @@ discard block |
||
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | $x = (string) $x; |
1361 | - if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { |
|
1361 | + if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1362 | 1362 | return PHPExcel_Calculation_Functions::VALUE(); |
1363 | 1363 | } |
1364 | 1364 | $x = (string) floor($x); |
1365 | 1365 | $r = decoct($x); |
1366 | 1366 | if (strlen($r) == 11) { |
1367 | 1367 | // Two's Complement |
1368 | - $r = substr($r,-10); |
|
1368 | + $r = substr($r, -10); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | - return self::_nbrConversionFormat($r,$places); |
|
1371 | + return self::_nbrConversionFormat($r, $places); |
|
1372 | 1372 | } // function DECTOOCT() |
1373 | 1373 | |
1374 | 1374 | |
@@ -1403,20 +1403,20 @@ discard block |
||
1403 | 1403 | * If places is negative, HEX2BIN returns the #NUM! error value. |
1404 | 1404 | * @return string |
1405 | 1405 | */ |
1406 | - public static function HEXTOBIN($x, $places=null) { |
|
1407 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1408 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1406 | + public static function HEXTOBIN($x, $places = null) { |
|
1407 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1408 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1409 | 1409 | |
1410 | 1410 | if (is_bool($x)) { |
1411 | 1411 | return PHPExcel_Calculation_Functions::VALUE(); |
1412 | 1412 | } |
1413 | 1413 | $x = (string) $x; |
1414 | - if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
|
1414 | + if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1415 | 1415 | return PHPExcel_Calculation_Functions::NaN(); |
1416 | 1416 | } |
1417 | 1417 | $binVal = decbin(hexdec($x)); |
1418 | 1418 | |
1419 | - return substr(self::_nbrConversionFormat($binVal,$places),-10); |
|
1419 | + return substr(self::_nbrConversionFormat($binVal, $places), -10); |
|
1420 | 1420 | } // function HEXTOBIN() |
1421 | 1421 | |
1422 | 1422 | |
@@ -1440,13 +1440,13 @@ discard block |
||
1440 | 1440 | * @return string |
1441 | 1441 | */ |
1442 | 1442 | public static function HEXTODEC($x) { |
1443 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1443 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1444 | 1444 | |
1445 | 1445 | if (is_bool($x)) { |
1446 | 1446 | return PHPExcel_Calculation_Functions::VALUE(); |
1447 | 1447 | } |
1448 | 1448 | $x = (string) $x; |
1449 | - if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
|
1449 | + if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1450 | 1450 | return PHPExcel_Calculation_Functions::NaN(); |
1451 | 1451 | } |
1452 | 1452 | return hexdec($x); |
@@ -1485,20 +1485,20 @@ discard block |
||
1485 | 1485 | * If places is negative, HEX2OCT returns the #NUM! error value. |
1486 | 1486 | * @return string |
1487 | 1487 | */ |
1488 | - public static function HEXTOOCT($x, $places=null) { |
|
1489 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1490 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1488 | + public static function HEXTOOCT($x, $places = null) { |
|
1489 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1490 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1491 | 1491 | |
1492 | 1492 | if (is_bool($x)) { |
1493 | 1493 | return PHPExcel_Calculation_Functions::VALUE(); |
1494 | 1494 | } |
1495 | 1495 | $x = (string) $x; |
1496 | - if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
|
1496 | + if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1497 | 1497 | return PHPExcel_Calculation_Functions::NaN(); |
1498 | 1498 | } |
1499 | 1499 | $octVal = decoct(hexdec($x)); |
1500 | 1500 | |
1501 | - return self::_nbrConversionFormat($octVal,$places); |
|
1501 | + return self::_nbrConversionFormat($octVal, $places); |
|
1502 | 1502 | } // function HEXTOOCT() |
1503 | 1503 | |
1504 | 1504 | |
@@ -1536,20 +1536,20 @@ discard block |
||
1536 | 1536 | * value. |
1537 | 1537 | * @return string |
1538 | 1538 | */ |
1539 | - public static function OCTTOBIN($x, $places=null) { |
|
1540 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1541 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1539 | + public static function OCTTOBIN($x, $places = null) { |
|
1540 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1541 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1542 | 1542 | |
1543 | 1543 | if (is_bool($x)) { |
1544 | 1544 | return PHPExcel_Calculation_Functions::VALUE(); |
1545 | 1545 | } |
1546 | 1546 | $x = (string) $x; |
1547 | - if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
|
1547 | + if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1548 | 1548 | return PHPExcel_Calculation_Functions::NaN(); |
1549 | 1549 | } |
1550 | 1550 | $r = decbin(octdec($x)); |
1551 | 1551 | |
1552 | - return self::_nbrConversionFormat($r,$places); |
|
1552 | + return self::_nbrConversionFormat($r, $places); |
|
1553 | 1553 | } // function OCTTOBIN() |
1554 | 1554 | |
1555 | 1555 | |
@@ -1573,13 +1573,13 @@ discard block |
||
1573 | 1573 | * @return string |
1574 | 1574 | */ |
1575 | 1575 | public static function OCTTODEC($x) { |
1576 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1576 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1577 | 1577 | |
1578 | 1578 | if (is_bool($x)) { |
1579 | 1579 | return PHPExcel_Calculation_Functions::VALUE(); |
1580 | 1580 | } |
1581 | 1581 | $x = (string) $x; |
1582 | - if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
|
1582 | + if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1583 | 1583 | return PHPExcel_Calculation_Functions::NaN(); |
1584 | 1584 | } |
1585 | 1585 | return octdec($x); |
@@ -1615,20 +1615,20 @@ discard block |
||
1615 | 1615 | * If places is negative, OCT2HEX returns the #NUM! error value. |
1616 | 1616 | * @return string |
1617 | 1617 | */ |
1618 | - public static function OCTTOHEX($x, $places=null) { |
|
1619 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1620 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1618 | + public static function OCTTOHEX($x, $places = null) { |
|
1619 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1620 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1621 | 1621 | |
1622 | 1622 | if (is_bool($x)) { |
1623 | 1623 | return PHPExcel_Calculation_Functions::VALUE(); |
1624 | 1624 | } |
1625 | 1625 | $x = (string) $x; |
1626 | - if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
|
1626 | + if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1627 | 1627 | return PHPExcel_Calculation_Functions::NaN(); |
1628 | 1628 | } |
1629 | 1629 | $hexVal = strtoupper(dechex(octdec($x))); |
1630 | 1630 | |
1631 | - return self::_nbrConversionFormat($hexVal,$places); |
|
1631 | + return self::_nbrConversionFormat($hexVal, $places); |
|
1632 | 1632 | } // function OCTTOHEX() |
1633 | 1633 | |
1634 | 1634 | |
@@ -1648,15 +1648,15 @@ discard block |
||
1648 | 1648 | * If omitted, the suffix is assumed to be "i". |
1649 | 1649 | * @return string |
1650 | 1650 | */ |
1651 | - public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') { |
|
1652 | - $realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
1653 | - $imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary); |
|
1654 | - $suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix); |
|
1651 | + public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') { |
|
1652 | + $realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
1653 | + $imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary); |
|
1654 | + $suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix); |
|
1655 | 1655 | |
1656 | 1656 | if (((is_numeric($realNumber)) && (is_numeric($imaginary))) && |
1657 | 1657 | (($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) { |
1658 | - $realNumber = (float) $realNumber; |
|
1659 | - $imaginary = (float) $imaginary; |
|
1658 | + $realNumber = (float) $realNumber; |
|
1659 | + $imaginary = (float) $imaginary; |
|
1660 | 1660 | |
1661 | 1661 | if ($suffix == '') $suffix = 'i'; |
1662 | 1662 | if ($realNumber == 0.0) { |
@@ -1766,7 +1766,7 @@ discard block |
||
1766 | 1766 | if ($parsedComplex['real'] == 0.0) { |
1767 | 1767 | if ($parsedComplex['imaginary'] == 0.0) { |
1768 | 1768 | return 0.0; |
1769 | - } elseif($parsedComplex['imaginary'] < 0.0) { |
|
1769 | + } elseif ($parsedComplex['imaginary'] < 0.0) { |
|
1770 | 1770 | return M_PI / -2; |
1771 | 1771 | } else { |
1772 | 1772 | return M_PI / 2; |
@@ -1800,7 +1800,7 @@ discard block |
||
1800 | 1800 | if ($parsedComplex['imaginary'] == 0.0) { |
1801 | 1801 | return $parsedComplex['real']; |
1802 | 1802 | } else { |
1803 | - return self::_cleanComplex( self::COMPLEX( $parsedComplex['real'], |
|
1803 | + return self::_cleanComplex(self::COMPLEX($parsedComplex['real'], |
|
1804 | 1804 | 0 - $parsedComplex['imaginary'], |
1805 | 1805 | $parsedComplex['suffix'] |
1806 | 1806 | ) |
@@ -1828,7 +1828,7 @@ discard block |
||
1828 | 1828 | if ($parsedComplex['imaginary'] == 0.0) { |
1829 | 1829 | return cos($parsedComplex['real']); |
1830 | 1830 | } else { |
1831 | - return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']),sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix'])); |
|
1831 | + return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']), sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']), $parsedComplex['suffix'])); |
|
1832 | 1832 | } |
1833 | 1833 | } // function IMCOS() |
1834 | 1834 | |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | if ($parsedComplex['imaginary'] == 0.0) { |
1853 | 1853 | return sin($parsedComplex['real']); |
1854 | 1854 | } else { |
1855 | - return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']); |
|
1855 | + return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']), cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']), $parsedComplex['suffix']); |
|
1856 | 1856 | } |
1857 | 1857 | } // function IMSIN() |
1858 | 1858 | |
@@ -1879,9 +1879,9 @@ discard block |
||
1879 | 1879 | $r = sqrt(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']))); |
1880 | 1880 | |
1881 | 1881 | if ($parsedComplex['suffix'] == '') { |
1882 | - return self::COMPLEX($d1 * $r,$d2 * $r); |
|
1882 | + return self::COMPLEX($d1 * $r, $d2 * $r); |
|
1883 | 1883 | } else { |
1884 | - return self::COMPLEX($d1 * $r,$d2 * $r,$parsedComplex['suffix']); |
|
1884 | + return self::COMPLEX($d1 * $r, $d2 * $r, $parsedComplex['suffix']); |
|
1885 | 1885 | } |
1886 | 1886 | } // function IMSQRT() |
1887 | 1887 | |
@@ -1910,9 +1910,9 @@ discard block |
||
1910 | 1910 | $t = self::IMARGUMENT($complexNumber); |
1911 | 1911 | |
1912 | 1912 | if ($parsedComplex['suffix'] == '') { |
1913 | - return self::COMPLEX($logR,$t); |
|
1913 | + return self::COMPLEX($logR, $t); |
|
1914 | 1914 | } else { |
1915 | - return self::COMPLEX($logR,$t,$parsedComplex['suffix']); |
|
1915 | + return self::COMPLEX($logR, $t, $parsedComplex['suffix']); |
|
1916 | 1916 | } |
1917 | 1917 | } // function IMLN() |
1918 | 1918 | |
@@ -1939,7 +1939,7 @@ discard block |
||
1939 | 1939 | return log10($parsedComplex['real']); |
1940 | 1940 | } |
1941 | 1941 | |
1942 | - return self::IMPRODUCT(log10(EULER),self::IMLN($complexNumber)); |
|
1942 | + return self::IMPRODUCT(log10(EULER), self::IMLN($complexNumber)); |
|
1943 | 1943 | } // function IMLOG10() |
1944 | 1944 | |
1945 | 1945 | |
@@ -1962,10 +1962,10 @@ discard block |
||
1962 | 1962 | if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { |
1963 | 1963 | return PHPExcel_Calculation_Functions::NaN(); |
1964 | 1964 | } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) { |
1965 | - return log($parsedComplex['real'],2); |
|
1965 | + return log($parsedComplex['real'], 2); |
|
1966 | 1966 | } |
1967 | 1967 | |
1968 | - return self::IMPRODUCT(log(EULER,2),self::IMLN($complexNumber)); |
|
1968 | + return self::IMPRODUCT(log(EULER, 2), self::IMLN($complexNumber)); |
|
1969 | 1969 | } // function IMLOG2() |
1970 | 1970 | |
1971 | 1971 | |
@@ -1994,9 +1994,9 @@ discard block |
||
1994 | 1994 | $eY = $e * sin($parsedComplex['imaginary']); |
1995 | 1995 | |
1996 | 1996 | if ($parsedComplex['suffix'] == '') { |
1997 | - return self::COMPLEX($eX,$eY); |
|
1997 | + return self::COMPLEX($eX, $eY); |
|
1998 | 1998 | } else { |
1999 | - return self::COMPLEX($eX,$eY,$parsedComplex['suffix']); |
|
1999 | + return self::COMPLEX($eX, $eY, $parsedComplex['suffix']); |
|
2000 | 2000 | } |
2001 | 2001 | } // function IMEXP() |
2002 | 2002 | |
@@ -2013,25 +2013,25 @@ discard block |
||
2013 | 2013 | * @param float $realNumber The power to which you want to raise the complex number. |
2014 | 2014 | * @return string |
2015 | 2015 | */ |
2016 | - public static function IMPOWER($complexNumber,$realNumber) { |
|
2017 | - $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); |
|
2018 | - $realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
2016 | + public static function IMPOWER($complexNumber, $realNumber) { |
|
2017 | + $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); |
|
2018 | + $realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
2019 | 2019 | |
2020 | - if (!is_numeric($realNumber)) { |
|
2020 | + if ( ! is_numeric($realNumber)) { |
|
2021 | 2021 | return PHPExcel_Calculation_Functions::VALUE(); |
2022 | 2022 | } |
2023 | 2023 | |
2024 | 2024 | $parsedComplex = self::_parseComplex($complexNumber); |
2025 | 2025 | |
2026 | 2026 | $r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])); |
2027 | - $rPower = pow($r,$realNumber); |
|
2027 | + $rPower = pow($r, $realNumber); |
|
2028 | 2028 | $theta = self::IMARGUMENT($complexNumber) * $realNumber; |
2029 | 2029 | if ($theta == 0) { |
2030 | 2030 | return 1; |
2031 | 2031 | } elseif ($parsedComplex['imaginary'] == 0.0) { |
2032 | - return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']); |
|
2032 | + return self::COMPLEX($rPower * cos($theta), $rPower * sin($theta), $parsedComplex['suffix']); |
|
2033 | 2033 | } else { |
2034 | - return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']); |
|
2034 | + return self::COMPLEX($rPower * cos($theta), $rPower * sin($theta), $parsedComplex['suffix']); |
|
2035 | 2035 | } |
2036 | 2036 | } // function IMPOWER() |
2037 | 2037 | |
@@ -2048,9 +2048,9 @@ discard block |
||
2048 | 2048 | * @param string $complexDivisor The complex denominator or divisor. |
2049 | 2049 | * @return string |
2050 | 2050 | */ |
2051 | - public static function IMDIV($complexDividend,$complexDivisor) { |
|
2052 | - $complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend); |
|
2053 | - $complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor); |
|
2051 | + public static function IMDIV($complexDividend, $complexDivisor) { |
|
2052 | + $complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend); |
|
2053 | + $complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor); |
|
2054 | 2054 | |
2055 | 2055 | $parsedComplexDividend = self::_parseComplex($complexDividend); |
2056 | 2056 | $parsedComplexDivisor = self::_parseComplex($complexDivisor); |
@@ -2067,8 +2067,8 @@ discard block |
||
2067 | 2067 | $d2 = ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['real']) - ($parsedComplexDividend['real'] * $parsedComplexDivisor['imaginary']); |
2068 | 2068 | $d3 = ($parsedComplexDivisor['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDivisor['imaginary'] * $parsedComplexDivisor['imaginary']); |
2069 | 2069 | |
2070 | - $r = $d1/$d3; |
|
2071 | - $i = $d2/$d3; |
|
2070 | + $r = $d1 / $d3; |
|
2071 | + $i = $d2 / $d3; |
|
2072 | 2072 | |
2073 | 2073 | if ($i > 0.0) { |
2074 | 2074 | return self::_cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']); |
@@ -2092,7 +2092,7 @@ discard block |
||
2092 | 2092 | * @param string $complexNumber2 The complex number to subtract from complexNumber1. |
2093 | 2093 | * @return string |
2094 | 2094 | */ |
2095 | - public static function IMSUB($complexNumber1,$complexNumber2) { |
|
2095 | + public static function IMSUB($complexNumber1, $complexNumber2) { |
|
2096 | 2096 | $complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1); |
2097 | 2097 | $complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2); |
2098 | 2098 | |
@@ -2109,7 +2109,7 @@ discard block |
||
2109 | 2109 | $d1 = $parsedComplex1['real'] - $parsedComplex2['real']; |
2110 | 2110 | $d2 = $parsedComplex1['imaginary'] - $parsedComplex2['imaginary']; |
2111 | 2111 | |
2112 | - return self::COMPLEX($d1,$d2,$parsedComplex1['suffix']); |
|
2112 | + return self::COMPLEX($d1, $d2, $parsedComplex1['suffix']); |
|
2113 | 2113 | } // function IMSUB() |
2114 | 2114 | |
2115 | 2115 | |
@@ -2145,7 +2145,7 @@ discard block |
||
2145 | 2145 | } |
2146 | 2146 | |
2147 | 2147 | if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; } |
2148 | - return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix); |
|
2148 | + return self::COMPLEX($returnValue['real'], $returnValue['imaginary'], $activeSuffix); |
|
2149 | 2149 | } // function IMSUM() |
2150 | 2150 | |
2151 | 2151 | |
@@ -2181,7 +2181,7 @@ discard block |
||
2181 | 2181 | } |
2182 | 2182 | |
2183 | 2183 | if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; } |
2184 | - return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix); |
|
2184 | + return self::COMPLEX($returnValue['real'], $returnValue['imaginary'], $activeSuffix); |
|
2185 | 2185 | } // function IMPRODUCT() |
2186 | 2186 | |
2187 | 2187 | |
@@ -2200,7 +2200,7 @@ discard block |
||
2200 | 2200 | * @param float $b The second number. If omitted, b is assumed to be zero. |
2201 | 2201 | * @return int |
2202 | 2202 | */ |
2203 | - public static function DELTA($a, $b=0) { |
|
2203 | + public static function DELTA($a, $b = 0) { |
|
2204 | 2204 | $a = PHPExcel_Calculation_Functions::flattenSingleValue($a); |
2205 | 2205 | $b = PHPExcel_Calculation_Functions::flattenSingleValue($b); |
2206 | 2206 | |
@@ -2223,9 +2223,9 @@ discard block |
||
2223 | 2223 | * If you omit a value for step, GESTEP uses zero. |
2224 | 2224 | * @return int |
2225 | 2225 | */ |
2226 | - public static function GESTEP($number, $step=0) { |
|
2227 | - $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); |
|
2228 | - $step = PHPExcel_Calculation_Functions::flattenSingleValue($step); |
|
2226 | + public static function GESTEP($number, $step = 0) { |
|
2227 | + $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); |
|
2228 | + $step = PHPExcel_Calculation_Functions::flattenSingleValue($step); |
|
2229 | 2229 | |
2230 | 2230 | return (int) ($number >= $step); |
2231 | 2231 | } // function GESTEP() |
@@ -2337,7 +2337,7 @@ discard block |
||
2337 | 2337 | * @return int |
2338 | 2338 | */ |
2339 | 2339 | public static function ERFC($x) { |
2340 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
2340 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
2341 | 2341 | |
2342 | 2342 | if (is_numeric($x)) { |
2343 | 2343 | if ($x < 0) { |
@@ -2356,7 +2356,7 @@ discard block |
||
2356 | 2356 | */ |
2357 | 2357 | public static function getConversionGroups() { |
2358 | 2358 | $conversionGroups = array(); |
2359 | - foreach(self::$_conversionUnits as $conversionUnit) { |
|
2359 | + foreach (self::$_conversionUnits as $conversionUnit) { |
|
2360 | 2360 | $conversionGroups[] = $conversionUnit['Group']; |
2361 | 2361 | } |
2362 | 2362 | return array_merge(array_unique($conversionGroups)); |
@@ -2370,7 +2370,7 @@ discard block |
||
2370 | 2370 | */ |
2371 | 2371 | public static function getConversionGroupUnits($group = NULL) { |
2372 | 2372 | $conversionGroups = array(); |
2373 | - foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2373 | + foreach (self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2374 | 2374 | if ((is_null($group)) || ($conversionGroup['Group'] == $group)) { |
2375 | 2375 | $conversionGroups[$conversionGroup['Group']][] = $conversionUnit; |
2376 | 2376 | } |
@@ -2386,9 +2386,9 @@ discard block |
||
2386 | 2386 | */ |
2387 | 2387 | public static function getConversionGroupUnitDetails($group = NULL) { |
2388 | 2388 | $conversionGroups = array(); |
2389 | - foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2389 | + foreach (self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2390 | 2390 | if ((is_null($group)) || ($conversionGroup['Group'] == $group)) { |
2391 | - $conversionGroups[$conversionGroup['Group']][] = array( 'unit' => $conversionUnit, |
|
2391 | + $conversionGroups[$conversionGroup['Group']][] = array('unit' => $conversionUnit, |
|
2392 | 2392 | 'description' => $conversionGroup['Unit Name'] |
2393 | 2393 | ); |
2394 | 2394 | } |
@@ -2424,18 +2424,18 @@ discard block |
||
2424 | 2424 | */ |
2425 | 2425 | public static function CONVERTUOM($value, $fromUOM, $toUOM) { |
2426 | 2426 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
2427 | - $fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM); |
|
2427 | + $fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM); |
|
2428 | 2428 | $toUOM = PHPExcel_Calculation_Functions::flattenSingleValue($toUOM); |
2429 | 2429 | |
2430 | - if (!is_numeric($value)) { |
|
2430 | + if ( ! is_numeric($value)) { |
|
2431 | 2431 | return PHPExcel_Calculation_Functions::VALUE(); |
2432 | 2432 | } |
2433 | 2433 | $fromMultiplier = 1.0; |
2434 | 2434 | if (isset(self::$_conversionUnits[$fromUOM])) { |
2435 | 2435 | $unitGroup1 = self::$_conversionUnits[$fromUOM]['Group']; |
2436 | 2436 | } else { |
2437 | - $fromMultiplier = substr($fromUOM,0,1); |
|
2438 | - $fromUOM = substr($fromUOM,1); |
|
2437 | + $fromMultiplier = substr($fromUOM, 0, 1); |
|
2438 | + $fromUOM = substr($fromUOM, 1); |
|
2439 | 2439 | if (isset(self::$_conversionMultipliers[$fromMultiplier])) { |
2440 | 2440 | $fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier']; |
2441 | 2441 | } else { |
@@ -2453,8 +2453,8 @@ discard block |
||
2453 | 2453 | if (isset(self::$_conversionUnits[$toUOM])) { |
2454 | 2454 | $unitGroup2 = self::$_conversionUnits[$toUOM]['Group']; |
2455 | 2455 | } else { |
2456 | - $toMultiplier = substr($toUOM,0,1); |
|
2457 | - $toUOM = substr($toUOM,1); |
|
2456 | + $toMultiplier = substr($toUOM, 0, 1); |
|
2457 | + $toUOM = substr($toUOM, 1); |
|
2458 | 2458 | if (isset(self::$_conversionMultipliers[$toMultiplier])) { |
2459 | 2459 | $toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier']; |
2460 | 2460 | } else { |
@@ -749,10 +749,18 @@ discard block |
||
749 | 749 | * @return string The "cleaned" complex number |
750 | 750 | */ |
751 | 751 | private static function _cleanComplex($complexNumber) { |
752 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
753 | - if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1); |
|
754 | - if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber; |
|
755 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
752 | + if ($complexNumber{0} == '+') { |
|
753 | + $complexNumber = substr($complexNumber,1); |
|
754 | + } |
|
755 | + if ($complexNumber{0} == '0') { |
|
756 | + $complexNumber = substr($complexNumber,1); |
|
757 | + } |
|
758 | + if ($complexNumber{0} == '.') { |
|
759 | + $complexNumber = '0'.$complexNumber; |
|
760 | + } |
|
761 | + if ($complexNumber{0} == '+') { |
|
762 | + $complexNumber = substr($complexNumber,1); |
|
763 | + } |
|
756 | 764 | return $complexNumber; |
757 | 765 | } |
758 | 766 | |
@@ -1658,7 +1666,9 @@ discard block |
||
1658 | 1666 | $realNumber = (float) $realNumber; |
1659 | 1667 | $imaginary = (float) $imaginary; |
1660 | 1668 | |
1661 | - if ($suffix == '') $suffix = 'i'; |
|
1669 | + if ($suffix == '') { |
|
1670 | + $suffix = 'i'; |
|
1671 | + } |
|
1662 | 1672 | if ($realNumber == 0.0) { |
1663 | 1673 | if ($imaginary == 0.0) { |
1664 | 1674 | return (string) '0'; |
@@ -80,6 +80,10 @@ discard block |
||
80 | 80 | } // function _firstDayOfMonth() |
81 | 81 | |
82 | 82 | |
83 | + /** |
|
84 | + * @param integer $frequency |
|
85 | + * @param boolean $next |
|
86 | + */ |
|
83 | 87 | private static function _coupFirstPeriodDate($settlement, $maturity, $frequency, $next) |
84 | 88 | { |
85 | 89 | $months = 12 / $frequency; |
@@ -102,6 +106,9 @@ discard block |
||
102 | 106 | } // function _coupFirstPeriodDate() |
103 | 107 | |
104 | 108 | |
109 | + /** |
|
110 | + * @param integer $frequency |
|
111 | + */ |
|
105 | 112 | private static function _validFrequency($frequency) |
106 | 113 | { |
107 | 114 | if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) { |
@@ -179,7 +186,7 @@ discard block |
||
179 | 186 | * The security settlement date is the date after the issue date |
180 | 187 | * when the security is traded to the buyer. |
181 | 188 | * @param float $rate The security's annual coupon rate. |
182 | - * @param float $par The security's par value. |
|
189 | + * @param integer $par The security's par value. |
|
183 | 190 | * If you omit par, ACCRINT uses $1,000. |
184 | 191 | * @param integer $frequency the number of coupon payments per year. |
185 | 192 | * Valid frequency values are: |
@@ -446,6 +453,7 @@ discard block |
||
446 | 453 | * 2 Actual/360 |
447 | 454 | * 3 Actual/365 |
448 | 455 | * 4 European 30/360 |
456 | + * @param integer $frequency |
|
449 | 457 | * @return float |
450 | 458 | */ |
451 | 459 | public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) { |
@@ -504,6 +512,7 @@ discard block |
||
504 | 512 | * 2 Actual/360 |
505 | 513 | * 3 Actual/365 |
506 | 514 | * 4 European 30/360 |
515 | + * @param integer $frequency |
|
507 | 516 | * @return float |
508 | 517 | */ |
509 | 518 | public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) { |
@@ -574,6 +583,7 @@ discard block |
||
574 | 583 | * 2 Actual/360 |
575 | 584 | * 3 Actual/365 |
576 | 585 | * 4 European 30/360 |
586 | + * @param integer $frequency |
|
577 | 587 | * @return float |
578 | 588 | */ |
579 | 589 | public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) { |
@@ -689,6 +699,7 @@ discard block |
||
689 | 699 | * 2 Actual/360 |
690 | 700 | * 3 Actual/365 |
691 | 701 | * 4 European 30/360 |
702 | + * @param integer $frequency |
|
692 | 703 | * @return integer |
693 | 704 | */ |
694 | 705 | public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) { |
@@ -1143,7 +1154,7 @@ discard block |
||
1143 | 1154 | * |
1144 | 1155 | * @access public |
1145 | 1156 | * @category Financial Functions |
1146 | - * @param float $nominal_rate Nominal interest rate |
|
1157 | + * @param integer $nominal_rate Nominal interest rate |
|
1147 | 1158 | * @param integer $npery Number of compounding payments per year |
1148 | 1159 | * @return float |
1149 | 1160 | */ |
@@ -1170,12 +1181,12 @@ discard block |
||
1170 | 1181 | * |
1171 | 1182 | * @access public |
1172 | 1183 | * @category Financial Functions |
1173 | - * @param float $rate The interest rate per period |
|
1184 | + * @param integer $rate The interest rate per period |
|
1174 | 1185 | * @param int $nper Total number of payment periods in an annuity |
1175 | - * @param float $pmt The payment made each period: it cannot change over the |
|
1186 | + * @param integer $pmt The payment made each period: it cannot change over the |
|
1176 | 1187 | * life of the annuity. Typically, pmt contains principal |
1177 | 1188 | * and interest but no other fees or taxes. |
1178 | - * @param float $pv Present Value, or the lump-sum amount that a series of |
|
1189 | + * @param integer $pv Present Value, or the lump-sum amount that a series of |
|
1179 | 1190 | * future payments is worth right now. |
1180 | 1191 | * @param integer $type A number 0 or 1 and indicates when payments are due: |
1181 | 1192 | * 0 or omitted At the end of the period. |
@@ -1277,7 +1288,7 @@ discard block |
||
1277 | 1288 | * @param int $per Period for which we want to find the interest |
1278 | 1289 | * @param int $nper Number of periods |
1279 | 1290 | * @param float $pv Present Value |
1280 | - * @param float $fv Future Value |
|
1291 | + * @param integer $fv Future Value |
|
1281 | 1292 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1282 | 1293 | * @return float |
1283 | 1294 | */ |
@@ -1419,7 +1430,7 @@ discard block |
||
1419 | 1430 | * |
1420 | 1431 | * Returns the nominal interest rate given the effective rate and the number of compounding payments per year. |
1421 | 1432 | * |
1422 | - * @param float $effect_rate Effective interest rate |
|
1433 | + * @param integer $effect_rate Effective interest rate |
|
1423 | 1434 | * @param int $npery Number of compounding payments per year |
1424 | 1435 | * @return float |
1425 | 1436 | */ |
@@ -1442,10 +1453,10 @@ discard block |
||
1442 | 1453 | * |
1443 | 1454 | * Returns the number of periods for a cash flow with constant periodic payments (annuities), and interest rate. |
1444 | 1455 | * |
1445 | - * @param float $rate Interest rate per period |
|
1456 | + * @param integer $rate Interest rate per period |
|
1446 | 1457 | * @param int $pmt Periodic payment (annuity) |
1447 | - * @param float $pv Present Value |
|
1448 | - * @param float $fv Future Value |
|
1458 | + * @param integer $pv Present Value |
|
1459 | + * @param integer $fv Future Value |
|
1449 | 1460 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1450 | 1461 | * @return float |
1451 | 1462 | */ |
@@ -1511,10 +1522,10 @@ discard block |
||
1511 | 1522 | * |
1512 | 1523 | * Returns the constant payment (annuity) for a cash flow with a constant interest rate. |
1513 | 1524 | * |
1514 | - * @param float $rate Interest rate per period |
|
1525 | + * @param integer $rate Interest rate per period |
|
1515 | 1526 | * @param int $nper Number of periods |
1516 | - * @param float $pv Present Value |
|
1517 | - * @param float $fv Future Value |
|
1527 | + * @param integer $pv Present Value |
|
1528 | + * @param integer $fv Future Value |
|
1518 | 1529 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1519 | 1530 | * @return float |
1520 | 1531 | */ |
@@ -1548,7 +1559,7 @@ discard block |
||
1548 | 1559 | * @param int $per Period for which we want to find the interest |
1549 | 1560 | * @param int $nper Number of periods |
1550 | 1561 | * @param float $pv Present Value |
1551 | - * @param float $fv Future Value |
|
1562 | + * @param integer $fv Future Value |
|
1552 | 1563 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1553 | 1564 | * @return float |
1554 | 1565 | */ |
@@ -1727,10 +1738,10 @@ discard block |
||
1727 | 1738 | * |
1728 | 1739 | * Returns the Present Value of a cash flow with constant payments and interest rate (annuities). |
1729 | 1740 | * |
1730 | - * @param float $rate Interest rate per period |
|
1741 | + * @param integer $rate Interest rate per period |
|
1731 | 1742 | * @param int $nper Number of periods |
1732 | - * @param float $pmt Periodic payment (annuity) |
|
1733 | - * @param float $fv Future Value |
|
1743 | + * @param integer $pmt Periodic payment (annuity) |
|
1744 | + * @param integer $fv Future Value |
|
1734 | 1745 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1735 | 1746 | * @return float |
1736 | 1747 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * 4 European 360 |
130 | 130 | * @return integer |
131 | 131 | */ |
132 | - private static function _daysPerYear($year, $basis=0) |
|
132 | + private static function _daysPerYear($year, $basis = 0) |
|
133 | 133 | { |
134 | 134 | switch ($basis) { |
135 | 135 | case 0 : |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | } // function _daysPerYear() |
151 | 151 | |
152 | 152 | |
153 | - private static function _interestAndPrincipal($rate=0, $per=0, $nper=0, $pv=0, $fv=0, $type=0) |
|
153 | + private static function _interestAndPrincipal($rate = 0, $per = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) |
|
154 | 154 | { |
155 | 155 | $pmt = self::PMT($rate, $nper, $pv, $fv, $type); |
156 | 156 | $capital = $pv; |
157 | - for ($i = 1; $i<= $per; ++$i) { |
|
157 | + for ($i = 1; $i <= $per; ++$i) { |
|
158 | 158 | $interest = ($type && $i == 1) ? 0 : -$capital * $rate; |
159 | 159 | $principal = $pmt - $interest; |
160 | 160 | $capital += $principal; |
@@ -198,25 +198,25 @@ discard block |
||
198 | 198 | * 4 European 30/360 |
199 | 199 | * @return float |
200 | 200 | */ |
201 | - public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par=1000, $frequency=1, $basis=0) |
|
201 | + public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par = 1000, $frequency = 1, $basis = 0) |
|
202 | 202 | { |
203 | - $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
204 | - $firstinterest = PHPExcel_Calculation_Functions::flattenSingleValue($firstinterest); |
|
205 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
206 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
207 | - $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
208 | - $frequency = (is_null($frequency)) ? 1 : PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
209 | - $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
203 | + $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
204 | + $firstinterest = PHPExcel_Calculation_Functions::flattenSingleValue($firstinterest); |
|
205 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
206 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
207 | + $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
208 | + $frequency = (is_null($frequency)) ? 1 : PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
209 | + $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
210 | 210 | |
211 | 211 | // Validate |
212 | 212 | if ((is_numeric($rate)) && (is_numeric($par))) { |
213 | - $rate = (float) $rate; |
|
214 | - $par = (float) $par; |
|
213 | + $rate = (float) $rate; |
|
214 | + $par = (float) $par; |
|
215 | 215 | if (($rate <= 0) || ($par <= 0)) { |
216 | 216 | return PHPExcel_Calculation_Functions::NaN(); |
217 | 217 | } |
218 | 218 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
219 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
219 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
220 | 220 | // return date error |
221 | 221 | return $daysBetweenIssueAndSettlement; |
222 | 222 | } |
@@ -250,22 +250,22 @@ discard block |
||
250 | 250 | * 4 European 30/360 |
251 | 251 | * @return float |
252 | 252 | */ |
253 | - public static function ACCRINTM($issue, $settlement, $rate, $par=1000, $basis=0) { |
|
254 | - $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
255 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
256 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
257 | - $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
258 | - $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
253 | + public static function ACCRINTM($issue, $settlement, $rate, $par = 1000, $basis = 0) { |
|
254 | + $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
255 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
256 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
257 | + $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
258 | + $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
259 | 259 | |
260 | 260 | // Validate |
261 | 261 | if ((is_numeric($rate)) && (is_numeric($par))) { |
262 | - $rate = (float) $rate; |
|
263 | - $par = (float) $par; |
|
262 | + $rate = (float) $rate; |
|
263 | + $par = (float) $par; |
|
264 | 264 | if (($rate <= 0) || ($par <= 0)) { |
265 | 265 | return PHPExcel_Calculation_Functions::NaN(); |
266 | 266 | } |
267 | 267 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
268 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
268 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
269 | 269 | // return date error |
270 | 270 | return $daysBetweenIssueAndSettlement; |
271 | 271 | } |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | * 4 European 30/360 |
307 | 307 | * @return float |
308 | 308 | */ |
309 | - public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) { |
|
310 | - $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
311 | - $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
312 | - $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
309 | + public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) { |
|
310 | + $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
311 | + $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
312 | + $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
313 | 313 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
314 | 314 | $period = floor(PHPExcel_Calculation_Functions::flattenSingleValue($period)); |
315 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
316 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
315 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
316 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
317 | 317 | |
318 | 318 | // The depreciation coefficients are: |
319 | 319 | // Life of assets (1/rate) Depreciation coefficient |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | $rate *= $amortiseCoeff; |
336 | - $fNRate = round(PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost,0); |
|
336 | + $fNRate = round(PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost, 0); |
|
337 | 337 | $cost -= $fNRate; |
338 | 338 | $fRest = $cost - $salvage; |
339 | 339 | |
340 | 340 | for ($n = 0; $n < $period; ++$n) { |
341 | - $fNRate = round($rate * $cost,0); |
|
341 | + $fNRate = round($rate * $cost, 0); |
|
342 | 342 | $fRest -= $fNRate; |
343 | 343 | |
344 | 344 | if ($fRest < 0.0) { |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | * 4 European 30/360 |
383 | 383 | * @return float |
384 | 384 | */ |
385 | - public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) { |
|
386 | - $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
387 | - $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
388 | - $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
385 | + public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) { |
|
386 | + $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
387 | + $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
388 | + $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
389 | 389 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
390 | 390 | $period = PHPExcel_Calculation_Functions::flattenSingleValue($period); |
391 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
392 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
391 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
392 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
393 | 393 | |
394 | 394 | $fOneRate = $cost * $rate; |
395 | 395 | $fCostDelta = $cost - $salvage; |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | * 4 European 30/360 |
449 | 449 | * @return float |
450 | 450 | */ |
451 | - public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) { |
|
452 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
453 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
454 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
455 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
451 | + public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = 0) { |
|
452 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
453 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
454 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
455 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
456 | 456 | |
457 | 457 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
458 | 458 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | if (($settlement > $maturity) || |
465 | - (!self::_validFrequency($frequency)) || |
|
465 | + ( ! self::_validFrequency($frequency)) || |
|
466 | 466 | (($basis < 0) || ($basis > 4))) { |
467 | 467 | return PHPExcel_Calculation_Functions::NaN(); |
468 | 468 | } |
469 | 469 | |
470 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
470 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
471 | 471 | $prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False); |
472 | 472 | |
473 | 473 | return PHPExcel_Calculation_DateTime::YEARFRAC($prev, $settlement, $basis) * $daysPerYear; |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | * 4 European 30/360 |
507 | 507 | * @return float |
508 | 508 | */ |
509 | - public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) { |
|
510 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
511 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
512 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
513 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
509 | + public static function COUPDAYS($settlement, $maturity, $frequency, $basis = 0) { |
|
510 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
511 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
512 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
513 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
514 | 514 | |
515 | 515 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
516 | 516 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | if (($settlement > $maturity) || |
523 | - (!self::_validFrequency($frequency)) || |
|
523 | + ( ! self::_validFrequency($frequency)) || |
|
524 | 524 | (($basis < 0) || ($basis > 4))) { |
525 | 525 | return PHPExcel_Calculation_Functions::NaN(); |
526 | 526 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | return 365 / $frequency; |
531 | 531 | case 1: // Actual/actual |
532 | 532 | if ($frequency == 1) { |
533 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($maturity),$basis); |
|
533 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($maturity), $basis); |
|
534 | 534 | return ($daysPerYear / $frequency); |
535 | 535 | } else { |
536 | 536 | $prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False); |
@@ -576,11 +576,11 @@ discard block |
||
576 | 576 | * 4 European 30/360 |
577 | 577 | * @return float |
578 | 578 | */ |
579 | - public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) { |
|
580 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
581 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
582 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
583 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
579 | + public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = 0) { |
|
580 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
581 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
582 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
583 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
584 | 584 | |
585 | 585 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
586 | 586 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | } |
591 | 591 | |
592 | 592 | if (($settlement > $maturity) || |
593 | - (!self::_validFrequency($frequency)) || |
|
593 | + ( ! self::_validFrequency($frequency)) || |
|
594 | 594 | (($basis < 0) || ($basis > 4))) { |
595 | 595 | return PHPExcel_Calculation_Functions::NaN(); |
596 | 596 | } |
597 | 597 | |
598 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
598 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
599 | 599 | $next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True); |
600 | 600 | |
601 | 601 | return PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $next, $basis) * $daysPerYear; |
@@ -635,11 +635,11 @@ discard block |
||
635 | 635 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
636 | 636 | * depending on the value of the ReturnDateType flag |
637 | 637 | */ |
638 | - public static function COUPNCD($settlement, $maturity, $frequency, $basis=0) { |
|
639 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
640 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
641 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
642 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
638 | + public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0) { |
|
639 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
640 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
641 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
642 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
643 | 643 | |
644 | 644 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
645 | 645 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | } |
650 | 650 | |
651 | 651 | if (($settlement > $maturity) || |
652 | - (!self::_validFrequency($frequency)) || |
|
652 | + ( ! self::_validFrequency($frequency)) || |
|
653 | 653 | (($basis < 0) || ($basis > 4))) { |
654 | 654 | return PHPExcel_Calculation_Functions::NaN(); |
655 | 655 | } |
@@ -691,11 +691,11 @@ discard block |
||
691 | 691 | * 4 European 30/360 |
692 | 692 | * @return integer |
693 | 693 | */ |
694 | - public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) { |
|
695 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
696 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
697 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
698 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
694 | + public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0) { |
|
695 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
696 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
697 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
698 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
699 | 699 | |
700 | 700 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
701 | 701 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | if (($settlement > $maturity) || |
708 | - (!self::_validFrequency($frequency)) || |
|
708 | + ( ! self::_validFrequency($frequency)) || |
|
709 | 709 | (($basis < 0) || ($basis > 4))) { |
710 | 710 | return PHPExcel_Calculation_Functions::NaN(); |
711 | 711 | } |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
763 | 763 | * depending on the value of the ReturnDateType flag |
764 | 764 | */ |
765 | - public static function COUPPCD($settlement, $maturity, $frequency, $basis=0) { |
|
766 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
767 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
768 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
769 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
765 | + public static function COUPPCD($settlement, $maturity, $frequency, $basis = 0) { |
|
766 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
767 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
768 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
769 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
770 | 770 | |
771 | 771 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
772 | 772 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | if (($settlement > $maturity) || |
779 | - (!self::_validFrequency($frequency)) || |
|
779 | + ( ! self::_validFrequency($frequency)) || |
|
780 | 780 | (($basis < 0) || ($basis > 4))) { |
781 | 781 | return PHPExcel_Calculation_Functions::NaN(); |
782 | 782 | } |
@@ -810,9 +810,9 @@ discard block |
||
810 | 810 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
811 | 811 | $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
812 | 812 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
813 | - $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
813 | + $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
814 | 814 | $end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end); |
815 | - $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
815 | + $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
816 | 816 | |
817 | 817 | // Validate parameters |
818 | 818 | if ($type != 0 && $type != 1) { |
@@ -857,9 +857,9 @@ discard block |
||
857 | 857 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
858 | 858 | $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
859 | 859 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
860 | - $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
860 | + $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
861 | 861 | $end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end); |
862 | - $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
862 | + $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
863 | 863 | |
864 | 864 | // Validate parameters |
865 | 865 | if ($type != 0 && $type != 1) { |
@@ -905,12 +905,12 @@ discard block |
||
905 | 905 | * it defaults to 12. |
906 | 906 | * @return float |
907 | 907 | */ |
908 | - public static function DB($cost, $salvage, $life, $period, $month=12) { |
|
908 | + public static function DB($cost, $salvage, $life, $period, $month = 12) { |
|
909 | 909 | $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
910 | 910 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
911 | 911 | $life = PHPExcel_Calculation_Functions::flattenSingleValue($life); |
912 | 912 | $period = PHPExcel_Calculation_Functions::flattenSingleValue($period); |
913 | - $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); |
|
913 | + $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); |
|
914 | 914 | |
915 | 915 | // Validate |
916 | 916 | if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($month))) { |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | $salvage = (float) $salvage; |
919 | 919 | $life = (int) $life; |
920 | 920 | $period = (int) $period; |
921 | - $month = (int) $month; |
|
921 | + $month = (int) $month; |
|
922 | 922 | if ($cost == 0) { |
923 | 923 | return 0.0; |
924 | 924 | } elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) { |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | $previousDepreciation += $depreciation; |
942 | 942 | } |
943 | 943 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
944 | - $depreciation = round($depreciation,2); |
|
944 | + $depreciation = round($depreciation, 2); |
|
945 | 945 | } |
946 | 946 | return $depreciation; |
947 | 947 | } |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | * double-declining balance method). |
973 | 973 | * @return float |
974 | 974 | */ |
975 | - public static function DDB($cost, $salvage, $life, $period, $factor=2.0) { |
|
975 | + public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) { |
|
976 | 976 | $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
977 | 977 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
978 | 978 | $life = PHPExcel_Calculation_Functions::flattenSingleValue($life); |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | // Loop through each period calculating the depreciation |
997 | 997 | $previousDepreciation = 0; |
998 | 998 | for ($per = 1; $per <= $period; ++$per) { |
999 | - $depreciation = min( ($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation) ); |
|
999 | + $depreciation = min(($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation)); |
|
1000 | 1000 | $previousDepreciation += $depreciation; |
1001 | 1001 | } |
1002 | 1002 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
1003 | - $depreciation = round($depreciation,2); |
|
1003 | + $depreciation = round($depreciation, 2); |
|
1004 | 1004 | } |
1005 | 1005 | return $depreciation; |
1006 | 1006 | } |
@@ -1033,9 +1033,9 @@ discard block |
||
1033 | 1033 | * 4 European 30/360 |
1034 | 1034 | * @return float |
1035 | 1035 | */ |
1036 | - public static function DISC($settlement, $maturity, $price, $redemption, $basis=0) { |
|
1036 | + public static function DISC($settlement, $maturity, $price, $redemption, $basis = 0) { |
|
1037 | 1037 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1038 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1038 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1039 | 1039 | $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
1040 | 1040 | $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
1041 | 1041 | $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
@@ -1043,13 +1043,13 @@ discard block |
||
1043 | 1043 | // Validate |
1044 | 1044 | if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) { |
1045 | 1045 | $price = (float) $price; |
1046 | - $redemption = (float) $redemption; |
|
1046 | + $redemption = (float) $redemption; |
|
1047 | 1047 | $basis = (int) $basis; |
1048 | 1048 | if (($price <= 0) || ($redemption <= 0)) { |
1049 | 1049 | return PHPExcel_Calculation_Functions::NaN(); |
1050 | 1050 | } |
1051 | 1051 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1052 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1052 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1053 | 1053 | // return date error |
1054 | 1054 | return $daysBetweenSettlementAndMaturity; |
1055 | 1055 | } |
@@ -1077,8 +1077,8 @@ discard block |
||
1077 | 1077 | * @return float |
1078 | 1078 | */ |
1079 | 1079 | public static function DOLLARDE($fractional_dollar = Null, $fraction = 0) { |
1080 | - $fractional_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($fractional_dollar); |
|
1081 | - $fraction = (int)PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1080 | + $fractional_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($fractional_dollar); |
|
1081 | + $fraction = (int) PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1082 | 1082 | |
1083 | 1083 | // Validate parameters |
1084 | 1084 | if (is_null($fractional_dollar) || $fraction < 0) { |
@@ -1089,9 +1089,9 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | $dollars = floor($fractional_dollar); |
1092 | - $cents = fmod($fractional_dollar,1); |
|
1092 | + $cents = fmod($fractional_dollar, 1); |
|
1093 | 1093 | $cents /= $fraction; |
1094 | - $cents *= pow(10,ceil(log10($fraction))); |
|
1094 | + $cents *= pow(10, ceil(log10($fraction))); |
|
1095 | 1095 | return $dollars + $cents; |
1096 | 1096 | } // function DOLLARDE() |
1097 | 1097 | |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | * @return float |
1114 | 1114 | */ |
1115 | 1115 | public static function DOLLARFR($decimal_dollar = Null, $fraction = 0) { |
1116 | - $decimal_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($decimal_dollar); |
|
1117 | - $fraction = (int)PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1116 | + $decimal_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($decimal_dollar); |
|
1117 | + $fraction = (int) PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1118 | 1118 | |
1119 | 1119 | // Validate parameters |
1120 | 1120 | if (is_null($decimal_dollar) || $fraction < 0) { |
@@ -1125,9 +1125,9 @@ discard block |
||
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | $dollars = floor($decimal_dollar); |
1128 | - $cents = fmod($decimal_dollar,1); |
|
1128 | + $cents = fmod($decimal_dollar, 1); |
|
1129 | 1129 | $cents *= $fraction; |
1130 | - $cents *= pow(10,-ceil(log10($fraction))); |
|
1130 | + $cents *= pow(10, -ceil(log10($fraction))); |
|
1131 | 1131 | return $dollars + $cents; |
1132 | 1132 | } // function DOLLARFR() |
1133 | 1133 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | * @return float |
1149 | 1149 | */ |
1150 | 1150 | public static function EFFECT($nominal_rate = 0, $npery = 0) { |
1151 | - $nominal_rate = PHPExcel_Calculation_Functions::flattenSingleValue($nominal_rate); |
|
1152 | - $npery = (int)PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1151 | + $nominal_rate = PHPExcel_Calculation_Functions::flattenSingleValue($nominal_rate); |
|
1152 | + $npery = (int) PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1153 | 1153 | |
1154 | 1154 | // Validate parameters |
1155 | 1155 | if ($nominal_rate <= 0 || $npery < 1) { |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // Calculate |
1198 | - if (!is_null($rate) && $rate != 0) { |
|
1198 | + if ( ! is_null($rate) && $rate != 0) { |
|
1199 | 1199 | return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate; |
1200 | 1200 | } else { |
1201 | 1201 | return -$pv - $pmt * $nper; |
@@ -1208,10 +1208,10 @@ discard block |
||
1208 | 1208 | * |
1209 | 1209 | */ |
1210 | 1210 | public static function FVSCHEDULE($principal, $schedule) { |
1211 | - $principal = PHPExcel_Calculation_Functions::flattenSingleValue($principal); |
|
1212 | - $schedule = PHPExcel_Calculation_Functions::flattenArray($schedule); |
|
1211 | + $principal = PHPExcel_Calculation_Functions::flattenSingleValue($principal); |
|
1212 | + $schedule = PHPExcel_Calculation_Functions::flattenArray($schedule); |
|
1213 | 1213 | |
1214 | - foreach($schedule as $n) { |
|
1214 | + foreach ($schedule as $n) { |
|
1215 | 1215 | $principal *= 1 + $n; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1241,23 +1241,23 @@ discard block |
||
1241 | 1241 | * 4 European 30/360 |
1242 | 1242 | * @return float |
1243 | 1243 | */ |
1244 | - public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis=0) { |
|
1244 | + public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis = 0) { |
|
1245 | 1245 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1246 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1246 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1247 | 1247 | $investment = PHPExcel_Calculation_Functions::flattenSingleValue($investment); |
1248 | 1248 | $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
1249 | - $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1249 | + $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1250 | 1250 | |
1251 | 1251 | // Validate |
1252 | 1252 | if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) { |
1253 | 1253 | $investment = (float) $investment; |
1254 | 1254 | $redemption = (float) $redemption; |
1255 | - $basis = (int) $basis; |
|
1255 | + $basis = (int) $basis; |
|
1256 | 1256 | if (($investment <= 0) || ($redemption <= 0)) { |
1257 | 1257 | return PHPExcel_Calculation_Functions::NaN(); |
1258 | 1258 | } |
1259 | 1259 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1260 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1260 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1261 | 1261 | // return date error |
1262 | 1262 | return $daysBetweenSettlementAndMaturity; |
1263 | 1263 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | |
1305 | 1305 | |
1306 | 1306 | public static function IRR($values, $guess = 0.1) { |
1307 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1307 | + if ( ! is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1308 | 1308 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
1309 | 1309 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
1310 | 1310 | |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | $dx = $x1 - $x2; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
1335 | + for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
1336 | 1336 | $dx *= 0.5; |
1337 | 1337 | $x_mid = $rtb + $dx; |
1338 | 1338 | $f_mid = self::NPV($x_mid, $values); |
@@ -1372,11 +1372,11 @@ discard block |
||
1372 | 1372 | |
1373 | 1373 | // Calculate |
1374 | 1374 | $principlePayment = ($principleRemaining * 1.0) / ($numberPeriods * 1.0); |
1375 | - for($i=0; $i <= $period; ++$i) { |
|
1375 | + for ($i = 0; $i <= $period; ++$i) { |
|
1376 | 1376 | $returnValue = $interestRate * $principleRemaining * -1; |
1377 | 1377 | $principleRemaining -= $principlePayment; |
1378 | 1378 | // principle needs to be 0 after the last payment, don't let floating point screw it up |
1379 | - if($i == $numberPeriods) { |
|
1379 | + if ($i == $numberPeriods) { |
|
1380 | 1380 | $returnValue = 0; |
1381 | 1381 | } |
1382 | 1382 | } |
@@ -1385,17 +1385,17 @@ discard block |
||
1385 | 1385 | |
1386 | 1386 | |
1387 | 1387 | public static function MIRR($values, $finance_rate, $reinvestment_rate) { |
1388 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1389 | - $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
1390 | - $finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate); |
|
1391 | - $reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate); |
|
1388 | + if ( ! is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1389 | + $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
1390 | + $finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate); |
|
1391 | + $reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate); |
|
1392 | 1392 | $n = count($values); |
1393 | 1393 | |
1394 | 1394 | $rr = 1.0 + $reinvestment_rate; |
1395 | 1395 | $fr = 1.0 + $finance_rate; |
1396 | 1396 | |
1397 | 1397 | $npv_pos = $npv_neg = 0.0; |
1398 | - foreach($values as $i => $v) { |
|
1398 | + foreach ($values as $i => $v) { |
|
1399 | 1399 | if ($v >= 0) { |
1400 | 1400 | $npv_pos += $v / pow($rr, $i); |
1401 | 1401 | } else { |
@@ -1424,8 +1424,8 @@ discard block |
||
1424 | 1424 | * @return float |
1425 | 1425 | */ |
1426 | 1426 | public static function NOMINAL($effect_rate = 0, $npery = 0) { |
1427 | - $effect_rate = PHPExcel_Calculation_Functions::flattenSingleValue($effect_rate); |
|
1428 | - $npery = (int)PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1427 | + $effect_rate = PHPExcel_Calculation_Functions::flattenSingleValue($effect_rate); |
|
1428 | + $npery = (int) PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1429 | 1429 | |
1430 | 1430 | // Validate parameters |
1431 | 1431 | if ($effect_rate <= 0 || $npery < 1) { |
@@ -1450,11 +1450,11 @@ discard block |
||
1450 | 1450 | * @return float |
1451 | 1451 | */ |
1452 | 1452 | public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) { |
1453 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1453 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1454 | 1454 | $pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt); |
1455 | 1455 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
1456 | 1456 | $fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv); |
1457 | - $type = PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1457 | + $type = PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1458 | 1458 | |
1459 | 1459 | // Validate parameters |
1460 | 1460 | if ($type != 0 && $type != 1) { |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | // Calculate |
1465 | - if (!is_null($rate) && $rate != 0) { |
|
1465 | + if ( ! is_null($rate) && $rate != 0) { |
|
1466 | 1466 | if ($pmt == 0 && $pv == 0) { |
1467 | 1467 | return PHPExcel_Calculation_Functions::NaN(); |
1468 | 1468 | } |
@@ -1471,7 +1471,7 @@ discard block |
||
1471 | 1471 | if ($pmt == 0) { |
1472 | 1472 | return PHPExcel_Calculation_Functions::NaN(); |
1473 | 1473 | } |
1474 | - return (-$pv -$fv) / $pmt; |
|
1474 | + return (-$pv - $fv) / $pmt; |
|
1475 | 1475 | } |
1476 | 1476 | } // function NPER() |
1477 | 1477 | |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | // Calculate |
1534 | - if (!is_null($rate) && $rate != 0) { |
|
1534 | + if ( ! is_null($rate) && $rate != 0) { |
|
1535 | 1535 | return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate); |
1536 | 1536 | } else { |
1537 | 1537 | return (-$pv - $fv) / $nper; |
@@ -1574,14 +1574,14 @@ discard block |
||
1574 | 1574 | } // function PPMT() |
1575 | 1575 | |
1576 | 1576 | |
1577 | - public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis=0) { |
|
1578 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1579 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1580 | - $rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1577 | + public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0) { |
|
1578 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1579 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1580 | + $rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1581 | 1581 | $yield = (float) PHPExcel_Calculation_Functions::flattenSingleValue($yield); |
1582 | - $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
|
1583 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
1584 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1582 | + $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
|
1583 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
1584 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1585 | 1585 | |
1586 | 1586 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
1587 | 1587 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | if (($settlement > $maturity) || |
1594 | - (!self::_validFrequency($frequency)) || |
|
1594 | + ( ! self::_validFrequency($frequency)) || |
|
1595 | 1595 | (($basis < 0) || ($basis > 4))) { |
1596 | 1596 | return PHPExcel_Calculation_Functions::NaN(); |
1597 | 1597 | } |
@@ -1601,12 +1601,12 @@ discard block |
||
1601 | 1601 | $n = self::COUPNUM($settlement, $maturity, $frequency, $basis); |
1602 | 1602 | $a = self::COUPDAYBS($settlement, $maturity, $frequency, $basis); |
1603 | 1603 | |
1604 | - $baseYF = 1.0 + ($yield / $frequency); |
|
1605 | - $rfp = 100 * ($rate / $frequency); |
|
1606 | - $de = $dsc / $e; |
|
1604 | + $baseYF = 1.0 + ($yield / $frequency); |
|
1605 | + $rfp = 100 * ($rate / $frequency); |
|
1606 | + $de = $dsc / $e; |
|
1607 | 1607 | |
1608 | 1608 | $result = $redemption / pow($baseYF, (--$n + $de)); |
1609 | - for($k = 0; $k <= $n; ++$k) { |
|
1609 | + for ($k = 0; $k <= $n; ++$k) { |
|
1610 | 1610 | $result += $rfp / (pow($baseYF, ($k + $de))); |
1611 | 1611 | } |
1612 | 1612 | $result -= $rfp * ($a / $e); |
@@ -1634,12 +1634,12 @@ discard block |
||
1634 | 1634 | * 4 European 30/360 |
1635 | 1635 | * @return float |
1636 | 1636 | */ |
1637 | - public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis=0) { |
|
1637 | + public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis = 0) { |
|
1638 | 1638 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1639 | 1639 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1640 | 1640 | $discount = (float) PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1641 | 1641 | $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
1642 | - $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1642 | + $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1643 | 1643 | |
1644 | 1644 | // Validate |
1645 | 1645 | if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) { |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | return PHPExcel_Calculation_Functions::NaN(); |
1648 | 1648 | } |
1649 | 1649 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1650 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1650 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1651 | 1651 | // return date error |
1652 | 1652 | return $daysBetweenSettlementAndMaturity; |
1653 | 1653 | } |
@@ -1678,11 +1678,11 @@ discard block |
||
1678 | 1678 | * 4 European 30/360 |
1679 | 1679 | * @return float |
1680 | 1680 | */ |
1681 | - public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis=0) { |
|
1682 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1683 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1681 | + public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis = 0) { |
|
1682 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1683 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1684 | 1684 | $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
1685 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1685 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1686 | 1686 | $yield = PHPExcel_Calculation_Functions::flattenSingleValue($yield); |
1687 | 1687 | $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
1688 | 1688 | |
@@ -1691,24 +1691,24 @@ discard block |
||
1691 | 1691 | if (($rate <= 0) || ($yield <= 0)) { |
1692 | 1692 | return PHPExcel_Calculation_Functions::NaN(); |
1693 | 1693 | } |
1694 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
1695 | - if (!is_numeric($daysPerYear)) { |
|
1694 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
1695 | + if ( ! is_numeric($daysPerYear)) { |
|
1696 | 1696 | return $daysPerYear; |
1697 | 1697 | } |
1698 | 1698 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
1699 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
1699 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
1700 | 1700 | // return date error |
1701 | 1701 | return $daysBetweenIssueAndSettlement; |
1702 | 1702 | } |
1703 | 1703 | $daysBetweenIssueAndSettlement *= $daysPerYear; |
1704 | 1704 | $daysBetweenIssueAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $maturity, $basis); |
1705 | - if (!is_numeric($daysBetweenIssueAndMaturity)) { |
|
1705 | + if ( ! is_numeric($daysBetweenIssueAndMaturity)) { |
|
1706 | 1706 | // return date error |
1707 | 1707 | return $daysBetweenIssueAndMaturity; |
1708 | 1708 | } |
1709 | 1709 | $daysBetweenIssueAndMaturity *= $daysPerYear; |
1710 | 1710 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1711 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1711 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1712 | 1712 | // return date error |
1713 | 1713 | return $daysBetweenSettlementAndMaturity; |
1714 | 1714 | } |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | // Calculate |
1750 | - if (!is_null($rate) && $rate != 0) { |
|
1750 | + if ( ! is_null($rate) && $rate != 0) { |
|
1751 | 1751 | return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper); |
1752 | 1752 | } else { |
1753 | 1753 | return -$fv - $pmt * $nper; |
@@ -1786,12 +1786,12 @@ discard block |
||
1786 | 1786 | * @return float |
1787 | 1787 | **/ |
1788 | 1788 | public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) { |
1789 | - $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
|
1789 | + $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
|
1790 | 1790 | $pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt); |
1791 | 1791 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
1792 | - $fv = (is_null($fv)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($fv); |
|
1793 | - $type = (is_null($type)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1794 | - $guess = (is_null($guess)) ? 0.1 : PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
|
1792 | + $fv = (is_null($fv)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($fv); |
|
1793 | + $type = (is_null($type)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1794 | + $guess = (is_null($guess)) ? 0.1 : PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
|
1795 | 1795 | |
1796 | 1796 | $rate = $guess; |
1797 | 1797 | if (abs($rate) < FINANCIAL_PRECISION) { |
@@ -1847,12 +1847,12 @@ discard block |
||
1847 | 1847 | * 4 European 30/360 |
1848 | 1848 | * @return float |
1849 | 1849 | */ |
1850 | - public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis=0) { |
|
1850 | + public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis = 0) { |
|
1851 | 1851 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1852 | 1852 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1853 | 1853 | $investment = (float) PHPExcel_Calculation_Functions::flattenSingleValue($investment); |
1854 | 1854 | $discount = (float) PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1855 | - $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1855 | + $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1856 | 1856 | |
1857 | 1857 | // Validate |
1858 | 1858 | if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) { |
@@ -1860,12 +1860,12 @@ discard block |
||
1860 | 1860 | return PHPExcel_Calculation_Functions::NaN(); |
1861 | 1861 | } |
1862 | 1862 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1863 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1863 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1864 | 1864 | // return date error |
1865 | 1865 | return $daysBetweenSettlementAndMaturity; |
1866 | 1866 | } |
1867 | 1867 | |
1868 | - return $investment / ( 1 - ($discount * $daysBetweenSettlementAndMaturity)); |
|
1868 | + return $investment / (1 - ($discount * $daysBetweenSettlementAndMaturity)); |
|
1869 | 1869 | } |
1870 | 1870 | return PHPExcel_Calculation_Functions::VALUE(); |
1871 | 1871 | } // function RECEIVED() |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | */ |
1884 | 1884 | public static function SLN($cost, $salvage, $life) { |
1885 | 1885 | $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
1886 | - $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
|
1886 | + $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
|
1887 | 1887 | $life = PHPExcel_Calculation_Functions::flattenSingleValue($life); |
1888 | 1888 | |
1889 | 1889 | // Calculate |
@@ -1938,7 +1938,7 @@ discard block |
||
1938 | 1938 | * @return float |
1939 | 1939 | */ |
1940 | 1940 | public static function TBILLEQ($settlement, $maturity, $discount) { |
1941 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1941 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1942 | 1942 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1943 | 1943 | $discount = PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1944 | 1944 | |
@@ -1976,7 +1976,7 @@ discard block |
||
1976 | 1976 | * @return float |
1977 | 1977 | */ |
1978 | 1978 | public static function TBILLPRICE($settlement, $maturity, $discount) { |
1979 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1979 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1980 | 1980 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1981 | 1981 | $discount = PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1982 | 1982 | |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
1994 | 1994 | ++$maturity; |
1995 | 1995 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360; |
1996 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1996 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1997 | 1997 | // return date error |
1998 | 1998 | return $daysBetweenSettlementAndMaturity; |
1999 | 1999 | } |
@@ -2028,9 +2028,9 @@ discard block |
||
2028 | 2028 | * @return float |
2029 | 2029 | */ |
2030 | 2030 | public static function TBILLYIELD($settlement, $maturity, $price) { |
2031 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2032 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2033 | - $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
|
2031 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2032 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2033 | + $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
|
2034 | 2034 | |
2035 | 2035 | // Validate |
2036 | 2036 | if (is_numeric($price)) { |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
2042 | 2042 | ++$maturity; |
2043 | 2043 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360; |
2044 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2044 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2045 | 2045 | // return date error |
2046 | 2046 | return $daysBetweenSettlementAndMaturity; |
2047 | 2047 | } |
@@ -2060,8 +2060,8 @@ discard block |
||
2060 | 2060 | |
2061 | 2061 | |
2062 | 2062 | public static function XIRR($values, $dates, $guess = 0.1) { |
2063 | - if ((!is_array($values)) && (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2064 | - $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2063 | + if (( ! is_array($values)) && ( ! is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2064 | + $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2065 | 2065 | $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
2066 | 2066 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
2067 | 2067 | if (count($values) != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
@@ -2090,7 +2090,7 @@ discard block |
||
2090 | 2090 | $dx = $x1 - $x2; |
2091 | 2091 | } |
2092 | 2092 | |
2093 | - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
2093 | + for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
2094 | 2094 | $dx *= 0.5; |
2095 | 2095 | $x_mid = $rtb + $dx; |
2096 | 2096 | $f_mid = self::XNPV($x_mid, $values, $dates); |
@@ -2117,18 +2117,18 @@ discard block |
||
2117 | 2117 | */ |
2118 | 2118 | public static function XNPV($rate, $values, $dates) { |
2119 | 2119 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
2120 | - if (!is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2121 | - if ((!is_array($values)) || (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2122 | - $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2123 | - $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
|
2120 | + if ( ! is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2121 | + if (( ! is_array($values)) || ( ! is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2122 | + $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2123 | + $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
|
2124 | 2124 | $valCount = count($values); |
2125 | 2125 | if ($valCount != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
2126 | 2126 | if ((min($values) > 0) || (max($values) < 0)) return PHPExcel_Calculation_Functions::VALUE(); |
2127 | 2127 | |
2128 | 2128 | $xnpv = 0.0; |
2129 | 2129 | for ($i = 0; $i < $valCount; ++$i) { |
2130 | - if (!is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE(); |
|
2131 | - $xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0],$dates[$i],'d') / 365); |
|
2130 | + if ( ! is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE(); |
|
2131 | + $xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0], $dates[$i], 'd') / 365); |
|
2132 | 2132 | } |
2133 | 2133 | return (is_finite($xnpv)) ? $xnpv : PHPExcel_Calculation_Functions::VALUE(); |
2134 | 2134 | } // function XNPV() |
@@ -2153,9 +2153,9 @@ discard block |
||
2153 | 2153 | * 4 European 30/360 |
2154 | 2154 | * @return float |
2155 | 2155 | */ |
2156 | - public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis=0) { |
|
2156 | + public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis = 0) { |
|
2157 | 2157 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
2158 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2158 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2159 | 2159 | $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
2160 | 2160 | $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
2161 | 2161 | $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
@@ -2165,12 +2165,12 @@ discard block |
||
2165 | 2165 | if (($price <= 0) || ($redemption <= 0)) { |
2166 | 2166 | return PHPExcel_Calculation_Functions::NaN(); |
2167 | 2167 | } |
2168 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
2169 | - if (!is_numeric($daysPerYear)) { |
|
2168 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
2169 | + if ( ! is_numeric($daysPerYear)) { |
|
2170 | 2170 | return $daysPerYear; |
2171 | 2171 | } |
2172 | - $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity,$basis); |
|
2173 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2172 | + $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
|
2173 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2174 | 2174 | // return date error |
2175 | 2175 | return $daysBetweenSettlementAndMaturity; |
2176 | 2176 | } |
@@ -2202,11 +2202,11 @@ discard block |
||
2202 | 2202 | * 4 European 30/360 |
2203 | 2203 | * @return float |
2204 | 2204 | */ |
2205 | - public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis=0) { |
|
2206 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2207 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2205 | + public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis = 0) { |
|
2206 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2207 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2208 | 2208 | $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
2209 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
2209 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
2210 | 2210 | $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
2211 | 2211 | $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
2212 | 2212 | |
@@ -2215,24 +2215,24 @@ discard block |
||
2215 | 2215 | if (($rate <= 0) || ($price <= 0)) { |
2216 | 2216 | return PHPExcel_Calculation_Functions::NaN(); |
2217 | 2217 | } |
2218 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
2219 | - if (!is_numeric($daysPerYear)) { |
|
2218 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
2219 | + if ( ! is_numeric($daysPerYear)) { |
|
2220 | 2220 | return $daysPerYear; |
2221 | 2221 | } |
2222 | 2222 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
2223 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
2223 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
2224 | 2224 | // return date error |
2225 | 2225 | return $daysBetweenIssueAndSettlement; |
2226 | 2226 | } |
2227 | 2227 | $daysBetweenIssueAndSettlement *= $daysPerYear; |
2228 | 2228 | $daysBetweenIssueAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $maturity, $basis); |
2229 | - if (!is_numeric($daysBetweenIssueAndMaturity)) { |
|
2229 | + if ( ! is_numeric($daysBetweenIssueAndMaturity)) { |
|
2230 | 2230 | // return date error |
2231 | 2231 | return $daysBetweenIssueAndMaturity; |
2232 | 2232 | } |
2233 | 2233 | $daysBetweenIssueAndMaturity *= $daysPerYear; |
2234 | 2234 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
2235 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2235 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2236 | 2236 | // return date error |
2237 | 2237 | return $daysBetweenSettlementAndMaturity; |
2238 | 2238 | } |
@@ -1304,7 +1304,9 @@ discard block |
||
1304 | 1304 | |
1305 | 1305 | |
1306 | 1306 | public static function IRR($values, $guess = 0.1) { |
1307 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1307 | + if (!is_array($values)) { |
|
1308 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
1309 | + } |
|
1308 | 1310 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
1309 | 1311 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
1310 | 1312 | |
@@ -1314,14 +1316,18 @@ discard block |
||
1314 | 1316 | $f1 = self::NPV($x1, $values); |
1315 | 1317 | $f2 = self::NPV($x2, $values); |
1316 | 1318 | for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
1317 | - if (($f1 * $f2) < 0.0) break; |
|
1319 | + if (($f1 * $f2) < 0.0) { |
|
1320 | + break; |
|
1321 | + } |
|
1318 | 1322 | if (abs($f1) < abs($f2)) { |
1319 | 1323 | $f1 = self::NPV($x1 += 1.6 * ($x1 - $x2), $values); |
1320 | 1324 | } else { |
1321 | 1325 | $f2 = self::NPV($x2 += 1.6 * ($x2 - $x1), $values); |
1322 | 1326 | } |
1323 | 1327 | } |
1324 | - if (($f1 * $f2) > 0.0) return PHPExcel_Calculation_Functions::VALUE(); |
|
1328 | + if (($f1 * $f2) > 0.0) { |
|
1329 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
1330 | + } |
|
1325 | 1331 | |
1326 | 1332 | $f = self::NPV($x1, $values); |
1327 | 1333 | if ($f < 0.0) { |
@@ -1336,8 +1342,12 @@ discard block |
||
1336 | 1342 | $dx *= 0.5; |
1337 | 1343 | $x_mid = $rtb + $dx; |
1338 | 1344 | $f_mid = self::NPV($x_mid, $values); |
1339 | - if ($f_mid <= 0.0) $rtb = $x_mid; |
|
1340 | - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid; |
|
1345 | + if ($f_mid <= 0.0) { |
|
1346 | + $rtb = $x_mid; |
|
1347 | + } |
|
1348 | + if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) { |
|
1349 | + return $x_mid; |
|
1350 | + } |
|
1341 | 1351 | } |
1342 | 1352 | return PHPExcel_Calculation_Functions::VALUE(); |
1343 | 1353 | } // function IRR() |
@@ -1385,7 +1395,9 @@ discard block |
||
1385 | 1395 | |
1386 | 1396 | |
1387 | 1397 | public static function MIRR($values, $finance_rate, $reinvestment_rate) { |
1388 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1398 | + if (!is_array($values)) { |
|
1399 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
1400 | + } |
|
1389 | 1401 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
1390 | 1402 | $finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate); |
1391 | 1403 | $reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate); |
@@ -1810,8 +1822,9 @@ discard block |
||
1810 | 1822 | $rate = ($y1 * $x0 - $y0 * $x1) / ($y1 - $y0); |
1811 | 1823 | $x0 = $x1; |
1812 | 1824 | $x1 = $rate; |
1813 | - if (($nper * abs($pmt)) > ($pv - $fv)) |
|
1814 | - $x1 = abs($x1); |
|
1825 | + if (($nper * abs($pmt)) > ($pv - $fv)) { |
|
1826 | + $x1 = abs($x1); |
|
1827 | + } |
|
1815 | 1828 | |
1816 | 1829 | if (abs($rate) < FINANCIAL_PRECISION) { |
1817 | 1830 | $y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv; |
@@ -2060,11 +2073,15 @@ discard block |
||
2060 | 2073 | |
2061 | 2074 | |
2062 | 2075 | public static function XIRR($values, $dates, $guess = 0.1) { |
2063 | - if ((!is_array($values)) && (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2076 | + if ((!is_array($values)) && (!is_array($dates))) { |
|
2077 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2078 | + } |
|
2064 | 2079 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
2065 | 2080 | $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
2066 | 2081 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
2067 | - if (count($values) != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
|
2082 | + if (count($values) != count($dates)) { |
|
2083 | + return PHPExcel_Calculation_Functions::NaN(); |
|
2084 | + } |
|
2068 | 2085 | |
2069 | 2086 | // create an initial range, with a root somewhere between 0 and guess |
2070 | 2087 | $x1 = 0.0; |
@@ -2072,14 +2089,18 @@ discard block |
||
2072 | 2089 | $f1 = self::XNPV($x1, $values, $dates); |
2073 | 2090 | $f2 = self::XNPV($x2, $values, $dates); |
2074 | 2091 | for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
2075 | - if (($f1 * $f2) < 0.0) break; |
|
2092 | + if (($f1 * $f2) < 0.0) { |
|
2093 | + break; |
|
2094 | + } |
|
2076 | 2095 | if (abs($f1) < abs($f2)) { |
2077 | 2096 | $f1 = self::XNPV($x1 += 1.6 * ($x1 - $x2), $values, $dates); |
2078 | 2097 | } else { |
2079 | 2098 | $f2 = self::XNPV($x2 += 1.6 * ($x2 - $x1), $values, $dates); |
2080 | 2099 | } |
2081 | 2100 | } |
2082 | - if (($f1 * $f2) > 0.0) return PHPExcel_Calculation_Functions::VALUE(); |
|
2101 | + if (($f1 * $f2) > 0.0) { |
|
2102 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2103 | + } |
|
2083 | 2104 | |
2084 | 2105 | $f = self::XNPV($x1, $values, $dates); |
2085 | 2106 | if ($f < 0.0) { |
@@ -2094,8 +2115,12 @@ discard block |
||
2094 | 2115 | $dx *= 0.5; |
2095 | 2116 | $x_mid = $rtb + $dx; |
2096 | 2117 | $f_mid = self::XNPV($x_mid, $values, $dates); |
2097 | - if ($f_mid <= 0.0) $rtb = $x_mid; |
|
2098 | - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid; |
|
2118 | + if ($f_mid <= 0.0) { |
|
2119 | + $rtb = $x_mid; |
|
2120 | + } |
|
2121 | + if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) { |
|
2122 | + return $x_mid; |
|
2123 | + } |
|
2099 | 2124 | } |
2100 | 2125 | return PHPExcel_Calculation_Functions::VALUE(); |
2101 | 2126 | } |
@@ -2117,17 +2142,27 @@ discard block |
||
2117 | 2142 | */ |
2118 | 2143 | public static function XNPV($rate, $values, $dates) { |
2119 | 2144 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
2120 | - if (!is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2121 | - if ((!is_array($values)) || (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2145 | + if (!is_numeric($rate)) { |
|
2146 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2147 | + } |
|
2148 | + if ((!is_array($values)) || (!is_array($dates))) { |
|
2149 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2150 | + } |
|
2122 | 2151 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
2123 | 2152 | $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
2124 | 2153 | $valCount = count($values); |
2125 | - if ($valCount != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
|
2126 | - if ((min($values) > 0) || (max($values) < 0)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2154 | + if ($valCount != count($dates)) { |
|
2155 | + return PHPExcel_Calculation_Functions::NaN(); |
|
2156 | + } |
|
2157 | + if ((min($values) > 0) || (max($values) < 0)) { |
|
2158 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2159 | + } |
|
2127 | 2160 | |
2128 | 2161 | $xnpv = 0.0; |
2129 | 2162 | for ($i = 0; $i < $valCount; ++$i) { |
2130 | - if (!is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE(); |
|
2163 | + if (!is_numeric($values[$i])) { |
|
2164 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2165 | + } |
|
2131 | 2166 | $xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0],$dates[$i],'d') / 365); |
2132 | 2167 | } |
2133 | 2168 | return (is_finite($xnpv)) ? $xnpv : PHPExcel_Calculation_Functions::VALUE(); |
@@ -409,7 +409,7 @@ |
||
409 | 409 | } elseif ($period <= $nNumOfFullPeriods) { |
410 | 410 | return $fOneRate; |
411 | 411 | } elseif ($period == ($nNumOfFullPeriods + 1)) { |
412 | - return ($fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate); |
|
412 | + return ($fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate); |
|
413 | 413 | } else { |
414 | 414 | return 0.0; |
415 | 415 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * Get Token |
122 | 122 | * |
123 | 123 | * @param int $pId Token id |
124 | - * @return string |
|
124 | + * @return PHPExcel_Calculation_FormulaToken |
|
125 | 125 | * @throws Exception |
126 | 126 | */ |
127 | 127 | public function getToken($pId = 0) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * Get Token count |
137 | 137 | * |
138 | - * @return string |
|
138 | + * @return integer |
|
139 | 139 | */ |
140 | 140 | public function getTokenCount() { |
141 | 141 | return count($this->_tokens); |
@@ -89,71 +89,71 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private $_tokens = array(); |
91 | 91 | |
92 | - /** |
|
93 | - * Create a new PHPExcel_Calculation_FormulaParser |
|
94 | - * |
|
95 | - * @param string $pFormula Formula to parse |
|
96 | - * @throws Exception |
|
97 | - */ |
|
98 | - public function __construct($pFormula = '') |
|
99 | - { |
|
100 | - // Check parameters |
|
101 | - if (is_null($pFormula)) { |
|
102 | - throw new Exception("Invalid parameter passed: formula"); |
|
103 | - } |
|
104 | - |
|
105 | - // Initialise values |
|
106 | - $this->_formula = trim($pFormula); |
|
107 | - // Parse! |
|
108 | - $this->_parseToTokens(); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get Formula |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function getFormula() { |
|
117 | - return $this->_formula; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Get Token |
|
122 | - * |
|
123 | - * @param int $pId Token id |
|
124 | - * @return string |
|
125 | - * @throws Exception |
|
126 | - */ |
|
127 | - public function getToken($pId = 0) { |
|
128 | - if (isset($this->_tokens[$pId])) { |
|
129 | - return $this->_tokens[$pId]; |
|
130 | - } else { |
|
131 | - throw new Exception("Token with id $pId does not exist."); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Get Token count |
|
137 | - * |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function getTokenCount() { |
|
141 | - return count($this->_tokens); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Get Tokens |
|
146 | - * |
|
147 | - * @return PHPExcel_Calculation_FormulaToken[] |
|
148 | - */ |
|
149 | - public function getTokens() { |
|
150 | - return $this->_tokens; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Parse to tokens |
|
155 | - */ |
|
156 | - private function _parseToTokens() { |
|
92 | + /** |
|
93 | + * Create a new PHPExcel_Calculation_FormulaParser |
|
94 | + * |
|
95 | + * @param string $pFormula Formula to parse |
|
96 | + * @throws Exception |
|
97 | + */ |
|
98 | + public function __construct($pFormula = '') |
|
99 | + { |
|
100 | + // Check parameters |
|
101 | + if (is_null($pFormula)) { |
|
102 | + throw new Exception("Invalid parameter passed: formula"); |
|
103 | + } |
|
104 | + |
|
105 | + // Initialise values |
|
106 | + $this->_formula = trim($pFormula); |
|
107 | + // Parse! |
|
108 | + $this->_parseToTokens(); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get Formula |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function getFormula() { |
|
117 | + return $this->_formula; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Get Token |
|
122 | + * |
|
123 | + * @param int $pId Token id |
|
124 | + * @return string |
|
125 | + * @throws Exception |
|
126 | + */ |
|
127 | + public function getToken($pId = 0) { |
|
128 | + if (isset($this->_tokens[$pId])) { |
|
129 | + return $this->_tokens[$pId]; |
|
130 | + } else { |
|
131 | + throw new Exception("Token with id $pId does not exist."); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Get Token count |
|
137 | + * |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function getTokenCount() { |
|
141 | + return count($this->_tokens); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Get Tokens |
|
146 | + * |
|
147 | + * @return PHPExcel_Calculation_FormulaToken[] |
|
148 | + */ |
|
149 | + public function getTokens() { |
|
150 | + return $this->_tokens; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Parse to tokens |
|
155 | + */ |
|
156 | + private function _parseToTokens() { |
|
157 | 157 | // No attempt is made to verify formulas; assumes formulas are derived from Excel, where |
158 | 158 | // they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions. |
159 | 159 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | continue; |
454 | 454 | } |
455 | 455 | |
456 | - // token accumulation |
|
456 | + // token accumulation |
|
457 | 457 | $value .= $this->_formula{$index}; |
458 | 458 | ++$index; |
459 | 459 | } |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
611 | - $this->_tokens[] = $token; |
|
611 | + $this->_tokens[] = $token; |
|
612 | 612 | } |
613 | - } |
|
613 | + } |
|
614 | 614 | } |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | const COMMA = ','; |
72 | 72 | const ERROR_START = '#'; |
73 | 73 | |
74 | - const OPERATORS_SN = "+-"; |
|
75 | - const OPERATORS_INFIX = "+-*/^&=><"; |
|
76 | - const OPERATORS_POSTFIX = "%"; |
|
74 | + const OPERATORS_SN = "+-"; |
|
75 | + const OPERATORS_INFIX = "+-*/^&=><"; |
|
76 | + const OPERATORS_POSTFIX = "%"; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Formula |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | if ($formulaLength < 2 || $this->_formula{0} != '=') return; |
163 | 163 | |
164 | 164 | // Helper variables |
165 | - $tokens1 = $tokens2 = $stack = array(); |
|
166 | - $inString = $inPath = $inRange = $inError = false; |
|
167 | - $token = $previousToken = $nextToken = null; |
|
165 | + $tokens1 = $tokens2 = $stack = array(); |
|
166 | + $inString = $inPath = $inRange = $inError = false; |
|
167 | + $token = $previousToken = $nextToken = null; |
|
168 | 168 | |
169 | 169 | $index = 1; |
170 | 170 | $value = ''; |
171 | 171 | |
172 | - $ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"); |
|
173 | - $COMPARATORS_MULTI = array(">=", "<=", "<>"); |
|
172 | + $ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"); |
|
173 | + $COMPARATORS_MULTI = array(">=", "<=", "<>"); |
|
174 | 174 | |
175 | 175 | while ($index < $formulaLength) { |
176 | 176 | // state-dependent character evaluation (order is important) |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | // standard infix operators |
382 | 382 | if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) { |
383 | 383 | if (strlen($value) > 0) { |
384 | - $tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); |
|
384 | + $tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); |
|
385 | 385 | $value = ""; |
386 | 386 | } |
387 | 387 | $tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX); |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | |
494 | - if (! ( |
|
494 | + if ( ! ( |
|
495 | 495 | (($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || |
496 | 496 | (($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || |
497 | 497 | ($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) |
498 | - ) ) { |
|
498 | + )) { |
|
499 | 499 | continue; |
500 | 500 | } |
501 | 501 | |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | continue; |
504 | 504 | } |
505 | 505 | |
506 | - if (! ( |
|
506 | + if ( ! ( |
|
507 | 507 | (($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) || |
508 | 508 | (($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) || |
509 | 509 | ($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) |
510 | - ) ) { |
|
510 | + )) { |
|
511 | 511 | continue; |
512 | 512 | } |
513 | 513 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | } |
587 | 587 | |
588 | 588 | if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { |
589 | - if (!is_numeric($token->getValue())) { |
|
589 | + if ( ! is_numeric($token->getValue())) { |
|
590 | 590 | if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) { |
591 | 591 | $token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL); |
592 | 592 | } else { |
@@ -159,7 +159,9 @@ |
||
159 | 159 | |
160 | 160 | // Check if the formula has a valid starting = |
161 | 161 | $formulaLength = strlen($this->_formula); |
162 | - if ($formulaLength < 2 || $this->_formula{0} != '=') return; |
|
162 | + if ($formulaLength < 2 || $this->_formula{0} != '=') { |
|
163 | + return; |
|
164 | + } |
|
163 | 165 | |
164 | 166 | // Helper variables |
165 | 167 | $tokens1 = $tokens2 = $stack = array(); |
@@ -97,8 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @access public |
99 | 99 | * @category Logical Functions |
100 | - * @param mixed $arg,... Data values |
|
101 | - * @return boolean The logical AND of the arguments. |
|
100 | + * @return string|boolean The logical AND of the arguments. |
|
102 | 101 | */ |
103 | 102 | public static function LOGICAL_AND() { |
104 | 103 | // Return value |
@@ -152,8 +151,7 @@ discard block |
||
152 | 151 | * |
153 | 152 | * @access public |
154 | 153 | * @category Logical Functions |
155 | - * @param mixed $arg,... Data values |
|
156 | - * @return boolean The logical OR of the arguments. |
|
154 | + * @return string|boolean The logical OR of the arguments. |
|
157 | 155 | */ |
158 | 156 | public static function LOGICAL_OR() { |
159 | 157 | // Return value |
@@ -207,7 +205,7 @@ discard block |
||
207 | 205 | * @access public |
208 | 206 | * @category Logical Functions |
209 | 207 | * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE |
210 | - * @return boolean The boolean inverse of the argument. |
|
208 | + * @return boolean|string The boolean inverse of the argument. |
|
211 | 209 | */ |
212 | 210 | public static function NOT($logical=FALSE) { |
213 | 211 | $logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical); |
@@ -252,8 +250,8 @@ discard block |
||
252 | 250 | * |
253 | 251 | * @access public |
254 | 252 | * @category Logical Functions |
255 | - * @param mixed $condition Condition to evaluate |
|
256 | - * @param mixed $returnIfTrue Value to return when condition is true |
|
253 | + * @param boolean $condition Condition to evaluate |
|
254 | + * @param integer $returnIfTrue Value to return when condition is true |
|
257 | 255 | * @param mixed $returnIfFalse Optional value to return when condition is false |
258 | 256 | * @return mixed The value of returnIfTrue or returnIfFalse determined by condition |
259 | 257 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // Is it a boolean value? |
112 | 112 | if (is_bool($arg)) { |
113 | 113 | $returnValue = $returnValue && $arg; |
114 | - } elseif ((is_numeric($arg)) && (!is_string($arg))) { |
|
114 | + } elseif ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
115 | 115 | $returnValue = $returnValue && ($arg != 0); |
116 | 116 | } elseif (is_string($arg)) { |
117 | 117 | $arg = strtoupper($arg); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // Is it a boolean value? |
167 | 167 | if (is_bool($arg)) { |
168 | 168 | $returnValue = $returnValue || $arg; |
169 | - } elseif ((is_numeric($arg)) && (!is_string($arg))) { |
|
169 | + } elseif ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
170 | 170 | $returnValue = $returnValue || ($arg != 0); |
171 | 171 | } elseif (is_string($arg)) { |
172 | 172 | $arg = strtoupper($arg); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE |
210 | 210 | * @return boolean The boolean inverse of the argument. |
211 | 211 | */ |
212 | - public static function NOT($logical=FALSE) { |
|
212 | + public static function NOT($logical = FALSE) { |
|
213 | 213 | $logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical); |
214 | 214 | if (is_string($logical)) { |
215 | 215 | $logical = strtoupper($logical); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | - return !$logical; |
|
225 | + return ! $logical; |
|
226 | 226 | } // function NOT() |
227 | 227 | |
228 | 228 | /** |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | * @return mixed The value of returnIfTrue or returnIfFalse determined by condition |
259 | 259 | */ |
260 | 260 | public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) { |
261 | - $condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition); |
|
262 | - $returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue); |
|
263 | - $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse); |
|
261 | + $condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition); |
|
262 | + $returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue); |
|
263 | + $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse); |
|
264 | 264 | |
265 | 265 | return ($condition) ? $returnIfTrue : $returnIfFalse; |
266 | 266 | } // function STATEMENT_IF() |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @return mixed The value of errorpart or testValue determined by error condition |
280 | 280 | */ |
281 | 281 | public static function IFERROR($testValue = '', $errorpart = '') { |
282 | - $testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
|
283 | - $errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart); |
|
282 | + $testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
|
283 | + $errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart); |
|
284 | 284 | |
285 | 285 | return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue); |
286 | 286 | } // function IFERROR() |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param row Row number to use in the cell reference |
58 | 58 | * @param column Column number to use in the cell reference |
59 | - * @param relativity Flag indicating the type of reference to return |
|
59 | + * @param relativity integer indicating the type of reference to return |
|
60 | 60 | * 1 or omitted Absolute |
61 | 61 | * 2 Absolute row; relative column |
62 | 62 | * 3 Relative row; absolute column |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or |
347 | 347 | * range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value. |
348 | - * @param rows The number of rows, up or down, that you want the upper-left cell to refer to. |
|
348 | + * @param rows integer number of rows, up or down, that you want the upper-left cell to refer to. |
|
349 | 349 | * Using 5 as the rows argument specifies that the upper-left cell in the reference is |
350 | 350 | * five rows below reference. Rows can be positive (which means below the starting reference) |
351 | 351 | * or negative (which means above the starting reference). |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @param lookup_value The value that you want to match in lookup_array |
482 | 482 | * @param lookup_array The range of cells being searched |
483 | - * @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered. |
|
483 | + * @param match_type integer number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered. |
|
484 | 484 | * @return integer The relative position of the found item |
485 | 485 | */ |
486 | 486 | public static function MATCH($lookup_value, $lookup_array, $match_type=1) { |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number. |
683 | 683 | * @param lookup_value The value that you want to match in lookup_array |
684 | 684 | * @param lookup_array The range of cells being searched |
685 | - * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. |
|
685 | + * @param index_number integer column number in table_array from which the matching value must be returned. The first column is 1. |
|
686 | 686 | * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
687 | 687 | * @return mixed The value of the found cell |
688 | 688 | */ |
@@ -678,14 +678,14 @@ |
||
678 | 678 | |
679 | 679 | |
680 | 680 | /** |
681 | - * VLOOKUP |
|
682 | - * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number. |
|
683 | - * @param lookup_value The value that you want to match in lookup_array |
|
684 | - * @param lookup_array The range of cells being searched |
|
685 | - * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. |
|
686 | - * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
|
687 | - * @return mixed The value of the found cell |
|
688 | - */ |
|
681 | + * VLOOKUP |
|
682 | + * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number. |
|
683 | + * @param lookup_value The value that you want to match in lookup_array |
|
684 | + * @param lookup_array The range of cells being searched |
|
685 | + * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. |
|
686 | + * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
|
687 | + * @return mixed The value of the found cell |
|
688 | + */ |
|
689 | 689 | public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { |
690 | 690 | $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
691 | 691 | $index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -67,23 +67,23 @@ discard block |
||
67 | 67 | * @param sheetText Optional Name of worksheet to use |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') { |
|
71 | - $row = PHPExcel_Calculation_Functions::flattenSingleValue($row); |
|
72 | - $column = PHPExcel_Calculation_Functions::flattenSingleValue($column); |
|
73 | - $relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity); |
|
74 | - $sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText); |
|
70 | + public static function CELL_ADDRESS($row, $column, $relativity = 1, $referenceStyle = True, $sheetText = '') { |
|
71 | + $row = PHPExcel_Calculation_Functions::flattenSingleValue($row); |
|
72 | + $column = PHPExcel_Calculation_Functions::flattenSingleValue($column); |
|
73 | + $relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity); |
|
74 | + $sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText); |
|
75 | 75 | |
76 | 76 | if (($row < 1) || ($column < 1)) { |
77 | 77 | return PHPExcel_Calculation_Functions::VALUE(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | if ($sheetText > '') { |
81 | - if (strpos($sheetText,' ') !== False) { $sheetText = "'".$sheetText."'"; } |
|
82 | - $sheetText .='!'; |
|
81 | + if (strpos($sheetText, ' ') !== False) { $sheetText = "'".$sheetText."'"; } |
|
82 | + $sheetText .= '!'; |
|
83 | 83 | } |
84 | - if ((!is_bool($referenceStyle)) || $referenceStyle) { |
|
84 | + if (( ! is_bool($referenceStyle)) || $referenceStyle) { |
|
85 | 85 | $rowRelative = $columnRelative = '$'; |
86 | - $column = PHPExcel_Cell::stringFromColumnIndex($column-1); |
|
86 | + $column = PHPExcel_Cell::stringFromColumnIndex($column - 1); |
|
87 | 87 | if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; } |
88 | 88 | if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; } |
89 | 89 | return $sheetText.$columnRelative.$column.$rowRelative.$row; |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | * @param cellAddress A reference to a range of cells for which you want the column numbers |
110 | 110 | * @return integer or array of integer |
111 | 111 | */ |
112 | - public static function COLUMN($cellAddress=Null) { |
|
112 | + public static function COLUMN($cellAddress = Null) { |
|
113 | 113 | if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; } |
114 | 114 | |
115 | 115 | if (is_array($cellAddress)) { |
116 | - foreach($cellAddress as $columnKey => $value) { |
|
117 | - $columnKey = preg_replace('/[^a-z]/i','',$columnKey); |
|
116 | + foreach ($cellAddress as $columnKey => $value) { |
|
117 | + $columnKey = preg_replace('/[^a-z]/i', '', $columnKey); |
|
118 | 118 | return (integer) PHPExcel_Cell::columnIndexFromString($columnKey); |
119 | 119 | } |
120 | 120 | } else { |
121 | - if (strpos($cellAddress,'!') !== false) { |
|
122 | - list($sheet,$cellAddress) = explode('!',$cellAddress); |
|
121 | + if (strpos($cellAddress, '!') !== false) { |
|
122 | + list($sheet, $cellAddress) = explode('!', $cellAddress); |
|
123 | 123 | } |
124 | - if (strpos($cellAddress,':') !== false) { |
|
125 | - list($startAddress,$endAddress) = explode(':',$cellAddress); |
|
126 | - $startAddress = preg_replace('/[^a-z]/i','',$startAddress); |
|
127 | - $endAddress = preg_replace('/[^a-z]/i','',$endAddress); |
|
124 | + if (strpos($cellAddress, ':') !== false) { |
|
125 | + list($startAddress, $endAddress) = explode(':', $cellAddress); |
|
126 | + $startAddress = preg_replace('/[^a-z]/i', '', $startAddress); |
|
127 | + $endAddress = preg_replace('/[^a-z]/i', '', $endAddress); |
|
128 | 128 | $returnValue = array(); |
129 | 129 | do { |
130 | 130 | $returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress); |
131 | 131 | } while ($startAddress++ != $endAddress); |
132 | 132 | return $returnValue; |
133 | 133 | } else { |
134 | - $cellAddress = preg_replace('/[^a-z]/i','',$cellAddress); |
|
134 | + $cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress); |
|
135 | 135 | return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress); |
136 | 136 | } |
137 | 137 | } |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns |
150 | 150 | * @return integer The number of columns in cellAddress |
151 | 151 | */ |
152 | - public static function COLUMNS($cellAddress=Null) { |
|
152 | + public static function COLUMNS($cellAddress = Null) { |
|
153 | 153 | if (is_null($cellAddress) || $cellAddress === '') { |
154 | 154 | return 1; |
155 | - } elseif (!is_array($cellAddress)) { |
|
155 | + } elseif ( ! is_array($cellAddress)) { |
|
156 | 156 | return PHPExcel_Calculation_Functions::VALUE(); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $x = array_keys($cellAddress); |
160 | 160 | $x = array_shift($x); |
161 | 161 | $isMatrix = (is_numeric($x)); |
162 | - list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
162 | + list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
163 | 163 | |
164 | 164 | if ($isMatrix) { |
165 | 165 | return $rows; |
@@ -183,31 +183,31 @@ discard block |
||
183 | 183 | * @param cellAddress A reference to a range of cells for which you want the row numbers |
184 | 184 | * @return integer or array of integer |
185 | 185 | */ |
186 | - public static function ROW($cellAddress=Null) { |
|
186 | + public static function ROW($cellAddress = Null) { |
|
187 | 187 | if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; } |
188 | 188 | |
189 | 189 | if (is_array($cellAddress)) { |
190 | - foreach($cellAddress as $columnKey => $rowValue) { |
|
191 | - foreach($rowValue as $rowKey => $cellValue) { |
|
192 | - return (integer) preg_replace('/[^0-9]/i','',$rowKey); |
|
190 | + foreach ($cellAddress as $columnKey => $rowValue) { |
|
191 | + foreach ($rowValue as $rowKey => $cellValue) { |
|
192 | + return (integer) preg_replace('/[^0-9]/i', '', $rowKey); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } else { |
196 | - if (strpos($cellAddress,'!') !== false) { |
|
197 | - list($sheet,$cellAddress) = explode('!',$cellAddress); |
|
196 | + if (strpos($cellAddress, '!') !== false) { |
|
197 | + list($sheet, $cellAddress) = explode('!', $cellAddress); |
|
198 | 198 | } |
199 | - if (strpos($cellAddress,':') !== false) { |
|
200 | - list($startAddress,$endAddress) = explode(':',$cellAddress); |
|
201 | - $startAddress = preg_replace('/[^0-9]/','',$startAddress); |
|
202 | - $endAddress = preg_replace('/[^0-9]/','',$endAddress); |
|
199 | + if (strpos($cellAddress, ':') !== false) { |
|
200 | + list($startAddress, $endAddress) = explode(':', $cellAddress); |
|
201 | + $startAddress = preg_replace('/[^0-9]/', '', $startAddress); |
|
202 | + $endAddress = preg_replace('/[^0-9]/', '', $endAddress); |
|
203 | 203 | $returnValue = array(); |
204 | 204 | do { |
205 | 205 | $returnValue[][] = (integer) $startAddress; |
206 | 206 | } while ($startAddress++ != $endAddress); |
207 | 207 | return $returnValue; |
208 | 208 | } else { |
209 | - list($cellAddress) = explode(':',$cellAddress); |
|
210 | - return (integer) preg_replace('/[^0-9]/','',$cellAddress); |
|
209 | + list($cellAddress) = explode(':', $cellAddress); |
|
210 | + return (integer) preg_replace('/[^0-9]/', '', $cellAddress); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | } // function ROW() |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows |
225 | 225 | * @return integer The number of rows in cellAddress |
226 | 226 | */ |
227 | - public static function ROWS($cellAddress=Null) { |
|
227 | + public static function ROWS($cellAddress = Null) { |
|
228 | 228 | if (is_null($cellAddress) || $cellAddress === '') { |
229 | 229 | return 1; |
230 | - } elseif (!is_array($cellAddress)) { |
|
230 | + } elseif ( ! is_array($cellAddress)) { |
|
231 | 231 | return PHPExcel_Calculation_Functions::VALUE(); |
232 | 232 | } |
233 | 233 | |
234 | 234 | $i = array_keys($cellAddress); |
235 | 235 | $isMatrix = (is_numeric(array_shift($i))); |
236 | - list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
236 | + list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
237 | 237 | |
238 | 238 | if ($isMatrix) { |
239 | 239 | return $columns; |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | $args = func_get_args(); |
260 | 260 | $pCell = array_pop($args); |
261 | 261 | |
262 | - $linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL); |
|
263 | - $displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName); |
|
262 | + $linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL); |
|
263 | + $displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName); |
|
264 | 264 | |
265 | - if ((!is_object($pCell)) || (trim($linkURL) == '')) { |
|
265 | + if (( ! is_object($pCell)) || (trim($linkURL) == '')) { |
|
266 | 266 | return PHPExcel_Calculation_Functions::REF(); |
267 | 267 | } |
268 | 268 | |
@@ -293,27 +293,27 @@ discard block |
||
293 | 293 | * @todo Support for the optional a1 parameter introduced in Excel 2010 |
294 | 294 | * |
295 | 295 | */ |
296 | - public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) { |
|
297 | - $cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress); |
|
296 | + public static function INDIRECT($cellAddress = Null, PHPExcel_Cell $pCell = null) { |
|
297 | + $cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress); |
|
298 | 298 | if (is_null($cellAddress) || $cellAddress === '') { |
299 | 299 | return PHPExcel_Calculation_Functions::REF(); |
300 | 300 | } |
301 | 301 | |
302 | 302 | $cellAddress1 = $cellAddress; |
303 | 303 | $cellAddress2 = NULL; |
304 | - if (strpos($cellAddress,':') !== false) { |
|
305 | - list($cellAddress1,$cellAddress2) = explode(':',$cellAddress); |
|
304 | + if (strpos($cellAddress, ':') !== false) { |
|
305 | + list($cellAddress1, $cellAddress2) = explode(':', $cellAddress); |
|
306 | 306 | } |
307 | 307 | |
308 | - if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || |
|
309 | - ((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { |
|
308 | + if (( ! preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || |
|
309 | + (( ! is_null($cellAddress2)) && ( ! preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { |
|
310 | 310 | |
311 | - if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { |
|
311 | + if ( ! preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { |
|
312 | 312 | return PHPExcel_Calculation_Functions::REF(); |
313 | 313 | } |
314 | 314 | |
315 | - if (strpos($cellAddress,'!') !== false) { |
|
316 | - list($sheetName,$cellAddress) = explode('!',$cellAddress); |
|
315 | + if (strpos($cellAddress, '!') !== false) { |
|
316 | + list($sheetName, $cellAddress) = explode('!', $cellAddress); |
|
317 | 317 | $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); |
318 | 318 | } else { |
319 | 319 | $pSheet = $pCell->getParent(); |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False); |
323 | 323 | } |
324 | 324 | |
325 | - if (strpos($cellAddress,'!') !== false) { |
|
326 | - list($sheetName,$cellAddress) = explode('!',$cellAddress); |
|
325 | + if (strpos($cellAddress, '!') !== false) { |
|
326 | + list($sheetName, $cellAddress) = explode('!', $cellAddress); |
|
327 | 327 | $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); |
328 | 328 | } else { |
329 | 329 | $pSheet = $pCell->getParent(); |
@@ -358,32 +358,32 @@ discard block |
||
358 | 358 | * @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number. |
359 | 359 | * @return string A reference to a cell or range of cells |
360 | 360 | */ |
361 | - public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) { |
|
362 | - $rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows); |
|
361 | + public static function OFFSET($cellAddress = Null, $rows = 0, $columns = 0, $height = null, $width = null) { |
|
362 | + $rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows); |
|
363 | 363 | $columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns); |
364 | 364 | $height = PHPExcel_Calculation_Functions::flattenSingleValue($height); |
365 | - $width = PHPExcel_Calculation_Functions::flattenSingleValue($width); |
|
365 | + $width = PHPExcel_Calculation_Functions::flattenSingleValue($width); |
|
366 | 366 | if ($cellAddress == Null) { |
367 | 367 | return 0; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $args = func_get_args(); |
371 | 371 | $pCell = array_pop($args); |
372 | - if (!is_object($pCell)) { |
|
372 | + if ( ! is_object($pCell)) { |
|
373 | 373 | return PHPExcel_Calculation_Functions::REF(); |
374 | 374 | } |
375 | 375 | |
376 | 376 | $sheetName = null; |
377 | - if (strpos($cellAddress,"!")) { |
|
378 | - list($sheetName,$cellAddress) = explode("!",$cellAddress); |
|
377 | + if (strpos($cellAddress, "!")) { |
|
378 | + list($sheetName, $cellAddress) = explode("!", $cellAddress); |
|
379 | 379 | } |
380 | - if (strpos($cellAddress,":")) { |
|
381 | - list($startCell,$endCell) = explode(":",$cellAddress); |
|
380 | + if (strpos($cellAddress, ":")) { |
|
381 | + list($startCell, $endCell) = explode(":", $cellAddress); |
|
382 | 382 | } else { |
383 | 383 | $startCell = $endCell = $cellAddress; |
384 | 384 | } |
385 | - list($startCellColumn,$startCellRow) = PHPExcel_Cell::coordinateFromString($startCell); |
|
386 | - list($endCellColumn,$endCellRow) = PHPExcel_Cell::coordinateFromString($endCell); |
|
385 | + list($startCellColumn, $startCellRow) = PHPExcel_Cell::coordinateFromString($startCell); |
|
386 | + list($endCellColumn, $endCellRow) = PHPExcel_Cell::coordinateFromString($endCell); |
|
387 | 387 | |
388 | 388 | $startCellRow += $rows; |
389 | 389 | $startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1; |
@@ -393,14 +393,14 @@ discard block |
||
393 | 393 | return PHPExcel_Calculation_Functions::REF(); |
394 | 394 | } |
395 | 395 | $endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1; |
396 | - if (($width != null) && (!is_object($width))) { |
|
396 | + if (($width != null) && ( ! is_object($width))) { |
|
397 | 397 | $endCellColumn = $startCellColumn + $width - 1; |
398 | 398 | } else { |
399 | 399 | $endCellColumn += $columns; |
400 | 400 | } |
401 | 401 | $startCellColumn = PHPExcel_Cell::stringFromColumnIndex($startCellColumn); |
402 | 402 | |
403 | - if (($height != null) && (!is_object($height))) { |
|
403 | + if (($height != null) && ( ! is_object($height))) { |
|
404 | 404 | $endCellRow = $startCellRow + $height - 1; |
405 | 405 | } else { |
406 | 406 | $endCellRow += $rows; |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | $chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs)); |
450 | 450 | $entryCount = count($chooseArgs) - 1; |
451 | 451 | |
452 | - if(is_array($chosenEntry)) { |
|
452 | + if (is_array($chosenEntry)) { |
|
453 | 453 | $chosenEntry = array_shift($chosenEntry); |
454 | 454 | } |
455 | - if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) { |
|
455 | + if ((is_numeric($chosenEntry)) && ( ! is_bool($chosenEntry))) { |
|
456 | 456 | --$chosenEntry; |
457 | 457 | } else { |
458 | 458 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -483,15 +483,15 @@ discard block |
||
483 | 483 | * @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered. |
484 | 484 | * @return integer The relative position of the found item |
485 | 485 | */ |
486 | - public static function MATCH($lookup_value, $lookup_array, $match_type=1) { |
|
486 | + public static function MATCH($lookup_value, $lookup_array, $match_type = 1) { |
|
487 | 487 | $lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array); |
488 | 488 | $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
489 | - $match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type); |
|
489 | + $match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type); |
|
490 | 490 | // MATCH is not case sensitive |
491 | 491 | $lookup_value = strtolower($lookup_value); |
492 | 492 | |
493 | 493 | // lookup_value type has to be number, text, or logical values |
494 | - if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) { |
|
494 | + if (( ! is_numeric($lookup_value)) && ( ! is_string($lookup_value)) && ( ! is_bool($lookup_value))) { |
|
495 | 495 | return PHPExcel_Calculation_Functions::NA(); |
496 | 496 | } |
497 | 497 | |
@@ -507,10 +507,10 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | // lookup_array should contain only number, text, or logical values, or empty (null) cells |
510 | - foreach($lookup_array as $i => $lookupArrayValue) { |
|
510 | + foreach ($lookup_array as $i => $lookupArrayValue) { |
|
511 | 511 | // check the type of the value |
512 | - if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && |
|
513 | - (!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) { |
|
512 | + if (( ! is_numeric($lookupArrayValue)) && ( ! is_string($lookupArrayValue)) && |
|
513 | + ( ! is_bool($lookupArrayValue)) && ( ! is_null($lookupArrayValue))) { |
|
514 | 514 | return PHPExcel_Calculation_Functions::NA(); |
515 | 515 | } |
516 | 516 | // convert strings to lowercase for case-insensitive testing |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | $lookup_array[$i] = strtolower($lookupArrayValue); |
519 | 519 | } |
520 | 520 | if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) { |
521 | - $lookup_array = array_slice($lookup_array,0,$i-1); |
|
521 | + $lookup_array = array_slice($lookup_array, 0, $i - 1); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | if ($match_type == 1) { |
527 | 527 | asort($lookup_array); |
528 | 528 | $keySet = array_keys($lookup_array); |
529 | - } elseif($match_type == -1) { |
|
529 | + } elseif ($match_type == -1) { |
|
530 | 530 | arsort($lookup_array); |
531 | 531 | $keySet = array_keys($lookup_array); |
532 | 532 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | // loop on the cells |
538 | 538 | // var_dump($lookup_array); |
539 | 539 | // echo '<br />'; |
540 | - foreach($lookup_array as $i => $lookupArrayValue) { |
|
540 | + foreach ($lookup_array as $i => $lookupArrayValue) { |
|
541 | 541 | if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) { |
542 | 542 | // exact match |
543 | 543 | return ++$i; |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | // echo 'Keyset = '; |
549 | 549 | // var_dump($keySet); |
550 | 550 | // echo '<br />'; |
551 | - $i = array_search($i,$keySet); |
|
551 | + $i = array_search($i, $keySet); |
|
552 | 552 | // echo '$i='.$i.'<br />'; |
553 | 553 | // if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value |
554 | - if ($i < 1){ |
|
554 | + if ($i < 1) { |
|
555 | 555 | // 1st cell was allready smaller than the lookup_value |
556 | 556 | break; |
557 | 557 | } else { |
558 | 558 | // the previous cell was the match |
559 | - return $keySet[$i-1]+1; |
|
559 | + return $keySet[$i - 1] + 1; |
|
560 | 560 | } |
561 | 561 | } elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) { |
562 | 562 | // echo '$i = '.$i.' => '; |
@@ -565,15 +565,15 @@ discard block |
||
565 | 565 | // echo 'Keyset = '; |
566 | 566 | // var_dump($keySet); |
567 | 567 | // echo '<br />'; |
568 | - $i = array_search($i,$keySet); |
|
568 | + $i = array_search($i, $keySet); |
|
569 | 569 | // echo '$i='.$i.'<br />'; |
570 | 570 | // if match_type is 1 <=> find the largest value that is less than or equal to lookup_value |
571 | - if ($i < 1){ |
|
571 | + if ($i < 1) { |
|
572 | 572 | // 1st cell was allready bigger than the lookup_value |
573 | 573 | break; |
574 | 574 | } else { |
575 | 575 | // the previous cell was the match |
576 | - return $keySet[$i-1]+1; |
|
576 | + return $keySet[$i - 1] + 1; |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | } |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | * @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required. |
597 | 597 | * @return mixed the value of a specified cell or array of cells |
598 | 598 | */ |
599 | - public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) { |
|
599 | + public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0) { |
|
600 | 600 | |
601 | 601 | if (($rowNum < 0) || ($columnNum < 0)) { |
602 | 602 | return PHPExcel_Calculation_Functions::VALUE(); |
603 | 603 | } |
604 | 604 | |
605 | - if (!is_array($arrayValues)) { |
|
605 | + if ( ! is_array($arrayValues)) { |
|
606 | 606 | return PHPExcel_Calculation_Functions::REF(); |
607 | 607 | } |
608 | 608 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | $rowNum = $rowKeys[--$rowNum]; |
619 | 619 | $returnArray = array(); |
620 | - foreach($arrayValues as $arrayColumn) { |
|
620 | + foreach ($arrayValues as $arrayColumn) { |
|
621 | 621 | if (is_array($arrayColumn)) { |
622 | 622 | if (isset($arrayColumn[$rowNum])) { |
623 | 623 | $returnArray[] = $arrayColumn[$rowNum]; |
@@ -652,12 +652,12 @@ discard block |
||
652 | 652 | */ |
653 | 653 | public static function TRANSPOSE($matrixData) { |
654 | 654 | $returnMatrix = array(); |
655 | - if (!is_array($matrixData)) { $matrixData = array(array($matrixData)); } |
|
655 | + if ( ! is_array($matrixData)) { $matrixData = array(array($matrixData)); } |
|
656 | 656 | |
657 | 657 | $column = 0; |
658 | - foreach($matrixData as $matrixRow) { |
|
658 | + foreach ($matrixData as $matrixRow) { |
|
659 | 659 | $row = 0; |
660 | - foreach($matrixRow as $matrixCell) { |
|
660 | + foreach ($matrixRow as $matrixCell) { |
|
661 | 661 | $returnMatrix[$row][$column] = $matrixCell; |
662 | 662 | ++$row; |
663 | 663 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | } // function TRANSPOSE() |
668 | 668 | |
669 | 669 | |
670 | - private static function _vlookupSort($a,$b) { |
|
670 | + private static function _vlookupSort($a, $b) { |
|
671 | 671 | $f = array_keys($a); |
672 | 672 | $firstColumn = array_shift($f); |
673 | 673 | if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) { |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
687 | 687 | * @return mixed The value of the found cell |
688 | 688 | */ |
689 | - public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { |
|
689 | + public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true) { |
|
690 | 690 | $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
691 | 691 | $index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); |
692 | - $not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); |
|
692 | + $not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); |
|
693 | 693 | |
694 | 694 | // index_number must be greater than or equal to 1 |
695 | 695 | if ($index_number < 1) { |
@@ -697,12 +697,12 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | // index_number must be less than or equal to the number of columns in lookup_array |
700 | - if ((!is_array($lookup_array)) || (empty($lookup_array))) { |
|
700 | + if (( ! is_array($lookup_array)) || (empty($lookup_array))) { |
|
701 | 701 | return PHPExcel_Calculation_Functions::REF(); |
702 | 702 | } else { |
703 | 703 | $f = array_keys($lookup_array); |
704 | 704 | $firstRow = array_pop($f); |
705 | - if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { |
|
705 | + if (( ! is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { |
|
706 | 706 | return PHPExcel_Calculation_Functions::REF(); |
707 | 707 | } else { |
708 | 708 | $columnKeys = array_keys($lookup_array[$firstRow]); |
@@ -711,12 +711,12 @@ discard block |
||
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
714 | - if (!$not_exact_match) { |
|
715 | - uasort($lookup_array,array('self','_vlookupSort')); |
|
714 | + if ( ! $not_exact_match) { |
|
715 | + uasort($lookup_array, array('self', '_vlookupSort')); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | $rowNumber = $rowValue = False; |
719 | - foreach($lookup_array as $rowKey => $rowData) { |
|
719 | + foreach ($lookup_array as $rowKey => $rowData) { |
|
720 | 720 | if (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)) { |
721 | 721 | break; |
722 | 722 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | if ($rowNumber !== false) { |
728 | - if ((!$not_exact_match) && ($rowValue != $lookup_value)) { |
|
728 | + if (( ! $not_exact_match) && ($rowValue != $lookup_value)) { |
|
729 | 729 | // if an exact match is required, we have what we need to return an appropriate response |
730 | 730 | return PHPExcel_Calculation_Functions::NA(); |
731 | 731 | } else { |
@@ -746,10 +746,10 @@ discard block |
||
746 | 746 | * @param result_vector The column from which the matching value must be returned |
747 | 747 | * @return mixed The value of the found cell |
748 | 748 | */ |
749 | - public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) { |
|
750 | - $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
|
749 | + public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null) { |
|
750 | + $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
|
751 | 751 | |
752 | - if (!is_array($lookup_vector)) { |
|
752 | + if ( ! is_array($lookup_vector)) { |
|
753 | 753 | return PHPExcel_Calculation_Functions::NA(); |
754 | 754 | } |
755 | 755 | $lookupRows = count($lookup_vector); |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | $lookup_vector = array_shift($lookup_vector); |
783 | 783 | } |
784 | 784 | if ($lookupColumns != 2) { |
785 | - foreach($lookup_vector as &$value) { |
|
785 | + foreach ($lookup_vector as &$value) { |
|
786 | 786 | if (is_array($value)) { |
787 | 787 | $k = array_keys($value); |
788 | 788 | $key1 = $key2 = array_shift($k); |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | unset($value); |
803 | 803 | } |
804 | 804 | |
805 | - return self::VLOOKUP($lookup_value,$lookup_vector,2); |
|
805 | + return self::VLOOKUP($lookup_value, $lookup_vector, 2); |
|
806 | 806 | } // function LOOKUP() |
807 | 807 | |
808 | 808 | } // class PHPExcel_Calculation_LookupRef |
@@ -70,6 +70,10 @@ discard block |
||
70 | 70 | } // function _factors() |
71 | 71 | |
72 | 72 | |
73 | + /** |
|
74 | + * @param integer $num |
|
75 | + * @param integer $n |
|
76 | + */ |
|
73 | 77 | private static function _romanCut($num, $n) { |
74 | 78 | return ($num - ($num % $n ) ) / $n; |
75 | 79 | } // function _romanCut() |
@@ -423,8 +427,7 @@ discard block |
||
423 | 427 | * |
424 | 428 | * @access public |
425 | 429 | * @category Mathematical and Trigonometric Functions |
426 | - * @param float $value The positive real number for which you want the logarithm |
|
427 | - * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10. |
|
430 | + * @param integer $base The base of the logarithm. If base is omitted, it is assumed to be 10. |
|
428 | 431 | * @return float |
429 | 432 | */ |
430 | 433 | public static function LOG_BASE($number = NULL, $base=10) { |
@@ -681,8 +684,8 @@ discard block |
||
681 | 684 | * |
682 | 685 | * Computes x raised to the power y. |
683 | 686 | * |
684 | - * @param float $x |
|
685 | - * @param float $y |
|
687 | + * @param integer $x |
|
688 | + * @param integer $y |
|
686 | 689 | * @return float |
687 | 690 | */ |
688 | 691 | public static function POWER($x = 0, $y = 2) { |
@@ -712,7 +715,6 @@ discard block |
||
712 | 715 | * |
713 | 716 | * @access public |
714 | 717 | * @category Mathematical and Trigonometric Functions |
715 | - * @param mixed $arg,... Data values |
|
716 | 718 | * @return float |
717 | 719 | */ |
718 | 720 | public static function PRODUCT() { |
@@ -750,8 +752,7 @@ discard block |
||
750 | 752 | * |
751 | 753 | * @access public |
752 | 754 | * @category Mathematical and Trigonometric Functions |
753 | - * @param mixed $arg,... Data values |
|
754 | - * @return float |
|
755 | + * @return integer |
|
755 | 756 | */ |
756 | 757 | public static function QUOTIENT() { |
757 | 758 | // Return value |
@@ -881,9 +882,6 @@ discard block |
||
881 | 882 | * |
882 | 883 | * Returns the sum of a power series |
883 | 884 | * |
884 | - * @param float $x Input value to the power series |
|
885 | - * @param float $n Initial power to which you want to raise $x |
|
886 | - * @param float $m Step by which to increase $n for each term in the series |
|
887 | 885 | * @param array of mixed Data Series |
888 | 886 | * @return float |
889 | 887 | */ |
@@ -1028,7 +1026,6 @@ discard block |
||
1028 | 1026 | * |
1029 | 1027 | * @access public |
1030 | 1028 | * @category Mathematical and Trigonometric Functions |
1031 | - * @param mixed $arg,... Data values |
|
1032 | 1029 | * @return float |
1033 | 1030 | */ |
1034 | 1031 | public static function SUM() { |
@@ -1058,9 +1055,8 @@ discard block |
||
1058 | 1055 | * |
1059 | 1056 | * @access public |
1060 | 1057 | * @category Mathematical and Trigonometric Functions |
1061 | - * @param mixed $arg,... Data values |
|
1062 | 1058 | * @param string $condition The criteria that defines which cells will be summed. |
1063 | - * @return float |
|
1059 | + * @return integer |
|
1064 | 1060 | */ |
1065 | 1061 | public static function SUMIF($aArgs,$condition,$sumArgs = array()) { |
1066 | 1062 | // Return value |
@@ -1095,7 +1091,6 @@ discard block |
||
1095 | 1091 | * |
1096 | 1092 | * @access public |
1097 | 1093 | * @category Mathematical and Trigonometric Functions |
1098 | - * @param mixed $arg,... Data values |
|
1099 | 1094 | * @return float |
1100 | 1095 | */ |
1101 | 1096 | public static function SUMPRODUCT() { |
@@ -1139,7 +1134,6 @@ discard block |
||
1139 | 1134 | * |
1140 | 1135 | * @access public |
1141 | 1136 | * @category Mathematical and Trigonometric Functions |
1142 | - * @param mixed $arg,... Data values |
|
1143 | 1137 | * @return float |
1144 | 1138 | */ |
1145 | 1139 | public static function SUMSQ() { |
@@ -1162,7 +1156,6 @@ discard block |
||
1162 | 1156 | /** |
1163 | 1157 | * SUMX2MY2 |
1164 | 1158 | * |
1165 | - * @param mixed $value Value to check |
|
1166 | 1159 | * @return float |
1167 | 1160 | */ |
1168 | 1161 | public static function SUMX2MY2($matrixData1,$matrixData2) { |
@@ -1191,7 +1184,6 @@ discard block |
||
1191 | 1184 | /** |
1192 | 1185 | * SUMX2PY2 |
1193 | 1186 | * |
1194 | - * @param mixed $value Value to check |
|
1195 | 1187 | * @return float |
1196 | 1188 | */ |
1197 | 1189 | public static function SUMX2PY2($matrixData1,$matrixData2) { |
@@ -1220,7 +1212,6 @@ discard block |
||
1220 | 1212 | /** |
1221 | 1213 | * SUMXMY2 |
1222 | 1214 | * |
1223 | - * @param mixed $value Value to check |
|
1224 | 1215 | * @return float |
1225 | 1216 | */ |
1226 | 1217 | public static function SUMXMY2($matrixData1,$matrixData2) { |
@@ -1251,7 +1242,7 @@ discard block |
||
1251 | 1242 | * |
1252 | 1243 | * Truncates value to the number of fractional digits by number_digits. |
1253 | 1244 | * |
1254 | - * @param float $value |
|
1245 | + * @param integer $value |
|
1255 | 1246 | * @param int $digits |
1256 | 1247 | * @return float Truncated value |
1257 | 1248 | */ |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param p require p>0 |
146 | 146 | * @param q require q>0 |
147 | - * @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow |
|
147 | + * @return double if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow |
|
148 | 148 | * @author Jaco van Kooten |
149 | 149 | */ |
150 | 150 | private static function _logBeta($p, $q) { |
@@ -165,6 +165,8 @@ discard block |
||
165 | 165 | * Evaluates of continued fraction part of incomplete beta function. |
166 | 166 | * Based on an idea from Numerical Recipes (W.H. Press et al, 1992). |
167 | 167 | * @author Jaco van Kooten |
168 | + * @param double $p |
|
169 | + * @param double $q |
|
168 | 170 | */ |
169 | 171 | private static function _betaFraction($x, $p, $q) { |
170 | 172 | $c = 1.0; |
@@ -694,7 +696,6 @@ discard block |
||
694 | 696 | * |
695 | 697 | * @access public |
696 | 698 | * @category Statistical Functions |
697 | - * @param mixed $arg,... Data values |
|
698 | 699 | * @return float |
699 | 700 | */ |
700 | 701 | public static function AVEDEV() { |
@@ -742,7 +743,6 @@ discard block |
||
742 | 743 | * |
743 | 744 | * @access public |
744 | 745 | * @category Statistical Functions |
745 | - * @param mixed $arg,... Data values |
|
746 | 746 | * @return float |
747 | 747 | */ |
748 | 748 | public static function AVERAGE() { |
@@ -784,7 +784,6 @@ discard block |
||
784 | 784 | * |
785 | 785 | * @access public |
786 | 786 | * @category Statistical Functions |
787 | - * @param mixed $arg,... Data values |
|
788 | 787 | * @return float |
789 | 788 | */ |
790 | 789 | public static function AVERAGEA() { |
@@ -832,7 +831,6 @@ discard block |
||
832 | 831 | * |
833 | 832 | * @access public |
834 | 833 | * @category Mathematical and Trigonometric Functions |
835 | - * @param mixed $arg,... Data values |
|
836 | 834 | * @param string $condition The criteria that defines which cells will be checked. |
837 | 835 | * @return float |
838 | 836 | */ |
@@ -876,7 +874,6 @@ discard block |
||
876 | 874 | * @param float $value Value at which you want to evaluate the distribution |
877 | 875 | * @param float $alpha Parameter to the distribution |
878 | 876 | * @param float $beta Parameter to the distribution |
879 | - * @param boolean $cumulative |
|
880 | 877 | * @return float |
881 | 878 | * |
882 | 879 | */ |
@@ -912,7 +909,6 @@ discard block |
||
912 | 909 | * @param float $probability Probability at which you want to evaluate the distribution |
913 | 910 | * @param float $alpha Parameter to the distribution |
914 | 911 | * @param float $beta Parameter to the distribution |
915 | - * @param boolean $cumulative |
|
916 | 912 | * @return float |
917 | 913 | * |
918 | 914 | */ |
@@ -1156,7 +1152,6 @@ discard block |
||
1156 | 1152 | * |
1157 | 1153 | * @access public |
1158 | 1154 | * @category Statistical Functions |
1159 | - * @param mixed $arg,... Data values |
|
1160 | 1155 | * @return int |
1161 | 1156 | */ |
1162 | 1157 | public static function COUNT() { |
@@ -1191,7 +1186,6 @@ discard block |
||
1191 | 1186 | * |
1192 | 1187 | * @access public |
1193 | 1188 | * @category Statistical Functions |
1194 | - * @param mixed $arg,... Data values |
|
1195 | 1189 | * @return int |
1196 | 1190 | */ |
1197 | 1191 | public static function COUNTA() { |
@@ -1222,7 +1216,6 @@ discard block |
||
1222 | 1216 | * |
1223 | 1217 | * @access public |
1224 | 1218 | * @category Statistical Functions |
1225 | - * @param mixed $arg,... Data values |
|
1226 | 1219 | * @return int |
1227 | 1220 | */ |
1228 | 1221 | public static function COUNTBLANK() { |
@@ -1253,7 +1246,6 @@ discard block |
||
1253 | 1246 | * |
1254 | 1247 | * @access public |
1255 | 1248 | * @category Statistical Functions |
1256 | - * @param mixed $arg,... Data values |
|
1257 | 1249 | * @param string $condition The criteria that defines which cells will be counted. |
1258 | 1250 | * @return int |
1259 | 1251 | */ |
@@ -1425,7 +1417,6 @@ discard block |
||
1425 | 1417 | * |
1426 | 1418 | * @access public |
1427 | 1419 | * @category Statistical Functions |
1428 | - * @param mixed $arg,... Data values |
|
1429 | 1420 | * @return float |
1430 | 1421 | */ |
1431 | 1422 | public static function DEVSQ() { |
@@ -1700,7 +1691,6 @@ discard block |
||
1700 | 1691 | * |
1701 | 1692 | * @access public |
1702 | 1693 | * @category Statistical Functions |
1703 | - * @param mixed $arg,... Data values |
|
1704 | 1694 | * @return float |
1705 | 1695 | */ |
1706 | 1696 | public static function GEOMEAN() { |
@@ -1759,7 +1749,6 @@ discard block |
||
1759 | 1749 | * |
1760 | 1750 | * @access public |
1761 | 1751 | * @category Statistical Functions |
1762 | - * @param mixed $arg,... Data values |
|
1763 | 1752 | * @return float |
1764 | 1753 | */ |
1765 | 1754 | public static function HARMEAN() { |
@@ -1911,8 +1900,6 @@ discard block |
||
1911 | 1900 | * |
1912 | 1901 | * @access public |
1913 | 1902 | * @category Statistical Functions |
1914 | - * @param mixed $arg,... Data values |
|
1915 | - * @param int $entry Position (ordered from the largest) in the array or range of data to return |
|
1916 | 1903 | * @return float |
1917 | 1904 | * |
1918 | 1905 | */ |
@@ -2059,7 +2046,6 @@ discard block |
||
2059 | 2046 | * |
2060 | 2047 | * Returns the inverse of the normal cumulative distribution |
2061 | 2048 | * |
2062 | - * @param float $value |
|
2063 | 2049 | * @return float |
2064 | 2050 | * |
2065 | 2051 | * @todo Try implementing P J Acklam's refinement algorithm for greater |
@@ -2116,7 +2102,6 @@ discard block |
||
2116 | 2102 | * |
2117 | 2103 | * @access public |
2118 | 2104 | * @category Statistical Functions |
2119 | - * @param mixed $arg,... Data values |
|
2120 | 2105 | * @return float |
2121 | 2106 | */ |
2122 | 2107 | public static function MAX() { |
@@ -2152,7 +2137,6 @@ discard block |
||
2152 | 2137 | * |
2153 | 2138 | * @access public |
2154 | 2139 | * @category Statistical Functions |
2155 | - * @param mixed $arg,... Data values |
|
2156 | 2140 | * @return float |
2157 | 2141 | */ |
2158 | 2142 | public static function MAXA() { |
@@ -2193,7 +2177,6 @@ discard block |
||
2193 | 2177 | * |
2194 | 2178 | * @access public |
2195 | 2179 | * @category Mathematical and Trigonometric Functions |
2196 | - * @param mixed $arg,... Data values |
|
2197 | 2180 | * @param string $condition The criteria that defines which cells will be checked. |
2198 | 2181 | * @return float |
2199 | 2182 | */ |
@@ -2233,7 +2216,6 @@ discard block |
||
2233 | 2216 | * |
2234 | 2217 | * @access public |
2235 | 2218 | * @category Statistical Functions |
2236 | - * @param mixed $arg,... Data values |
|
2237 | 2219 | * @return float |
2238 | 2220 | */ |
2239 | 2221 | public static function MEDIAN() { |
@@ -2278,7 +2260,6 @@ discard block |
||
2278 | 2260 | * |
2279 | 2261 | * @access public |
2280 | 2262 | * @category Statistical Functions |
2281 | - * @param mixed $arg,... Data values |
|
2282 | 2263 | * @return float |
2283 | 2264 | */ |
2284 | 2265 | public static function MIN() { |
@@ -2314,7 +2295,6 @@ discard block |
||
2314 | 2295 | * |
2315 | 2296 | * @access public |
2316 | 2297 | * @category Statistical Functions |
2317 | - * @param mixed $arg,... Data values |
|
2318 | 2298 | * @return float |
2319 | 2299 | */ |
2320 | 2300 | public static function MINA() { |
@@ -2355,7 +2335,6 @@ discard block |
||
2355 | 2335 | * |
2356 | 2336 | * @access public |
2357 | 2337 | * @category Mathematical and Trigonometric Functions |
2358 | - * @param mixed $arg,... Data values |
|
2359 | 2338 | * @param string $condition The criteria that defines which cells will be checked. |
2360 | 2339 | * @return float |
2361 | 2340 | */ |
@@ -2429,7 +2408,6 @@ discard block |
||
2429 | 2408 | * |
2430 | 2409 | * @access public |
2431 | 2410 | * @category Statistical Functions |
2432 | - * @param mixed $arg,... Data values |
|
2433 | 2411 | * @return float |
2434 | 2412 | */ |
2435 | 2413 | public static function MODE() { |
@@ -2534,9 +2512,9 @@ discard block |
||
2534 | 2512 | * |
2535 | 2513 | * Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation. |
2536 | 2514 | * |
2537 | - * @param float $value |
|
2538 | 2515 | * @param float $mean Mean Value |
2539 | 2516 | * @param float $stdDev Standard Deviation |
2517 | + * @param double $probability |
|
2540 | 2518 | * @return float |
2541 | 2519 | * |
2542 | 2520 | */ |
@@ -2598,8 +2576,6 @@ discard block |
||
2598 | 2576 | * |
2599 | 2577 | * @access public |
2600 | 2578 | * @category Statistical Functions |
2601 | - * @param mixed $arg,... Data values |
|
2602 | - * @param float $entry Percentile value in the range 0..1, inclusive. |
|
2603 | 2579 | * @return float |
2604 | 2580 | */ |
2605 | 2581 | public static function PERCENTILE() { |
@@ -2759,8 +2735,6 @@ discard block |
||
2759 | 2735 | * |
2760 | 2736 | * @access public |
2761 | 2737 | * @category Statistical Functions |
2762 | - * @param mixed $arg,... Data values |
|
2763 | - * @param int $entry Quartile value in the range 1..3, inclusive. |
|
2764 | 2738 | * @return float |
2765 | 2739 | */ |
2766 | 2740 | public static function QUARTILE() { |
@@ -2918,8 +2892,6 @@ discard block |
||
2918 | 2892 | * |
2919 | 2893 | * @access public |
2920 | 2894 | * @category Statistical Functions |
2921 | - * @param mixed $arg,... Data values |
|
2922 | - * @param int $entry Position (ordered from the smallest) in the array or range of data to return |
|
2923 | 2895 | * @return float |
2924 | 2896 | */ |
2925 | 2897 | public static function SMALL() { |
@@ -2984,7 +2956,6 @@ discard block |
||
2984 | 2956 | * |
2985 | 2957 | * @access public |
2986 | 2958 | * @category Statistical Functions |
2987 | - * @param mixed $arg,... Data values |
|
2988 | 2959 | * @return float |
2989 | 2960 | */ |
2990 | 2961 | public static function STDEV() { |
@@ -3031,7 +3002,6 @@ discard block |
||
3031 | 3002 | * |
3032 | 3003 | * @access public |
3033 | 3004 | * @category Statistical Functions |
3034 | - * @param mixed $arg,... Data values |
|
3035 | 3005 | * @return float |
3036 | 3006 | */ |
3037 | 3007 | public static function STDEVA() { |
@@ -3083,7 +3053,6 @@ discard block |
||
3083 | 3053 | * |
3084 | 3054 | * @access public |
3085 | 3055 | * @category Statistical Functions |
3086 | - * @param mixed $arg,... Data values |
|
3087 | 3056 | * @return float |
3088 | 3057 | */ |
3089 | 3058 | public static function STDEVP() { |
@@ -3130,7 +3099,6 @@ discard block |
||
3130 | 3099 | * |
3131 | 3100 | * @access public |
3132 | 3101 | * @category Statistical Functions |
3133 | - * @param mixed $arg,... Data values |
|
3134 | 3102 | * @return float |
3135 | 3103 | */ |
3136 | 3104 | public static function STDEVPA() { |
@@ -3358,8 +3326,6 @@ discard block |
||
3358 | 3326 | * |
3359 | 3327 | * @access public |
3360 | 3328 | * @category Statistical Functions |
3361 | - * @param mixed $arg,... Data values |
|
3362 | - * @param float $discard Percentage to discard |
|
3363 | 3329 | * @return float |
3364 | 3330 | */ |
3365 | 3331 | public static function TRIMMEAN() { |
@@ -3401,7 +3367,6 @@ discard block |
||
3401 | 3367 | * |
3402 | 3368 | * @access public |
3403 | 3369 | * @category Statistical Functions |
3404 | - * @param mixed $arg,... Data values |
|
3405 | 3370 | * @return float |
3406 | 3371 | */ |
3407 | 3372 | public static function VARFunc() { |
@@ -3443,7 +3408,6 @@ discard block |
||
3443 | 3408 | * |
3444 | 3409 | * @access public |
3445 | 3410 | * @category Statistical Functions |
3446 | - * @param mixed $arg,... Data values |
|
3447 | 3411 | * @return float |
3448 | 3412 | */ |
3449 | 3413 | public static function VARA() { |
@@ -3496,7 +3460,6 @@ discard block |
||
3496 | 3460 | * |
3497 | 3461 | * @access public |
3498 | 3462 | * @category Statistical Functions |
3499 | - * @param mixed $arg,... Data values |
|
3500 | 3463 | * @return float |
3501 | 3464 | */ |
3502 | 3465 | public static function VARP() { |
@@ -3538,7 +3501,6 @@ discard block |
||
3538 | 3501 | * |
3539 | 3502 | * @access public |
3540 | 3503 | * @category Statistical Functions |
3541 | - * @param mixed $arg,... Data values |
|
3542 | 3504 | * @return float |
3543 | 3505 | */ |
3544 | 3506 | public static function VARPA() { |
@@ -3621,10 +3583,6 @@ discard block |
||
3621 | 3583 | * Returns the Weibull distribution. Use this distribution in reliability |
3622 | 3584 | * analysis, such as calculating a device's mean time to failure. |
3623 | 3585 | * |
3624 | - * @param float $value |
|
3625 | - * @param float $alpha Alpha Parameter |
|
3626 | - * @param float $beta Beta Parameter |
|
3627 | - * @param boolean $cumulative |
|
3628 | 3586 | * @return float |
3629 | 3587 | * |
3630 | 3588 | */ |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | -require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/trendClass.php'; |
|
39 | +require_once PHPEXCEL_ROOT.'PHPExcel/Shared/trend/trendClass.php'; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** LOG_GAMMA_X_MAX_VALUE */ |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | class PHPExcel_Calculation_Statistical { |
63 | 63 | |
64 | 64 | |
65 | - private static function _checkTrendArrays(&$array1,&$array2) { |
|
66 | - if (!is_array($array1)) { $array1 = array($array1); } |
|
67 | - if (!is_array($array2)) { $array2 = array($array2); } |
|
65 | + private static function _checkTrendArrays(&$array1, &$array2) { |
|
66 | + if ( ! is_array($array1)) { $array1 = array($array1); } |
|
67 | + if ( ! is_array($array2)) { $array2 = array($array2); } |
|
68 | 68 | |
69 | 69 | $array1 = PHPExcel_Calculation_Functions::flattenArray($array1); |
70 | 70 | $array2 = PHPExcel_Calculation_Functions::flattenArray($array2); |
71 | - foreach($array1 as $key => $value) { |
|
71 | + foreach ($array1 as $key => $value) { |
|
72 | 72 | if ((is_bool($value)) || (is_string($value)) || (is_null($value))) { |
73 | 73 | unset($array1[$key]); |
74 | 74 | unset($array2[$key]); |
75 | 75 | } |
76 | 76 | } |
77 | - foreach($array2 as $key => $value) { |
|
77 | + foreach ($array2 as $key => $value) { |
|
78 | 78 | if ((is_bool($value)) || (is_string($value)) || (is_null($value))) { |
79 | 79 | unset($array1[$key]); |
80 | 80 | unset($array2[$key]); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // Function cache for _logBeta function |
138 | 138 | private static $_logBetaCache_p = 0.0; |
139 | 139 | private static $_logBetaCache_q = 0.0; |
140 | - private static $_logBetaCache_result = 0.0; |
|
140 | + private static $_logBetaCache_result = 0.0; |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * The natural logarithm of the beta function. |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | } |
178 | 178 | $h = 1.0 / $h; |
179 | 179 | $frac = $h; |
180 | - $m = 1; |
|
180 | + $m = 1; |
|
181 | 181 | $delta = 0.0; |
182 | - while ($m <= MAX_ITERATIONS && abs($delta-1.0) > PRECISION ) { |
|
182 | + while ($m <= MAX_ITERATIONS && abs($delta - 1.0) > PRECISION) { |
|
183 | 183 | $m2 = 2 * $m; |
184 | 184 | // even index for d |
185 | - $d = $m * ($q - $m) * $x / ( ($p_minus + $m2) * ($p + $m2)); |
|
185 | + $d = $m * ($q - $m) * $x / (($p_minus + $m2) * ($p + $m2)); |
|
186 | 186 | $h = 1.0 + $d * $h; |
187 | 187 | if (abs($h) < XMININ) { |
188 | 188 | $h = XMININ; |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | */ |
257 | 257 | |
258 | 258 | // Function cache for logGamma |
259 | - private static $_logGammaCache_result = 0.0; |
|
260 | - private static $_logGammaCache_x = 0.0; |
|
259 | + private static $_logGammaCache_result = 0.0; |
|
260 | + private static $_logGammaCache_x = 0.0; |
|
261 | 261 | |
262 | 262 | private static function _logGamma($x) { |
263 | 263 | // Log Gamma related constants |
@@ -265,57 +265,57 @@ discard block |
||
265 | 265 | static $lg_d2 = 0.4227843350984671393993777; |
266 | 266 | static $lg_d4 = 1.791759469228055000094023; |
267 | 267 | |
268 | - static $lg_p1 = array( 4.945235359296727046734888, |
|
268 | + static $lg_p1 = array(4.945235359296727046734888, |
|
269 | 269 | 201.8112620856775083915565, |
270 | 270 | 2290.838373831346393026739, |
271 | 271 | 11319.67205903380828685045, |
272 | 272 | 28557.24635671635335736389, |
273 | 273 | 38484.96228443793359990269, |
274 | 274 | 26377.48787624195437963534, |
275 | - 7225.813979700288197698961 ); |
|
276 | - static $lg_p2 = array( 4.974607845568932035012064, |
|
275 | + 7225.813979700288197698961); |
|
276 | + static $lg_p2 = array(4.974607845568932035012064, |
|
277 | 277 | 542.4138599891070494101986, |
278 | 278 | 15506.93864978364947665077, |
279 | 279 | 184793.2904445632425417223, |
280 | 280 | 1088204.76946882876749847, |
281 | 281 | 3338152.967987029735917223, |
282 | 282 | 5106661.678927352456275255, |
283 | - 3074109.054850539556250927 ); |
|
284 | - static $lg_p4 = array( 14745.02166059939948905062, |
|
283 | + 3074109.054850539556250927); |
|
284 | + static $lg_p4 = array(14745.02166059939948905062, |
|
285 | 285 | 2426813.369486704502836312, |
286 | 286 | 121475557.4045093227939592, |
287 | 287 | 2663432449.630976949898078, |
288 | 288 | 29403789566.34553899906876, |
289 | 289 | 170266573776.5398868392998, |
290 | 290 | 492612579337.743088758812, |
291 | - 560625185622.3951465078242 ); |
|
291 | + 560625185622.3951465078242); |
|
292 | 292 | |
293 | - static $lg_q1 = array( 67.48212550303777196073036, |
|
293 | + static $lg_q1 = array(67.48212550303777196073036, |
|
294 | 294 | 1113.332393857199323513008, |
295 | 295 | 7738.757056935398733233834, |
296 | 296 | 27639.87074403340708898585, |
297 | 297 | 54993.10206226157329794414, |
298 | 298 | 61611.22180066002127833352, |
299 | 299 | 36351.27591501940507276287, |
300 | - 8785.536302431013170870835 ); |
|
301 | - static $lg_q2 = array( 183.0328399370592604055942, |
|
300 | + 8785.536302431013170870835); |
|
301 | + static $lg_q2 = array(183.0328399370592604055942, |
|
302 | 302 | 7765.049321445005871323047, |
303 | 303 | 133190.3827966074194402448, |
304 | 304 | 1136705.821321969608938755, |
305 | 305 | 5267964.117437946917577538, |
306 | 306 | 13467014.54311101692290052, |
307 | 307 | 17827365.30353274213975932, |
308 | - 9533095.591844353613395747 ); |
|
309 | - static $lg_q4 = array( 2690.530175870899333379843, |
|
308 | + 9533095.591844353613395747); |
|
309 | + static $lg_q4 = array(2690.530175870899333379843, |
|
310 | 310 | 639388.5654300092398984238, |
311 | 311 | 41355999.30241388052042842, |
312 | 312 | 1120872109.61614794137657, |
313 | 313 | 14886137286.78813811542398, |
314 | 314 | 101680358627.2438228077304, |
315 | 315 | 341747634550.7377132798597, |
316 | - 446315818741.9713286462081 ); |
|
316 | + 446315818741.9713286462081); |
|
317 | 317 | |
318 | - static $lg_c = array( -0.001910444077728, |
|
318 | + static $lg_c = array( -0.001910444077728, |
|
319 | 319 | 8.4171387781295e-4, |
320 | 320 | -5.952379913043012e-4, |
321 | 321 | 7.93650793500350248e-4, |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | // Rough estimate of the fourth root of logGamma_xBig |
327 | 327 | static $lg_frtbig = 2.25e76; |
328 | - static $pnt68 = 0.6796875; |
|
328 | + static $pnt68 = 0.6796875; |
|
329 | 329 | |
330 | 330 | |
331 | 331 | if ($x == self::$_logGammaCache_x) { |
@@ -422,17 +422,17 @@ discard block |
||
422 | 422 | // |
423 | 423 | // Private implementation of the incomplete Gamma function |
424 | 424 | // |
425 | - private static function _incompleteGamma($a,$x) { |
|
425 | + private static function _incompleteGamma($a, $x) { |
|
426 | 426 | static $max = 32; |
427 | 427 | $summer = 0; |
428 | - for ($n=0; $n<=$max; ++$n) { |
|
428 | + for ($n = 0; $n <= $max; ++$n) { |
|
429 | 429 | $divisor = $a; |
430 | - for ($i=1; $i<=$n; ++$i) { |
|
430 | + for ($i = 1; $i <= $n; ++$i) { |
|
431 | 431 | $divisor *= ($a + $i); |
432 | 432 | } |
433 | - $summer += (pow($x,$n) / $divisor); |
|
433 | + $summer += (pow($x, $n) / $divisor); |
|
434 | 434 | } |
435 | - return pow($x,$a) * exp(0-$x) * $summer; |
|
435 | + return pow($x, $a) * exp(0 - $x) * $summer; |
|
436 | 436 | } // function _incompleteGamma() |
437 | 437 | |
438 | 438 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | if ($data == 0.0) return 0; |
444 | 444 | |
445 | 445 | static $p0 = 1.000000000190015; |
446 | - static $p = array ( 1 => 76.18009172947146, |
|
446 | + static $p = array(1 => 76.18009172947146, |
|
447 | 447 | 2 => -86.50532032941677, |
448 | 448 | 3 => 24.01409824083091, |
449 | 449 | 4 => -1.231739572450155, |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $tmp -= ($x + 0.5) * log($tmp); |
457 | 457 | |
458 | 458 | $summer = $p0; |
459 | - for ($j=1;$j<=6;++$j) { |
|
459 | + for ($j = 1; $j <= 6; ++$j) { |
|
460 | 460 | $summer += ($p[$j] / ++$y); |
461 | 461 | } |
462 | 462 | return exp(0 - $tmp + log(SQRT2PI * $summer / $x)); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | // Input paramater is $p - probability - where 0 < p < 1. |
486 | 486 | |
487 | 487 | // Coefficients in rational approximations |
488 | - static $a = array( 1 => -3.969683028665376e+01, |
|
488 | + static $a = array(1 => -3.969683028665376e+01, |
|
489 | 489 | 2 => 2.209460984245205e+02, |
490 | 490 | 3 => -2.759285104469687e+02, |
491 | 491 | 4 => 1.383577518672690e+02, |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | 6 => 2.506628277459239e+00 |
494 | 494 | ); |
495 | 495 | |
496 | - static $b = array( 1 => -5.447609879822406e+01, |
|
496 | + static $b = array(1 => -5.447609879822406e+01, |
|
497 | 497 | 2 => 1.615858368580409e+02, |
498 | 498 | 3 => -1.556989798598866e+02, |
499 | 499 | 4 => 6.680131188771972e+01, |
500 | 500 | 5 => -1.328068155288572e+01 |
501 | 501 | ); |
502 | 502 | |
503 | - static $c = array( 1 => -7.784894002430293e-03, |
|
503 | + static $c = array(1 => -7.784894002430293e-03, |
|
504 | 504 | 2 => -3.223964580411365e-01, |
505 | 505 | 3 => -2.400758277161838e+00, |
506 | 506 | 4 => -2.549732539343734e+00, |
@@ -508,15 +508,15 @@ discard block |
||
508 | 508 | 6 => 2.938163982698783e+00 |
509 | 509 | ); |
510 | 510 | |
511 | - static $d = array( 1 => 7.784695709041462e-03, |
|
511 | + static $d = array(1 => 7.784695709041462e-03, |
|
512 | 512 | 2 => 3.224671290700398e-01, |
513 | 513 | 3 => 2.445134137142996e+00, |
514 | 514 | 4 => 3.754408661907416e+00 |
515 | 515 | ); |
516 | 516 | |
517 | 517 | // Define lower and upper region break-points. |
518 | - $p_low = 0.02425; //Use lower region approx. below this |
|
519 | - $p_high = 1 - $p_low; //Use upper region approx. above this |
|
518 | + $p_low = 0.02425; //Use lower region approx. below this |
|
519 | + $p_high = 1 - $p_low; //Use upper region approx. above this |
|
520 | 520 | |
521 | 521 | if (0 < $p && $p < $p_low) { |
522 | 522 | // Rational approximation for lower region. |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | } else { |
663 | 663 | $R = 1 - $p; |
664 | 664 | } |
665 | - $R = pow(-log($R),2); |
|
665 | + $R = pow(-log($R), 2); |
|
666 | 666 | |
667 | 667 | // computation for p not close to 0, 0.5 or 1. |
668 | 668 | If ($R <= $split2) { |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | $aCount = 0; |
709 | 709 | foreach ($aArgs as $k => $arg) { |
710 | 710 | if ((is_bool($arg)) && |
711 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
711 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
712 | 712 | $arg = (integer) $arg; |
713 | 713 | } |
714 | 714 | // Is it a numeric value? |
715 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
715 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
716 | 716 | if (is_null($returnValue)) { |
717 | 717 | $returnValue = abs($arg - $aMean); |
718 | 718 | } else { |
@@ -751,11 +751,11 @@ discard block |
||
751 | 751 | // Loop through arguments |
752 | 752 | foreach (PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()) as $k => $arg) { |
753 | 753 | if ((is_bool($arg)) && |
754 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
754 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
755 | 755 | $arg = (integer) $arg; |
756 | 756 | } |
757 | 757 | // Is it a numeric value? |
758 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
758 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
759 | 759 | if (is_null($returnValue)) { |
760 | 760 | $returnValue = $arg; |
761 | 761 | } else { |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | // Loop through arguments |
796 | 796 | foreach (PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()) as $k => $arg) { |
797 | 797 | if ((is_bool($arg)) && |
798 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
798 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
799 | 799 | } else { |
800 | 800 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) { |
801 | 801 | if (is_bool($arg)) { |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | * @param string $condition The criteria that defines which cells will be checked. |
837 | 837 | * @return float |
838 | 838 | */ |
839 | - public static function AVERAGEIF($aArgs,$condition,$averageArgs = array()) { |
|
839 | + public static function AVERAGEIF($aArgs, $condition, $averageArgs = array()) { |
|
840 | 840 | // Return value |
841 | 841 | $returnValue = 0; |
842 | 842 | |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | // Loop through arguments |
850 | 850 | $aCount = 0; |
851 | 851 | foreach ($aArgs as $key => $arg) { |
852 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
852 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
853 | 853 | $testCondition = '='.$arg.$condition; |
854 | 854 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
855 | 855 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * @return float |
881 | 881 | * |
882 | 882 | */ |
883 | - public static function BETADIST($value,$alpha,$beta,$rMin=0,$rMax=1) { |
|
883 | + public static function BETADIST($value, $alpha, $beta, $rMin = 0, $rMax = 1) { |
|
884 | 884 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
885 | 885 | $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
886 | 886 | $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | } |
899 | 899 | $value -= $rMin; |
900 | 900 | $value /= ($rMax - $rMin); |
901 | - return self::_incompleteBeta($value,$alpha,$beta); |
|
901 | + return self::_incompleteBeta($value, $alpha, $beta); |
|
902 | 902 | } |
903 | 903 | return PHPExcel_Calculation_Functions::VALUE(); |
904 | 904 | } // function BETADIST() |
@@ -916,9 +916,9 @@ discard block |
||
916 | 916 | * @return float |
917 | 917 | * |
918 | 918 | */ |
919 | - public static function BETAINV($probability,$alpha,$beta,$rMin=0,$rMax=1) { |
|
920 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
921 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
919 | + public static function BETAINV($probability, $alpha, $beta, $rMin = 0, $rMax = 1) { |
|
920 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
921 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
922 | 922 | $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
923 | 923 | $rMin = PHPExcel_Calculation_Functions::flattenSingleValue($rMin); |
924 | 924 | $rMax = PHPExcel_Calculation_Functions::flattenSingleValue($rMax); |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | if ($i == MAX_ITERATIONS) { |
951 | 951 | return PHPExcel_Calculation_Functions::NA(); |
952 | 952 | } |
953 | - return round($rMin + $guess * ($rMax - $rMin),12); |
|
953 | + return round($rMin + $guess * ($rMax - $rMin), 12); |
|
954 | 954 | } |
955 | 955 | return PHPExcel_Calculation_Functions::VALUE(); |
956 | 956 | } // function BETAINV() |
@@ -975,9 +975,9 @@ discard block |
||
975 | 975 | * |
976 | 976 | */ |
977 | 977 | public static function BINOMDIST($value, $trials, $probability, $cumulative) { |
978 | - $value = floor(PHPExcel_Calculation_Functions::flattenSingleValue($value)); |
|
979 | - $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
980 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
978 | + $value = floor(PHPExcel_Calculation_Functions::flattenSingleValue($value)); |
|
979 | + $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
980 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
981 | 981 | |
982 | 982 | if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) { |
983 | 983 | if (($value < 0) || ($value > $trials)) { |
@@ -990,11 +990,11 @@ discard block |
||
990 | 990 | if ($cumulative) { |
991 | 991 | $summer = 0; |
992 | 992 | for ($i = 0; $i <= $value; ++$i) { |
993 | - $summer += PHPExcel_Calculation_MathTrig::COMBIN($trials,$i) * pow($probability,$i) * pow(1 - $probability,$trials - $i); |
|
993 | + $summer += PHPExcel_Calculation_MathTrig::COMBIN($trials, $i) * pow($probability, $i) * pow(1 - $probability, $trials - $i); |
|
994 | 994 | } |
995 | 995 | return $summer; |
996 | 996 | } else { |
997 | - return PHPExcel_Calculation_MathTrig::COMBIN($trials,$value) * pow($probability,$value) * pow(1 - $probability,$trials - $value) ; |
|
997 | + return PHPExcel_Calculation_MathTrig::COMBIN($trials, $value) * pow($probability, $value) * pow(1 - $probability, $trials - $value); |
|
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | } |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | * @return float |
1013 | 1013 | */ |
1014 | 1014 | public static function CHIDIST($value, $degrees) { |
1015 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1016 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1015 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1016 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1017 | 1017 | |
1018 | 1018 | if ((is_numeric($value)) && (is_numeric($degrees))) { |
1019 | 1019 | if ($degrees < 1) { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | return PHPExcel_Calculation_Functions::NaN(); |
1027 | 1027 | } |
1028 | - return 1 - (self::_incompleteGamma($degrees/2,$value/2) / self::_gamma($degrees/2)); |
|
1028 | + return 1 - (self::_incompleteGamma($degrees / 2, $value / 2) / self::_gamma($degrees / 2)); |
|
1029 | 1029 | } |
1030 | 1030 | return PHPExcel_Calculation_Functions::VALUE(); |
1031 | 1031 | } // function CHIDIST() |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | * @return float |
1042 | 1042 | */ |
1043 | 1043 | public static function CHIINV($probability, $degrees) { |
1044 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1045 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1044 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1045 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1046 | 1046 | |
1047 | 1047 | if ((is_numeric($probability)) && (is_numeric($degrees))) { |
1048 | 1048 | |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | $xHi = 0; |
1051 | 1051 | |
1052 | 1052 | $x = $xNew = 1; |
1053 | - $dx = 1; |
|
1053 | + $dx = 1; |
|
1054 | 1054 | $i = 0; |
1055 | 1055 | |
1056 | 1056 | while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | if ($i == MAX_ITERATIONS) { |
1082 | 1082 | return PHPExcel_Calculation_Functions::NA(); |
1083 | 1083 | } |
1084 | - return round($x,12); |
|
1084 | + return round($x, 12); |
|
1085 | 1085 | } |
1086 | 1086 | return PHPExcel_Calculation_Functions::VALUE(); |
1087 | 1087 | } // function CHIINV() |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | * @return float |
1099 | 1099 | * |
1100 | 1100 | */ |
1101 | - public static function CONFIDENCE($alpha,$stdDev,$size) { |
|
1102 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1103 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
1104 | - $size = floor(PHPExcel_Calculation_Functions::flattenSingleValue($size)); |
|
1101 | + public static function CONFIDENCE($alpha, $stdDev, $size) { |
|
1102 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1103 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
1104 | + $size = floor(PHPExcel_Calculation_Functions::flattenSingleValue($size)); |
|
1105 | 1105 | |
1106 | 1106 | if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) { |
1107 | 1107 | if (($alpha <= 0) || ($alpha >= 1)) { |
@@ -1125,11 +1125,11 @@ discard block |
||
1125 | 1125 | * @param array of mixed Data Series X |
1126 | 1126 | * @return float |
1127 | 1127 | */ |
1128 | - public static function CORREL($yValues,$xValues=null) { |
|
1129 | - if ((is_null($xValues)) || (!is_array($yValues)) || (!is_array($xValues))) { |
|
1128 | + public static function CORREL($yValues, $xValues = null) { |
|
1129 | + if ((is_null($xValues)) || ( ! is_array($yValues)) || ( ! is_array($xValues))) { |
|
1130 | 1130 | return PHPExcel_Calculation_Functions::VALUE(); |
1131 | 1131 | } |
1132 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1132 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1133 | 1133 | return PHPExcel_Calculation_Functions::VALUE(); |
1134 | 1134 | } |
1135 | 1135 | $yValueCount = count($yValues); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | return PHPExcel_Calculation_Functions::DIV0(); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1144 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1145 | 1145 | return $bestFitLinear->getCorrelation(); |
1146 | 1146 | } // function CORREL() |
1147 | 1147 | |
@@ -1167,11 +1167,11 @@ discard block |
||
1167 | 1167 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
1168 | 1168 | foreach ($aArgs as $k => $arg) { |
1169 | 1169 | if ((is_bool($arg)) && |
1170 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1170 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1171 | 1171 | $arg = (integer) $arg; |
1172 | 1172 | } |
1173 | 1173 | // Is it a numeric value? |
1174 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1174 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1175 | 1175 | ++$returnValue; |
1176 | 1176 | } |
1177 | 1177 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * @param string $condition The criteria that defines which cells will be counted. |
1258 | 1258 | * @return int |
1259 | 1259 | */ |
1260 | - public static function COUNTIF($aArgs,$condition) { |
|
1260 | + public static function COUNTIF($aArgs, $condition) { |
|
1261 | 1261 | // Return value |
1262 | 1262 | $returnValue = 0; |
1263 | 1263 | |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
1266 | 1266 | // Loop through arguments |
1267 | 1267 | foreach ($aArgs as $arg) { |
1268 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
1268 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
1269 | 1269 | $testCondition = '='.$arg.$condition; |
1270 | 1270 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
1271 | 1271 | // Is it a value within our criteria |
@@ -1287,8 +1287,8 @@ discard block |
||
1287 | 1287 | * @param array of mixed Data Series X |
1288 | 1288 | * @return float |
1289 | 1289 | */ |
1290 | - public static function COVAR($yValues,$xValues) { |
|
1291 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1290 | + public static function COVAR($yValues, $xValues) { |
|
1291 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1292 | 1292 | return PHPExcel_Calculation_Functions::VALUE(); |
1293 | 1293 | } |
1294 | 1294 | $yValueCount = count($yValues); |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | return PHPExcel_Calculation_Functions::DIV0(); |
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1303 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1304 | 1304 | return $bestFitLinear->getCovariance(); |
1305 | 1305 | } // function COVAR() |
1306 | 1306 | |
@@ -1325,9 +1325,9 @@ discard block |
||
1325 | 1325 | * |
1326 | 1326 | */ |
1327 | 1327 | public static function CRITBINOM($trials, $probability, $alpha) { |
1328 | - $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
1329 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1330 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1328 | + $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
1329 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1330 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1331 | 1331 | |
1332 | 1332 | if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) { |
1333 | 1333 | if ($trials < 0) { |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | $t = sqrt(log(1 / ($alpha * $alpha))); |
1344 | 1344 | $trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t)); |
1345 | 1345 | } else { |
1346 | - $t = sqrt(log(1 / pow(1 - $alpha,2))); |
|
1346 | + $t = sqrt(log(1 / pow(1 - $alpha, 2))); |
|
1347 | 1347 | $trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t); |
1348 | 1348 | } |
1349 | 1349 | $Guess = floor($trials * $probability + $trialsApprox * sqrt($trials * $probability * (1 - $probability))); |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | $PreviousValue = 1; |
1365 | 1365 | $Done = False; |
1366 | 1366 | $k = $m + 1; |
1367 | - while ((!$Done) && ($k <= $trials)) { |
|
1367 | + while (( ! $Done) && ($k <= $trials)) { |
|
1368 | 1368 | $CurrentValue = $PreviousValue * ($trials - $k + 1) * $probability / ($k * (1 - $probability)); |
1369 | 1369 | $TotalUnscaledProbability += $CurrentValue; |
1370 | 1370 | if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; } |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | $PreviousValue = 1; |
1378 | 1378 | $Done = False; |
1379 | 1379 | $k = $m - 1; |
1380 | - while ((!$Done) && ($k >= 0)) { |
|
1380 | + while (( ! $Done) && ($k >= 0)) { |
|
1381 | 1381 | $CurrentValue = $PreviousValue * $k + 1 * (1 - $probability) / (($trials - $k) * $probability); |
1382 | 1382 | $TotalUnscaledProbability += $CurrentValue; |
1383 | 1383 | if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; } |
@@ -1440,14 +1440,14 @@ discard block |
||
1440 | 1440 | foreach ($aArgs as $k => $arg) { |
1441 | 1441 | // Is it a numeric value? |
1442 | 1442 | if ((is_bool($arg)) && |
1443 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1443 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1444 | 1444 | $arg = (integer) $arg; |
1445 | 1445 | } |
1446 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1446 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1447 | 1447 | if (is_null($returnValue)) { |
1448 | - $returnValue = pow(($arg - $aMean),2); |
|
1448 | + $returnValue = pow(($arg - $aMean), 2); |
|
1449 | 1449 | } else { |
1450 | - $returnValue += pow(($arg - $aMean),2); |
|
1450 | + $returnValue += pow(($arg - $aMean), 2); |
|
1451 | 1451 | } |
1452 | 1452 | ++$aCount; |
1453 | 1453 | } |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | * @return float |
1478 | 1478 | */ |
1479 | 1479 | public static function EXPONDIST($value, $lambda, $cumulative) { |
1480 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1481 | - $lambda = PHPExcel_Calculation_Functions::flattenSingleValue($lambda); |
|
1482 | - $cumulative = PHPExcel_Calculation_Functions::flattenSingleValue($cumulative); |
|
1480 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1481 | + $lambda = PHPExcel_Calculation_Functions::flattenSingleValue($lambda); |
|
1482 | + $cumulative = PHPExcel_Calculation_Functions::flattenSingleValue($cumulative); |
|
1483 | 1483 | |
1484 | 1484 | if ((is_numeric($value)) && (is_numeric($lambda))) { |
1485 | 1485 | if (($value < 0) || ($lambda < 0)) { |
@@ -1487,9 +1487,9 @@ discard block |
||
1487 | 1487 | } |
1488 | 1488 | if ((is_numeric($cumulative)) || (is_bool($cumulative))) { |
1489 | 1489 | if ($cumulative) { |
1490 | - return 1 - exp(0-$value*$lambda); |
|
1490 | + return 1 - exp(0 - $value * $lambda); |
|
1491 | 1491 | } else { |
1492 | - return $lambda * exp(0-$value*$lambda); |
|
1492 | + return $lambda * exp(0 - $value * $lambda); |
|
1493 | 1493 | } |
1494 | 1494 | } |
1495 | 1495 | } |
@@ -1508,13 +1508,13 @@ discard block |
||
1508 | 1508 | * @return float |
1509 | 1509 | */ |
1510 | 1510 | public static function FISHER($value) { |
1511 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1511 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1512 | 1512 | |
1513 | 1513 | if (is_numeric($value)) { |
1514 | 1514 | if (($value <= -1) || ($value >= 1)) { |
1515 | 1515 | return PHPExcel_Calculation_Functions::NaN(); |
1516 | 1516 | } |
1517 | - return 0.5 * log((1+$value)/(1-$value)); |
|
1517 | + return 0.5 * log((1 + $value) / (1 - $value)); |
|
1518 | 1518 | } |
1519 | 1519 | return PHPExcel_Calculation_Functions::VALUE(); |
1520 | 1520 | } // function FISHER() |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | * @return float |
1532 | 1532 | */ |
1533 | 1533 | public static function FISHERINV($value) { |
1534 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1534 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1535 | 1535 | |
1536 | 1536 | if (is_numeric($value)) { |
1537 | 1537 | return (exp(2 * $value) - 1) / (exp(2 * $value) + 1); |
@@ -1550,13 +1550,13 @@ discard block |
||
1550 | 1550 | * @param array of mixed Data Series X |
1551 | 1551 | * @return float |
1552 | 1552 | */ |
1553 | - public static function FORECAST($xValue,$yValues,$xValues) { |
|
1554 | - $xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue); |
|
1555 | - if (!is_numeric($xValue)) { |
|
1553 | + public static function FORECAST($xValue, $yValues, $xValues) { |
|
1554 | + $xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue); |
|
1555 | + if ( ! is_numeric($xValue)) { |
|
1556 | 1556 | return PHPExcel_Calculation_Functions::VALUE(); |
1557 | 1557 | } |
1558 | 1558 | |
1559 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1559 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1560 | 1560 | return PHPExcel_Calculation_Functions::VALUE(); |
1561 | 1561 | } |
1562 | 1562 | $yValueCount = count($yValues); |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | return PHPExcel_Calculation_Functions::DIV0(); |
1569 | 1569 | } |
1570 | 1570 | |
1571 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1571 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1572 | 1572 | return $bestFitLinear->getValueOfYForX($xValue); |
1573 | 1573 | } // function FORECAST() |
1574 | 1574 | |
@@ -1585,8 +1585,8 @@ discard block |
||
1585 | 1585 | * @return float |
1586 | 1586 | * |
1587 | 1587 | */ |
1588 | - public static function GAMMADIST($value,$a,$b,$cumulative) { |
|
1589 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1588 | + public static function GAMMADIST($value, $a, $b, $cumulative) { |
|
1589 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1590 | 1590 | $a = PHPExcel_Calculation_Functions::flattenSingleValue($a); |
1591 | 1591 | $b = PHPExcel_Calculation_Functions::flattenSingleValue($b); |
1592 | 1592 | |
@@ -1596,9 +1596,9 @@ discard block |
||
1596 | 1596 | } |
1597 | 1597 | if ((is_numeric($cumulative)) || (is_bool($cumulative))) { |
1598 | 1598 | if ($cumulative) { |
1599 | - return self::_incompleteGamma($a,$value / $b) / self::_gamma($a); |
|
1599 | + return self::_incompleteGamma($a, $value / $b) / self::_gamma($a); |
|
1600 | 1600 | } else { |
1601 | - return (1 / (pow($b,$a) * self::_gamma($a))) * pow($value,$a-1) * exp(0-($value / $b)); |
|
1601 | + return (1 / (pow($b, $a) * self::_gamma($a))) * pow($value, $a - 1) * exp(0 - ($value / $b)); |
|
1602 | 1602 | } |
1603 | 1603 | } |
1604 | 1604 | } |
@@ -1617,10 +1617,10 @@ discard block |
||
1617 | 1617 | * @return float |
1618 | 1618 | * |
1619 | 1619 | */ |
1620 | - public static function GAMMAINV($probability,$alpha,$beta) { |
|
1621 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1622 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1623 | - $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
1620 | + public static function GAMMAINV($probability, $alpha, $beta) { |
|
1621 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1622 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1623 | + $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
1624 | 1624 | |
1625 | 1625 | if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) { |
1626 | 1626 | if (($alpha <= 0) || ($beta <= 0) || ($probability < 0) || ($probability > 1)) { |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | |
1633 | 1633 | $x = $xNew = 1; |
1634 | 1634 | $error = $pdf = 0; |
1635 | - $dx = 1024; |
|
1635 | + $dx = 1024; |
|
1636 | 1636 | $i = 0; |
1637 | 1637 | |
1638 | 1638 | while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { |
@@ -1676,7 +1676,7 @@ discard block |
||
1676 | 1676 | * @return float |
1677 | 1677 | */ |
1678 | 1678 | public static function GAMMALN($value) { |
1679 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1679 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1680 | 1680 | |
1681 | 1681 | if (is_numeric($value)) { |
1682 | 1682 | if ($value <= 0) { |
@@ -1708,7 +1708,7 @@ discard block |
||
1708 | 1708 | |
1709 | 1709 | $aMean = PHPExcel_Calculation_MathTrig::PRODUCT($aArgs); |
1710 | 1710 | if (is_numeric($aMean) && ($aMean > 0)) { |
1711 | - $aCount = self::COUNT($aArgs) ; |
|
1711 | + $aCount = self::COUNT($aArgs); |
|
1712 | 1712 | if (self::MIN($aArgs) > 0) { |
1713 | 1713 | return pow($aMean, (1 / $aCount)); |
1714 | 1714 | } |
@@ -1728,19 +1728,19 @@ discard block |
||
1728 | 1728 | * @param boolean A logical value specifying whether to force the intersect to equal 0. |
1729 | 1729 | * @return array of float |
1730 | 1730 | */ |
1731 | - public static function GROWTH($yValues,$xValues=array(),$newValues=array(),$const=True) { |
|
1731 | + public static function GROWTH($yValues, $xValues = array(), $newValues = array(), $const = True) { |
|
1732 | 1732 | $yValues = PHPExcel_Calculation_Functions::flattenArray($yValues); |
1733 | 1733 | $xValues = PHPExcel_Calculation_Functions::flattenArray($xValues); |
1734 | 1734 | $newValues = PHPExcel_Calculation_Functions::flattenArray($newValues); |
1735 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1735 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1736 | 1736 | |
1737 | - $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const); |
|
1737 | + $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
1738 | 1738 | if (empty($newValues)) { |
1739 | 1739 | $newValues = $bestFitExponential->getXValues(); |
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | $returnArray = array(); |
1743 | - foreach($newValues as $xValue) { |
|
1743 | + foreach ($newValues as $xValue) { |
|
1744 | 1744 | $returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue); |
1745 | 1745 | } |
1746 | 1746 | |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | $aCount = 0; |
1775 | 1775 | foreach ($aArgs as $arg) { |
1776 | 1776 | // Is it a numeric value? |
1777 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1777 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1778 | 1778 | if ($arg <= 0) { |
1779 | 1779 | return PHPExcel_Calculation_Functions::NaN(); |
1780 | 1780 | } |
@@ -1810,10 +1810,10 @@ discard block |
||
1810 | 1810 | * |
1811 | 1811 | */ |
1812 | 1812 | public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber) { |
1813 | - $sampleSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleSuccesses)); |
|
1814 | - $sampleNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleNumber)); |
|
1815 | - $populationSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationSuccesses)); |
|
1816 | - $populationNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationNumber)); |
|
1813 | + $sampleSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleSuccesses)); |
|
1814 | + $sampleNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleNumber)); |
|
1815 | + $populationSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationSuccesses)); |
|
1816 | + $populationNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationNumber)); |
|
1817 | 1817 | |
1818 | 1818 | if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) { |
1819 | 1819 | if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) { |
@@ -1825,9 +1825,9 @@ discard block |
||
1825 | 1825 | if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) { |
1826 | 1826 | return PHPExcel_Calculation_Functions::NaN(); |
1827 | 1827 | } |
1828 | - return PHPExcel_Calculation_MathTrig::COMBIN($populationSuccesses,$sampleSuccesses) * |
|
1829 | - PHPExcel_Calculation_MathTrig::COMBIN($populationNumber - $populationSuccesses,$sampleNumber - $sampleSuccesses) / |
|
1830 | - PHPExcel_Calculation_MathTrig::COMBIN($populationNumber,$sampleNumber); |
|
1828 | + return PHPExcel_Calculation_MathTrig::COMBIN($populationSuccesses, $sampleSuccesses) * |
|
1829 | + PHPExcel_Calculation_MathTrig::COMBIN($populationNumber - $populationSuccesses, $sampleNumber - $sampleSuccesses) / |
|
1830 | + PHPExcel_Calculation_MathTrig::COMBIN($populationNumber, $sampleNumber); |
|
1831 | 1831 | } |
1832 | 1832 | return PHPExcel_Calculation_Functions::VALUE(); |
1833 | 1833 | } // function HYPGEOMDIST() |
@@ -1842,8 +1842,8 @@ discard block |
||
1842 | 1842 | * @param array of mixed Data Series X |
1843 | 1843 | * @return float |
1844 | 1844 | */ |
1845 | - public static function INTERCEPT($yValues,$xValues) { |
|
1846 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1845 | + public static function INTERCEPT($yValues, $xValues) { |
|
1846 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1847 | 1847 | return PHPExcel_Calculation_Functions::VALUE(); |
1848 | 1848 | } |
1849 | 1849 | $yValueCount = count($yValues); |
@@ -1855,7 +1855,7 @@ discard block |
||
1855 | 1855 | return PHPExcel_Calculation_Functions::DIV0(); |
1856 | 1856 | } |
1857 | 1857 | |
1858 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1858 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1859 | 1859 | return $bestFitLinear->getIntersect(); |
1860 | 1860 | } // function INTERCEPT() |
1861 | 1861 | |
@@ -1881,11 +1881,11 @@ discard block |
||
1881 | 1881 | // Loop through arguments |
1882 | 1882 | foreach ($aArgs as $k => $arg) { |
1883 | 1883 | if ((is_bool($arg)) && |
1884 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
1884 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
1885 | 1885 | } else { |
1886 | 1886 | // Is it a numeric value? |
1887 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1888 | - $summer += pow((($arg - $mean) / $stdDev),4) ; |
|
1887 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1888 | + $summer += pow((($arg - $mean) / $stdDev), 4); |
|
1889 | 1889 | ++$count; |
1890 | 1890 | } |
1891 | 1891 | } |
@@ -1893,7 +1893,7 @@ discard block |
||
1893 | 1893 | |
1894 | 1894 | // Return |
1895 | 1895 | if ($count > 3) { |
1896 | - return $summer * ($count * ($count+1) / (($count-1) * ($count-2) * ($count-3))) - (3 * pow($count-1,2) / (($count-2) * ($count-3))); |
|
1896 | + return $summer * ($count * ($count + 1) / (($count - 1) * ($count - 2) * ($count - 3))) - (3 * pow($count - 1, 2) / (($count - 2) * ($count - 3))); |
|
1897 | 1897 | } |
1898 | 1898 | } |
1899 | 1899 | return PHPExcel_Calculation_Functions::DIV0(); |
@@ -1922,11 +1922,11 @@ discard block |
||
1922 | 1922 | // Calculate |
1923 | 1923 | $entry = floor(array_pop($aArgs)); |
1924 | 1924 | |
1925 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
1925 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
1926 | 1926 | $mArgs = array(); |
1927 | 1927 | foreach ($aArgs as $arg) { |
1928 | 1928 | // Is it a numeric value? |
1929 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1929 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1930 | 1930 | $mArgs[] = $arg; |
1931 | 1931 | } |
1932 | 1932 | } |
@@ -1954,12 +1954,12 @@ discard block |
||
1954 | 1954 | * @param boolean A logical value specifying whether to return additional regression statistics. |
1955 | 1955 | * @return array |
1956 | 1956 | */ |
1957 | - public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) { |
|
1958 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1959 | - $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
1960 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1957 | + public static function LINEST($yValues, $xValues = null, $const = True, $stats = False) { |
|
1958 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1959 | + $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
1960 | + if (is_null($xValues)) $xValues = range(1, count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1961 | 1961 | |
1962 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1962 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1963 | 1963 | return PHPExcel_Calculation_Functions::VALUE(); |
1964 | 1964 | } |
1965 | 1965 | $yValueCount = count($yValues); |
@@ -1972,15 +1972,15 @@ discard block |
||
1972 | 1972 | return 0; |
1973 | 1973 | } |
1974 | 1974 | |
1975 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const); |
|
1975 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues, $const); |
|
1976 | 1976 | if ($stats) { |
1977 | - return array( array( $bestFitLinear->getSlope(), |
|
1977 | + return array(array($bestFitLinear->getSlope(), |
|
1978 | 1978 | $bestFitLinear->getSlopeSE(), |
1979 | 1979 | $bestFitLinear->getGoodnessOfFit(), |
1980 | 1980 | $bestFitLinear->getF(), |
1981 | 1981 | $bestFitLinear->getSSRegression(), |
1982 | 1982 | ), |
1983 | - array( $bestFitLinear->getIntersect(), |
|
1983 | + array($bestFitLinear->getIntersect(), |
|
1984 | 1984 | $bestFitLinear->getIntersectSE(), |
1985 | 1985 | $bestFitLinear->getStdevOfResiduals(), |
1986 | 1986 | $bestFitLinear->getDFResiduals(), |
@@ -1988,7 +1988,7 @@ discard block |
||
1988 | 1988 | ) |
1989 | 1989 | ); |
1990 | 1990 | } else { |
1991 | - return array( $bestFitLinear->getSlope(), |
|
1991 | + return array($bestFitLinear->getSlope(), |
|
1992 | 1992 | $bestFitLinear->getIntersect() |
1993 | 1993 | ); |
1994 | 1994 | } |
@@ -2007,18 +2007,18 @@ discard block |
||
2007 | 2007 | * @param boolean A logical value specifying whether to return additional regression statistics. |
2008 | 2008 | * @return array |
2009 | 2009 | */ |
2010 | - public static function LOGEST($yValues,$xValues=null,$const=True,$stats=False) { |
|
2011 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
2012 | - $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
2013 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2010 | + public static function LOGEST($yValues, $xValues = null, $const = True, $stats = False) { |
|
2011 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
2012 | + $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
2013 | + if (is_null($xValues)) $xValues = range(1, count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2014 | 2014 | |
2015 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
2015 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
2016 | 2016 | return PHPExcel_Calculation_Functions::VALUE(); |
2017 | 2017 | } |
2018 | 2018 | $yValueCount = count($yValues); |
2019 | 2019 | $xValueCount = count($xValues); |
2020 | 2020 | |
2021 | - foreach($yValues as $value) { |
|
2021 | + foreach ($yValues as $value) { |
|
2022 | 2022 | if ($value <= 0.0) { |
2023 | 2023 | return PHPExcel_Calculation_Functions::NaN(); |
2024 | 2024 | } |
@@ -2031,15 +2031,15 @@ discard block |
||
2031 | 2031 | return 1; |
2032 | 2032 | } |
2033 | 2033 | |
2034 | - $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const); |
|
2034 | + $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
2035 | 2035 | if ($stats) { |
2036 | - return array( array( $bestFitExponential->getSlope(), |
|
2036 | + return array(array($bestFitExponential->getSlope(), |
|
2037 | 2037 | $bestFitExponential->getSlopeSE(), |
2038 | 2038 | $bestFitExponential->getGoodnessOfFit(), |
2039 | 2039 | $bestFitExponential->getF(), |
2040 | 2040 | $bestFitExponential->getSSRegression(), |
2041 | 2041 | ), |
2042 | - array( $bestFitExponential->getIntersect(), |
|
2042 | + array($bestFitExponential->getIntersect(), |
|
2043 | 2043 | $bestFitExponential->getIntersectSE(), |
2044 | 2044 | $bestFitExponential->getStdevOfResiduals(), |
2045 | 2045 | $bestFitExponential->getDFResiduals(), |
@@ -2047,7 +2047,7 @@ discard block |
||
2047 | 2047 | ) |
2048 | 2048 | ); |
2049 | 2049 | } else { |
2050 | - return array( $bestFitExponential->getSlope(), |
|
2050 | + return array($bestFitExponential->getSlope(), |
|
2051 | 2051 | $bestFitExponential->getIntersect() |
2052 | 2052 | ); |
2053 | 2053 | } |
@@ -2067,9 +2067,9 @@ discard block |
||
2067 | 2067 | * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ |
2068 | 2068 | */ |
2069 | 2069 | public static function LOGINV($probability, $mean, $stdDev) { |
2070 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2071 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2072 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2070 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2071 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2072 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2073 | 2073 | |
2074 | 2074 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2075 | 2075 | if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) { |
@@ -2091,9 +2091,9 @@ discard block |
||
2091 | 2091 | * @return float |
2092 | 2092 | */ |
2093 | 2093 | public static function LOGNORMDIST($value, $mean, $stdDev) { |
2094 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2095 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2096 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2094 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2095 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2096 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2097 | 2097 | |
2098 | 2098 | if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2099 | 2099 | if (($value <= 0) || ($stdDev <= 0)) { |
@@ -2127,7 +2127,7 @@ discard block |
||
2127 | 2127 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
2128 | 2128 | foreach ($aArgs as $arg) { |
2129 | 2129 | // Is it a numeric value? |
2130 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2130 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2131 | 2131 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
2132 | 2132 | $returnValue = $arg; |
2133 | 2133 | } |
@@ -2135,7 +2135,7 @@ discard block |
||
2135 | 2135 | } |
2136 | 2136 | |
2137 | 2137 | // Return |
2138 | - if(is_null($returnValue)) { |
|
2138 | + if (is_null($returnValue)) { |
|
2139 | 2139 | return 0; |
2140 | 2140 | } |
2141 | 2141 | return $returnValue; |
@@ -2176,7 +2176,7 @@ discard block |
||
2176 | 2176 | } |
2177 | 2177 | |
2178 | 2178 | // Return |
2179 | - if(is_null($returnValue)) { |
|
2179 | + if (is_null($returnValue)) { |
|
2180 | 2180 | return 0; |
2181 | 2181 | } |
2182 | 2182 | return $returnValue; |
@@ -2197,7 +2197,7 @@ discard block |
||
2197 | 2197 | * @param string $condition The criteria that defines which cells will be checked. |
2198 | 2198 | * @return float |
2199 | 2199 | */ |
2200 | - public static function MAXIF($aArgs,$condition,$sumArgs = array()) { |
|
2200 | + public static function MAXIF($aArgs, $condition, $sumArgs = array()) { |
|
2201 | 2201 | // Return value |
2202 | 2202 | $returnValue = null; |
2203 | 2203 | |
@@ -2209,7 +2209,7 @@ discard block |
||
2209 | 2209 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
2210 | 2210 | // Loop through arguments |
2211 | 2211 | foreach ($aArgs as $key => $arg) { |
2212 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2212 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2213 | 2213 | $testCondition = '='.$arg.$condition; |
2214 | 2214 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
2215 | 2215 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
@@ -2245,14 +2245,14 @@ discard block |
||
2245 | 2245 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
2246 | 2246 | foreach ($aArgs as $arg) { |
2247 | 2247 | // Is it a numeric value? |
2248 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2248 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2249 | 2249 | $mArgs[] = $arg; |
2250 | 2250 | } |
2251 | 2251 | } |
2252 | 2252 | |
2253 | 2253 | $mValueCount = count($mArgs); |
2254 | 2254 | if ($mValueCount > 0) { |
2255 | - sort($mArgs,SORT_NUMERIC); |
|
2255 | + sort($mArgs, SORT_NUMERIC); |
|
2256 | 2256 | $mValueCount = $mValueCount / 2; |
2257 | 2257 | if ($mValueCount == floor($mValueCount)) { |
2258 | 2258 | $returnValue = ($mArgs[$mValueCount--] + $mArgs[$mValueCount]) / 2; |
@@ -2289,7 +2289,7 @@ discard block |
||
2289 | 2289 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
2290 | 2290 | foreach ($aArgs as $arg) { |
2291 | 2291 | // Is it a numeric value? |
2292 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2292 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2293 | 2293 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
2294 | 2294 | $returnValue = $arg; |
2295 | 2295 | } |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | } |
2298 | 2298 | |
2299 | 2299 | // Return |
2300 | - if(is_null($returnValue)) { |
|
2300 | + if (is_null($returnValue)) { |
|
2301 | 2301 | return 0; |
2302 | 2302 | } |
2303 | 2303 | return $returnValue; |
@@ -2338,7 +2338,7 @@ discard block |
||
2338 | 2338 | } |
2339 | 2339 | |
2340 | 2340 | // Return |
2341 | - if(is_null($returnValue)) { |
|
2341 | + if (is_null($returnValue)) { |
|
2342 | 2342 | return 0; |
2343 | 2343 | } |
2344 | 2344 | return $returnValue; |
@@ -2359,7 +2359,7 @@ discard block |
||
2359 | 2359 | * @param string $condition The criteria that defines which cells will be checked. |
2360 | 2360 | * @return float |
2361 | 2361 | */ |
2362 | - public static function MINIF($aArgs,$condition,$sumArgs = array()) { |
|
2362 | + public static function MINIF($aArgs, $condition, $sumArgs = array()) { |
|
2363 | 2363 | // Return value |
2364 | 2364 | $returnValue = null; |
2365 | 2365 | |
@@ -2371,7 +2371,7 @@ discard block |
||
2371 | 2371 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
2372 | 2372 | // Loop through arguments |
2373 | 2373 | foreach ($aArgs as $key => $arg) { |
2374 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2374 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2375 | 2375 | $testCondition = '='.$arg.$condition; |
2376 | 2376 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
2377 | 2377 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
@@ -2391,22 +2391,22 @@ discard block |
||
2391 | 2391 | // |
2392 | 2392 | private static function _modeCalc($data) { |
2393 | 2393 | $frequencyArray = array(); |
2394 | - foreach($data as $datum) { |
|
2394 | + foreach ($data as $datum) { |
|
2395 | 2395 | $found = False; |
2396 | - foreach($frequencyArray as $key => $value) { |
|
2396 | + foreach ($frequencyArray as $key => $value) { |
|
2397 | 2397 | if ((string) $value['value'] == (string) $datum) { |
2398 | 2398 | ++$frequencyArray[$key]['frequency']; |
2399 | 2399 | $found = True; |
2400 | 2400 | break; |
2401 | 2401 | } |
2402 | 2402 | } |
2403 | - if (!$found) { |
|
2403 | + if ( ! $found) { |
|
2404 | 2404 | $frequencyArray[] = array('value' => $datum, |
2405 | - 'frequency' => 1 ); |
|
2405 | + 'frequency' => 1); |
|
2406 | 2406 | } |
2407 | 2407 | } |
2408 | 2408 | |
2409 | - foreach($frequencyArray as $key => $value) { |
|
2409 | + foreach ($frequencyArray as $key => $value) { |
|
2410 | 2410 | $frequencyList[$key] = $value['frequency']; |
2411 | 2411 | $valueList[$key] = $value['value']; |
2412 | 2412 | } |
@@ -2442,12 +2442,12 @@ discard block |
||
2442 | 2442 | $mArgs = array(); |
2443 | 2443 | foreach ($aArgs as $arg) { |
2444 | 2444 | // Is it a numeric value? |
2445 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2445 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2446 | 2446 | $mArgs[] = $arg; |
2447 | 2447 | } |
2448 | 2448 | } |
2449 | 2449 | |
2450 | - if (!empty($mArgs)) { |
|
2450 | + if ( ! empty($mArgs)) { |
|
2451 | 2451 | return self::_modeCalc($mArgs); |
2452 | 2452 | } |
2453 | 2453 | |
@@ -2472,9 +2472,9 @@ discard block |
||
2472 | 2472 | * |
2473 | 2473 | */ |
2474 | 2474 | public static function NEGBINOMDIST($failures, $successes, $probability) { |
2475 | - $failures = floor(PHPExcel_Calculation_Functions::flattenSingleValue($failures)); |
|
2476 | - $successes = floor(PHPExcel_Calculation_Functions::flattenSingleValue($successes)); |
|
2477 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2475 | + $failures = floor(PHPExcel_Calculation_Functions::flattenSingleValue($failures)); |
|
2476 | + $successes = floor(PHPExcel_Calculation_Functions::flattenSingleValue($successes)); |
|
2477 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2478 | 2478 | |
2479 | 2479 | if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) { |
2480 | 2480 | if (($failures < 0) || ($successes < 1)) { |
@@ -2488,7 +2488,7 @@ discard block |
||
2488 | 2488 | return PHPExcel_Calculation_Functions::NaN(); |
2489 | 2489 | } |
2490 | 2490 | } |
2491 | - return (PHPExcel_Calculation_MathTrig::COMBIN($failures + $successes - 1,$successes - 1)) * (pow($probability,$successes)) * (pow(1 - $probability,$failures)) ; |
|
2491 | + return (PHPExcel_Calculation_MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures)); |
|
2492 | 2492 | } |
2493 | 2493 | return PHPExcel_Calculation_Functions::VALUE(); |
2494 | 2494 | } // function NEGBINOMDIST() |
@@ -2509,9 +2509,9 @@ discard block |
||
2509 | 2509 | * |
2510 | 2510 | */ |
2511 | 2511 | public static function NORMDIST($value, $mean, $stdDev, $cumulative) { |
2512 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2513 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2514 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2512 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2513 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2514 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2515 | 2515 | |
2516 | 2516 | if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2517 | 2517 | if ($stdDev < 0) { |
@@ -2521,7 +2521,7 @@ discard block |
||
2521 | 2521 | if ($cumulative) { |
2522 | 2522 | return 0.5 * (1 + PHPExcel_Calculation_Engineering::_erfVal(($value - $mean) / ($stdDev * sqrt(2)))); |
2523 | 2523 | } else { |
2524 | - return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * ($stdDev * $stdDev)))); |
|
2524 | + return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)))); |
|
2525 | 2525 | } |
2526 | 2526 | } |
2527 | 2527 | } |
@@ -2540,10 +2540,10 @@ discard block |
||
2540 | 2540 | * @return float |
2541 | 2541 | * |
2542 | 2542 | */ |
2543 | - public static function NORMINV($probability,$mean,$stdDev) { |
|
2544 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2545 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2546 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2543 | + public static function NORMINV($probability, $mean, $stdDev) { |
|
2544 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2545 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2546 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2547 | 2547 | |
2548 | 2548 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2549 | 2549 | if (($probability < 0) || ($probability > 1)) { |
@@ -2569,7 +2569,7 @@ discard block |
||
2569 | 2569 | * @return float |
2570 | 2570 | */ |
2571 | 2571 | public static function NORMSDIST($value) { |
2572 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2572 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2573 | 2573 | |
2574 | 2574 | return self::NORMDIST($value, 0, 1, True); |
2575 | 2575 | } // function NORMSDIST() |
@@ -2608,14 +2608,14 @@ discard block |
||
2608 | 2608 | // Calculate |
2609 | 2609 | $entry = array_pop($aArgs); |
2610 | 2610 | |
2611 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
2611 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
2612 | 2612 | if (($entry < 0) || ($entry > 1)) { |
2613 | 2613 | return PHPExcel_Calculation_Functions::NaN(); |
2614 | 2614 | } |
2615 | 2615 | $mArgs = array(); |
2616 | 2616 | foreach ($aArgs as $arg) { |
2617 | 2617 | // Is it a numeric value? |
2618 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2618 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2619 | 2619 | $mArgs[] = $arg; |
2620 | 2620 | } |
2621 | 2621 | } |
@@ -2623,14 +2623,14 @@ discard block |
||
2623 | 2623 | if ($mValueCount > 0) { |
2624 | 2624 | sort($mArgs); |
2625 | 2625 | $count = self::COUNT($mArgs); |
2626 | - $index = $entry * ($count-1); |
|
2626 | + $index = $entry * ($count - 1); |
|
2627 | 2627 | $iBase = floor($index); |
2628 | 2628 | if ($index == $iBase) { |
2629 | 2629 | return $mArgs[$index]; |
2630 | 2630 | } else { |
2631 | 2631 | $iNext = $iBase + 1; |
2632 | 2632 | $iProportion = $index - $iBase; |
2633 | - return $mArgs[$iBase] + (($mArgs[$iNext] - $mArgs[$iBase]) * $iProportion) ; |
|
2633 | + return $mArgs[$iBase] + (($mArgs[$iNext] - $mArgs[$iBase]) * $iProportion); |
|
2634 | 2634 | } |
2635 | 2635 | } |
2636 | 2636 | } |
@@ -2648,17 +2648,17 @@ discard block |
||
2648 | 2648 | * @param number The number of significant digits for the returned percentage value. |
2649 | 2649 | * @return float |
2650 | 2650 | */ |
2651 | - public static function PERCENTRANK($valueSet,$value,$significance=3) { |
|
2652 | - $valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet); |
|
2653 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2654 | - $significance = (is_null($significance)) ? 3 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($significance); |
|
2651 | + public static function PERCENTRANK($valueSet, $value, $significance = 3) { |
|
2652 | + $valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet); |
|
2653 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2654 | + $significance = (is_null($significance)) ? 3 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($significance); |
|
2655 | 2655 | |
2656 | - foreach($valueSet as $key => $valueEntry) { |
|
2657 | - if (!is_numeric($valueEntry)) { |
|
2656 | + foreach ($valueSet as $key => $valueEntry) { |
|
2657 | + if ( ! is_numeric($valueEntry)) { |
|
2658 | 2658 | unset($valueSet[$key]); |
2659 | 2659 | } |
2660 | 2660 | } |
2661 | - sort($valueSet,SORT_NUMERIC); |
|
2661 | + sort($valueSet, SORT_NUMERIC); |
|
2662 | 2662 | $valueCount = count($valueSet); |
2663 | 2663 | if ($valueCount == 0) { |
2664 | 2664 | return PHPExcel_Calculation_Functions::NaN(); |
@@ -2669,7 +2669,7 @@ discard block |
||
2669 | 2669 | return PHPExcel_Calculation_Functions::NA(); |
2670 | 2670 | } |
2671 | 2671 | |
2672 | - $pos = array_search($value,$valueSet); |
|
2672 | + $pos = array_search($value, $valueSet); |
|
2673 | 2673 | if ($pos === False) { |
2674 | 2674 | $pos = 0; |
2675 | 2675 | $testValue = $valueSet[0]; |
@@ -2680,7 +2680,7 @@ discard block |
||
2680 | 2680 | $pos += (($value - $valueSet[$pos]) / ($testValue - $valueSet[$pos])); |
2681 | 2681 | } |
2682 | 2682 | |
2683 | - return round($pos / $valueAdjustor,$significance); |
|
2683 | + return round($pos / $valueAdjustor, $significance); |
|
2684 | 2684 | } // function PERCENTRANK() |
2685 | 2685 | |
2686 | 2686 | |
@@ -2697,9 +2697,9 @@ discard block |
||
2697 | 2697 | * @param int $numInSet Number of objects in each permutation |
2698 | 2698 | * @return int Number of permutations |
2699 | 2699 | */ |
2700 | - public static function PERMUT($numObjs,$numInSet) { |
|
2701 | - $numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs); |
|
2702 | - $numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet); |
|
2700 | + public static function PERMUT($numObjs, $numInSet) { |
|
2701 | + $numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs); |
|
2702 | + $numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet); |
|
2703 | 2703 | |
2704 | 2704 | if ((is_numeric($numObjs)) && (is_numeric($numInSet))) { |
2705 | 2705 | $numInSet = floor($numInSet); |
@@ -2726,8 +2726,8 @@ discard block |
||
2726 | 2726 | * |
2727 | 2727 | */ |
2728 | 2728 | public static function POISSON($value, $mean, $cumulative) { |
2729 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2730 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2729 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2730 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2731 | 2731 | |
2732 | 2732 | if ((is_numeric($value)) && (is_numeric($mean))) { |
2733 | 2733 | if (($value <= 0) || ($mean <= 0)) { |
@@ -2737,11 +2737,11 @@ discard block |
||
2737 | 2737 | if ($cumulative) { |
2738 | 2738 | $summer = 0; |
2739 | 2739 | for ($i = 0; $i <= floor($value); ++$i) { |
2740 | - $summer += pow($mean,$i) / PHPExcel_Calculation_MathTrig::FACT($i); |
|
2740 | + $summer += pow($mean, $i) / PHPExcel_Calculation_MathTrig::FACT($i); |
|
2741 | 2741 | } |
2742 | - return exp(0-$mean) * $summer; |
|
2742 | + return exp(0 - $mean) * $summer; |
|
2743 | 2743 | } else { |
2744 | - return (exp(0-$mean) * pow($mean,$value)) / PHPExcel_Calculation_MathTrig::FACT($value); |
|
2744 | + return (exp(0 - $mean) * pow($mean, $value)) / PHPExcel_Calculation_MathTrig::FACT($value); |
|
2745 | 2745 | } |
2746 | 2746 | } |
2747 | 2747 | } |
@@ -2769,12 +2769,12 @@ discard block |
||
2769 | 2769 | // Calculate |
2770 | 2770 | $entry = floor(array_pop($aArgs)); |
2771 | 2771 | |
2772 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
2772 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
2773 | 2773 | $entry /= 4; |
2774 | 2774 | if (($entry < 0) || ($entry > 1)) { |
2775 | 2775 | return PHPExcel_Calculation_Functions::NaN(); |
2776 | 2776 | } |
2777 | - return self::PERCENTILE($aArgs,$entry); |
|
2777 | + return self::PERCENTILE($aArgs, $entry); |
|
2778 | 2778 | } |
2779 | 2779 | return PHPExcel_Calculation_Functions::VALUE(); |
2780 | 2780 | } // function QUARTILE() |
@@ -2790,23 +2790,23 @@ discard block |
||
2790 | 2790 | * @param mixed Order to sort the values in the value set |
2791 | 2791 | * @return float |
2792 | 2792 | */ |
2793 | - public static function RANK($value,$valueSet,$order=0) { |
|
2793 | + public static function RANK($value, $valueSet, $order = 0) { |
|
2794 | 2794 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
2795 | 2795 | $valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet); |
2796 | - $order = (is_null($order)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($order); |
|
2796 | + $order = (is_null($order)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($order); |
|
2797 | 2797 | |
2798 | - foreach($valueSet as $key => $valueEntry) { |
|
2799 | - if (!is_numeric($valueEntry)) { |
|
2798 | + foreach ($valueSet as $key => $valueEntry) { |
|
2799 | + if ( ! is_numeric($valueEntry)) { |
|
2800 | 2800 | unset($valueSet[$key]); |
2801 | 2801 | } |
2802 | 2802 | } |
2803 | 2803 | |
2804 | 2804 | if ($order == 0) { |
2805 | - rsort($valueSet,SORT_NUMERIC); |
|
2805 | + rsort($valueSet, SORT_NUMERIC); |
|
2806 | 2806 | } else { |
2807 | - sort($valueSet,SORT_NUMERIC); |
|
2807 | + sort($valueSet, SORT_NUMERIC); |
|
2808 | 2808 | } |
2809 | - $pos = array_search($value,$valueSet); |
|
2809 | + $pos = array_search($value, $valueSet); |
|
2810 | 2810 | if ($pos === False) { |
2811 | 2811 | return PHPExcel_Calculation_Functions::NA(); |
2812 | 2812 | } |
@@ -2824,8 +2824,8 @@ discard block |
||
2824 | 2824 | * @param array of mixed Data Series X |
2825 | 2825 | * @return float |
2826 | 2826 | */ |
2827 | - public static function RSQ($yValues,$xValues) { |
|
2828 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
2827 | + public static function RSQ($yValues, $xValues) { |
|
2828 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
2829 | 2829 | return PHPExcel_Calculation_Functions::VALUE(); |
2830 | 2830 | } |
2831 | 2831 | $yValueCount = count($yValues); |
@@ -2837,7 +2837,7 @@ discard block |
||
2837 | 2837 | return PHPExcel_Calculation_Functions::DIV0(); |
2838 | 2838 | } |
2839 | 2839 | |
2840 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
2840 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
2841 | 2841 | return $bestFitLinear->getGoodnessOfFit(); |
2842 | 2842 | } // function RSQ() |
2843 | 2843 | |
@@ -2862,11 +2862,11 @@ discard block |
||
2862 | 2862 | // Loop through arguments |
2863 | 2863 | foreach ($aArgs as $k => $arg) { |
2864 | 2864 | if ((is_bool($arg)) && |
2865 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
2865 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
2866 | 2866 | } else { |
2867 | 2867 | // Is it a numeric value? |
2868 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2869 | - $summer += pow((($arg - $mean) / $stdDev),3) ; |
|
2868 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2869 | + $summer += pow((($arg - $mean) / $stdDev), 3); |
|
2870 | 2870 | ++$count; |
2871 | 2871 | } |
2872 | 2872 | } |
@@ -2874,7 +2874,7 @@ discard block |
||
2874 | 2874 | |
2875 | 2875 | // Return |
2876 | 2876 | if ($count > 2) { |
2877 | - return $summer * ($count / (($count-1) * ($count-2))); |
|
2877 | + return $summer * ($count / (($count - 1) * ($count - 2))); |
|
2878 | 2878 | } |
2879 | 2879 | return PHPExcel_Calculation_Functions::DIV0(); |
2880 | 2880 | } // function SKEW() |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | * @param array of mixed Data Series X |
2890 | 2890 | * @return float |
2891 | 2891 | */ |
2892 | - public static function SLOPE($yValues,$xValues) { |
|
2893 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
2892 | + public static function SLOPE($yValues, $xValues) { |
|
2893 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
2894 | 2894 | return PHPExcel_Calculation_Functions::VALUE(); |
2895 | 2895 | } |
2896 | 2896 | $yValueCount = count($yValues); |
@@ -2902,7 +2902,7 @@ discard block |
||
2902 | 2902 | return PHPExcel_Calculation_Functions::DIV0(); |
2903 | 2903 | } |
2904 | 2904 | |
2905 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
2905 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
2906 | 2906 | return $bestFitLinear->getSlope(); |
2907 | 2907 | } // function SLOPE() |
2908 | 2908 | |
@@ -2928,11 +2928,11 @@ discard block |
||
2928 | 2928 | // Calculate |
2929 | 2929 | $entry = array_pop($aArgs); |
2930 | 2930 | |
2931 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
2931 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
2932 | 2932 | $mArgs = array(); |
2933 | 2933 | foreach ($aArgs as $arg) { |
2934 | 2934 | // Is it a numeric value? |
2935 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2935 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2936 | 2936 | $mArgs[] = $arg; |
2937 | 2937 | } |
2938 | 2938 | } |
@@ -2958,16 +2958,16 @@ discard block |
||
2958 | 2958 | * @param float $stdDev Standard Deviation |
2959 | 2959 | * @return float Standardized value |
2960 | 2960 | */ |
2961 | - public static function STANDARDIZE($value,$mean,$stdDev) { |
|
2962 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2963 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2964 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2961 | + public static function STANDARDIZE($value, $mean, $stdDev) { |
|
2962 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2963 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2964 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2965 | 2965 | |
2966 | 2966 | if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2967 | 2967 | if ($stdDev <= 0) { |
2968 | 2968 | return PHPExcel_Calculation_Functions::NaN(); |
2969 | 2969 | } |
2970 | - return ($value - $mean) / $stdDev ; |
|
2970 | + return ($value - $mean) / $stdDev; |
|
2971 | 2971 | } |
2972 | 2972 | return PHPExcel_Calculation_Functions::VALUE(); |
2973 | 2973 | } // function STANDARDIZE() |
@@ -2994,19 +2994,19 @@ discard block |
||
2994 | 2994 | $returnValue = null; |
2995 | 2995 | |
2996 | 2996 | $aMean = self::AVERAGE($aArgs); |
2997 | - if (!is_null($aMean)) { |
|
2997 | + if ( ! is_null($aMean)) { |
|
2998 | 2998 | $aCount = -1; |
2999 | 2999 | foreach ($aArgs as $k => $arg) { |
3000 | 3000 | if ((is_bool($arg)) && |
3001 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3001 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3002 | 3002 | $arg = (integer) $arg; |
3003 | 3003 | } |
3004 | 3004 | // Is it a numeric value? |
3005 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3005 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3006 | 3006 | if (is_null($returnValue)) { |
3007 | - $returnValue = pow(($arg - $aMean),2); |
|
3007 | + $returnValue = pow(($arg - $aMean), 2); |
|
3008 | 3008 | } else { |
3009 | - $returnValue += pow(($arg - $aMean),2); |
|
3009 | + $returnValue += pow(($arg - $aMean), 2); |
|
3010 | 3010 | } |
3011 | 3011 | ++$aCount; |
3012 | 3012 | } |
@@ -3041,11 +3041,11 @@ discard block |
||
3041 | 3041 | $returnValue = null; |
3042 | 3042 | |
3043 | 3043 | $aMean = self::AVERAGEA($aArgs); |
3044 | - if (!is_null($aMean)) { |
|
3044 | + if ( ! is_null($aMean)) { |
|
3045 | 3045 | $aCount = -1; |
3046 | 3046 | foreach ($aArgs as $k => $arg) { |
3047 | 3047 | if ((is_bool($arg)) && |
3048 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3048 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3049 | 3049 | } else { |
3050 | 3050 | // Is it a numeric value? |
3051 | 3051 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3055,9 +3055,9 @@ discard block |
||
3055 | 3055 | $arg = 0; |
3056 | 3056 | } |
3057 | 3057 | if (is_null($returnValue)) { |
3058 | - $returnValue = pow(($arg - $aMean),2); |
|
3058 | + $returnValue = pow(($arg - $aMean), 2); |
|
3059 | 3059 | } else { |
3060 | - $returnValue += pow(($arg - $aMean),2); |
|
3060 | + $returnValue += pow(($arg - $aMean), 2); |
|
3061 | 3061 | } |
3062 | 3062 | ++$aCount; |
3063 | 3063 | } |
@@ -3093,19 +3093,19 @@ discard block |
||
3093 | 3093 | $returnValue = null; |
3094 | 3094 | |
3095 | 3095 | $aMean = self::AVERAGE($aArgs); |
3096 | - if (!is_null($aMean)) { |
|
3096 | + if ( ! is_null($aMean)) { |
|
3097 | 3097 | $aCount = 0; |
3098 | 3098 | foreach ($aArgs as $k => $arg) { |
3099 | 3099 | if ((is_bool($arg)) && |
3100 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3100 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3101 | 3101 | $arg = (integer) $arg; |
3102 | 3102 | } |
3103 | 3103 | // Is it a numeric value? |
3104 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3104 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3105 | 3105 | if (is_null($returnValue)) { |
3106 | - $returnValue = pow(($arg - $aMean),2); |
|
3106 | + $returnValue = pow(($arg - $aMean), 2); |
|
3107 | 3107 | } else { |
3108 | - $returnValue += pow(($arg - $aMean),2); |
|
3108 | + $returnValue += pow(($arg - $aMean), 2); |
|
3109 | 3109 | } |
3110 | 3110 | ++$aCount; |
3111 | 3111 | } |
@@ -3140,11 +3140,11 @@ discard block |
||
3140 | 3140 | $returnValue = null; |
3141 | 3141 | |
3142 | 3142 | $aMean = self::AVERAGEA($aArgs); |
3143 | - if (!is_null($aMean)) { |
|
3143 | + if ( ! is_null($aMean)) { |
|
3144 | 3144 | $aCount = 0; |
3145 | 3145 | foreach ($aArgs as $k => $arg) { |
3146 | 3146 | if ((is_bool($arg)) && |
3147 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3147 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3148 | 3148 | } else { |
3149 | 3149 | // Is it a numeric value? |
3150 | 3150 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3154,9 +3154,9 @@ discard block |
||
3154 | 3154 | $arg = 0; |
3155 | 3155 | } |
3156 | 3156 | if (is_null($returnValue)) { |
3157 | - $returnValue = pow(($arg - $aMean),2); |
|
3157 | + $returnValue = pow(($arg - $aMean), 2); |
|
3158 | 3158 | } else { |
3159 | - $returnValue += pow(($arg - $aMean),2); |
|
3159 | + $returnValue += pow(($arg - $aMean), 2); |
|
3160 | 3160 | } |
3161 | 3161 | ++$aCount; |
3162 | 3162 | } |
@@ -3181,8 +3181,8 @@ discard block |
||
3181 | 3181 | * @param array of mixed Data Series X |
3182 | 3182 | * @return float |
3183 | 3183 | */ |
3184 | - public static function STEYX($yValues,$xValues) { |
|
3185 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
3184 | + public static function STEYX($yValues, $xValues) { |
|
3185 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
3186 | 3186 | return PHPExcel_Calculation_Functions::VALUE(); |
3187 | 3187 | } |
3188 | 3188 | $yValueCount = count($yValues); |
@@ -3194,7 +3194,7 @@ discard block |
||
3194 | 3194 | return PHPExcel_Calculation_Functions::DIV0(); |
3195 | 3195 | } |
3196 | 3196 | |
3197 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
3197 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
3198 | 3198 | return $bestFitLinear->getStdevOfResiduals(); |
3199 | 3199 | } // function STEYX() |
3200 | 3200 | |
@@ -3211,7 +3211,7 @@ discard block |
||
3211 | 3211 | */ |
3212 | 3212 | public static function TDIST($value, $degrees, $tails) { |
3213 | 3213 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
3214 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3214 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3215 | 3215 | $tails = floor(PHPExcel_Calculation_Functions::flattenSingleValue($tails)); |
3216 | 3216 | |
3217 | 3217 | if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) { |
@@ -3228,7 +3228,7 @@ discard block |
||
3228 | 3228 | // Algorithms", editied by P Griffiths and I D Hill (1985; Ellis |
3229 | 3229 | // Horwood Ltd.; W. Sussex, England). |
3230 | 3230 | $tterm = $degrees; |
3231 | - $ttheta = atan2($value,sqrt($tterm)); |
|
3231 | + $ttheta = atan2($value, sqrt($tterm)); |
|
3232 | 3232 | $tc = cos($ttheta); |
3233 | 3233 | $ts = sin($ttheta); |
3234 | 3234 | $tsum = 0; |
@@ -3270,15 +3270,15 @@ discard block |
||
3270 | 3270 | * @return float |
3271 | 3271 | */ |
3272 | 3272 | public static function TINV($probability, $degrees) { |
3273 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
3274 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3273 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
3274 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3275 | 3275 | |
3276 | 3276 | if ((is_numeric($probability)) && (is_numeric($degrees))) { |
3277 | 3277 | $xLo = 100; |
3278 | 3278 | $xHi = 0; |
3279 | 3279 | |
3280 | 3280 | $x = $xNew = 1; |
3281 | - $dx = 1; |
|
3281 | + $dx = 1; |
|
3282 | 3282 | $i = 0; |
3283 | 3283 | |
3284 | 3284 | while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { |
@@ -3309,7 +3309,7 @@ discard block |
||
3309 | 3309 | if ($i == MAX_ITERATIONS) { |
3310 | 3310 | return PHPExcel_Calculation_Functions::NA(); |
3311 | 3311 | } |
3312 | - return round($x,12); |
|
3312 | + return round($x, 12); |
|
3313 | 3313 | } |
3314 | 3314 | return PHPExcel_Calculation_Functions::VALUE(); |
3315 | 3315 | } // function TINV() |
@@ -3326,19 +3326,19 @@ discard block |
||
3326 | 3326 | * @param boolean A logical value specifying whether to force the intersect to equal 0. |
3327 | 3327 | * @return array of float |
3328 | 3328 | */ |
3329 | - public static function TREND($yValues,$xValues=array(),$newValues=array(),$const=True) { |
|
3329 | + public static function TREND($yValues, $xValues = array(), $newValues = array(), $const = True) { |
|
3330 | 3330 | $yValues = PHPExcel_Calculation_Functions::flattenArray($yValues); |
3331 | 3331 | $xValues = PHPExcel_Calculation_Functions::flattenArray($xValues); |
3332 | 3332 | $newValues = PHPExcel_Calculation_Functions::flattenArray($newValues); |
3333 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
3333 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
3334 | 3334 | |
3335 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const); |
|
3335 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues, $const); |
|
3336 | 3336 | if (empty($newValues)) { |
3337 | 3337 | $newValues = $bestFitLinear->getXValues(); |
3338 | 3338 | } |
3339 | 3339 | |
3340 | 3340 | $returnArray = array(); |
3341 | - foreach($newValues as $xValue) { |
|
3341 | + foreach ($newValues as $xValue) { |
|
3342 | 3342 | $returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue); |
3343 | 3343 | } |
3344 | 3344 | |
@@ -3368,20 +3368,20 @@ discard block |
||
3368 | 3368 | // Calculate |
3369 | 3369 | $percent = array_pop($aArgs); |
3370 | 3370 | |
3371 | - if ((is_numeric($percent)) && (!is_string($percent))) { |
|
3371 | + if ((is_numeric($percent)) && ( ! is_string($percent))) { |
|
3372 | 3372 | if (($percent < 0) || ($percent > 1)) { |
3373 | 3373 | return PHPExcel_Calculation_Functions::NaN(); |
3374 | 3374 | } |
3375 | 3375 | $mArgs = array(); |
3376 | 3376 | foreach ($aArgs as $arg) { |
3377 | 3377 | // Is it a numeric value? |
3378 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3378 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3379 | 3379 | $mArgs[] = $arg; |
3380 | 3380 | } |
3381 | 3381 | } |
3382 | 3382 | $discard = floor(self::COUNT($mArgs) * $percent / 2); |
3383 | 3383 | sort($mArgs); |
3384 | - for ($i=0; $i < $discard; ++$i) { |
|
3384 | + for ($i = 0; $i < $discard; ++$i) { |
|
3385 | 3385 | array_pop($mArgs); |
3386 | 3386 | array_shift($mArgs); |
3387 | 3387 | } |
@@ -3416,7 +3416,7 @@ discard block |
||
3416 | 3416 | foreach ($aArgs as $arg) { |
3417 | 3417 | if (is_bool($arg)) { $arg = (integer) $arg; } |
3418 | 3418 | // Is it a numeric value? |
3419 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3419 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3420 | 3420 | $summerA += ($arg * $arg); |
3421 | 3421 | $summerB += $arg; |
3422 | 3422 | ++$aCount; |
@@ -3460,7 +3460,7 @@ discard block |
||
3460 | 3460 | (PHPExcel_Calculation_Functions::isValue($k))) { |
3461 | 3461 | return PHPExcel_Calculation_Functions::VALUE(); |
3462 | 3462 | } elseif ((is_string($arg)) && |
3463 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3463 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3464 | 3464 | } else { |
3465 | 3465 | // Is it a numeric value? |
3466 | 3466 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3511,7 +3511,7 @@ discard block |
||
3511 | 3511 | foreach ($aArgs as $arg) { |
3512 | 3512 | if (is_bool($arg)) { $arg = (integer) $arg; } |
3513 | 3513 | // Is it a numeric value? |
3514 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3514 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3515 | 3515 | $summerA += ($arg * $arg); |
3516 | 3516 | $summerB += $arg; |
3517 | 3517 | ++$aCount; |
@@ -3555,7 +3555,7 @@ discard block |
||
3555 | 3555 | (PHPExcel_Calculation_Functions::isValue($k))) { |
3556 | 3556 | return PHPExcel_Calculation_Functions::VALUE(); |
3557 | 3557 | } elseif ((is_string($arg)) && |
3558 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3558 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3559 | 3559 | } else { |
3560 | 3560 | // Is it a numeric value? |
3561 | 3561 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3597,7 +3597,7 @@ discard block |
||
3597 | 3597 | public static function WEIBULL($value, $alpha, $beta, $cumulative) { |
3598 | 3598 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
3599 | 3599 | $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
3600 | - $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
3600 | + $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
3601 | 3601 | |
3602 | 3602 | if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) { |
3603 | 3603 | if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) { |
@@ -3605,9 +3605,9 @@ discard block |
||
3605 | 3605 | } |
3606 | 3606 | if ((is_numeric($cumulative)) || (is_bool($cumulative))) { |
3607 | 3607 | if ($cumulative) { |
3608 | - return 1 - exp(0 - pow($value / $beta,$alpha)); |
|
3608 | + return 1 - exp(0 - pow($value / $beta, $alpha)); |
|
3609 | 3609 | } else { |
3610 | - return ($alpha / pow($beta,$alpha)) * pow($value,$alpha - 1) * exp(0 - pow($value / $beta,$alpha)); |
|
3610 | + return ($alpha / pow($beta, $alpha)) * pow($value, $alpha - 1) * exp(0 - pow($value / $beta, $alpha)); |
|
3611 | 3611 | } |
3612 | 3612 | } |
3613 | 3613 | } |
@@ -3628,9 +3628,9 @@ discard block |
||
3628 | 3628 | * @return float |
3629 | 3629 | * |
3630 | 3630 | */ |
3631 | - public static function ZTEST($dataSet, $m0, $sigma=null) { |
|
3632 | - $dataSet = PHPExcel_Calculation_Functions::flattenArrayIndexed($dataSet); |
|
3633 | - $m0 = PHPExcel_Calculation_Functions::flattenSingleValue($m0); |
|
3631 | + public static function ZTEST($dataSet, $m0, $sigma = null) { |
|
3632 | + $dataSet = PHPExcel_Calculation_Functions::flattenArrayIndexed($dataSet); |
|
3633 | + $m0 = PHPExcel_Calculation_Functions::flattenSingleValue($m0); |
|
3634 | 3634 | $sigma = PHPExcel_Calculation_Functions::flattenSingleValue($sigma); |
3635 | 3635 | |
3636 | 3636 | if (is_null($sigma)) { |
@@ -3638,7 +3638,7 @@ discard block |
||
3638 | 3638 | } |
3639 | 3639 | $n = count($dataSet); |
3640 | 3640 | |
3641 | - return 1 - self::NORMSDIST((self::AVERAGE($dataSet) - $m0)/($sigma/SQRT($n))); |
|
3641 | + return 1 - self::NORMSDIST((self::AVERAGE($dataSet) - $m0) / ($sigma / SQRT($n))); |
|
3642 | 3642 | } // function ZTEST() |
3643 | 3643 | |
3644 | 3644 | } // class PHPExcel_Calculation_Statistical |
@@ -396,8 +396,9 @@ discard block |
||
396 | 396 | if ($y <= $lg_frtbig) { |
397 | 397 | $res = $lg_c[6]; |
398 | 398 | $ysq = $y * $y; |
399 | - for ($i = 0; $i < 6; ++$i) |
|
400 | - $res = $res / $ysq + $lg_c[$i]; |
|
399 | + for ($i = 0; $i < 6; ++$i) { |
|
400 | + $res = $res / $ysq + $lg_c[$i]; |
|
401 | + } |
|
401 | 402 | } |
402 | 403 | $res /= $y; |
403 | 404 | $corr = log($y); |
@@ -440,7 +441,9 @@ discard block |
||
440 | 441 | // Private implementation of the Gamma function |
441 | 442 | // |
442 | 443 | private static function _gamma($data) { |
443 | - if ($data == 0.0) return 0; |
|
444 | + if ($data == 0.0) { |
|
445 | + return 0; |
|
446 | + } |
|
444 | 447 | |
445 | 448 | static $p0 = 1.000000000190015; |
446 | 449 | static $p = array ( 1 => 76.18009172947146, |
@@ -1957,7 +1960,9 @@ discard block |
||
1957 | 1960 | public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) { |
1958 | 1961 | $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
1959 | 1962 | $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
1960 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1963 | + if (is_null($xValues)) { |
|
1964 | + $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1965 | + } |
|
1961 | 1966 | |
1962 | 1967 | if (!self::_checkTrendArrays($yValues,$xValues)) { |
1963 | 1968 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -2010,7 +2015,9 @@ discard block |
||
2010 | 2015 | public static function LOGEST($yValues,$xValues=null,$const=True,$stats=False) { |
2011 | 2016 | $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
2012 | 2017 | $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
2013 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2018 | + if (is_null($xValues)) { |
|
2019 | + $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2020 | + } |
|
2014 | 2021 | |
2015 | 2022 | if (!self::_checkTrendArrays($yValues,$xValues)) { |
2016 | 2023 | return PHPExcel_Calculation_Functions::VALUE(); |