From 12590bbf1e5f82562085a70b48ee377e428dfaff Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 14 May 2016 10:29:38 +0200 Subject: [PATCH] #401 : PHPCS (Calculation\Functions) --- src/PhpSpreadsheet/Calculation.php | 26 +++--- src/PhpSpreadsheet/Calculation/Database.php | 2 +- src/PhpSpreadsheet/Calculation/DateTime.php | 34 +++---- .../Calculation/Engineering.php | 56 ++++++------ src/PhpSpreadsheet/Calculation/Financial.php | 84 ++++++++--------- src/PhpSpreadsheet/Calculation/Functions.php | 30 +++---- src/PhpSpreadsheet/Calculation/Logical.php | 2 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 30 +++---- .../Calculation/Statistical.php | 90 +++++++++---------- src/PhpSpreadsheet/Calculation/TextData.php | 4 +- src/PhpSpreadsheet/Shared/JAMA/Matrix.php | 10 +-- .../Classes/src/Calculation/FunctionsTest.php | 24 ++--- 12 files changed, 196 insertions(+), 196 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index a0cdcb64..f1999f27 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -807,7 +807,7 @@ class Calculation ), 'ERROR.TYPE' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::ERROR_TYPE', + 'functionCall' => 'Calculation\Categories::errorType', 'argumentCount' => '1' ), 'EVEN' => array( @@ -1129,7 +1129,7 @@ class Calculation ), 'ISBLANK' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_BLANK', + 'functionCall' => 'Calculation\Categories::isBlank', 'argumentCount' => '1' ), 'ISERR' => array( @@ -1144,32 +1144,32 @@ class Calculation ), 'ISEVEN' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_EVEN', + 'functionCall' => 'Calculation\Categories::isEven', 'argumentCount' => '1' ), 'ISLOGICAL' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_LOGICAL', + 'functionCall' => 'Calculation\Categories::isLogical', 'argumentCount' => '1' ), 'ISNA' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_NA', + 'functionCall' => 'Calculation\Categories::isNa', 'argumentCount' => '1' ), 'ISNONTEXT' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_NONTEXT', + 'functionCall' => 'Calculation\Categories::isNonText', 'argumentCount' => '1' ), 'ISNUMBER' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_NUMBER', + 'functionCall' => 'Calculation\Categories::isNumber', 'argumentCount' => '1' ), 'ISODD' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_ODD', + 'functionCall' => 'Calculation\Categories::isOdd', 'argumentCount' => '1' ), 'ISPMT' => array( @@ -1184,7 +1184,7 @@ class Calculation ), 'ISTEXT' => array( 'category' => Calculation\Categories::CATEGORY_INFORMATION, - 'functionCall' => 'Calculation\Categories::IS_TEXT', + 'functionCall' => 'Calculation\Categories::isText', 'argumentCount' => '1' ), 'JIS' => array( @@ -2526,7 +2526,7 @@ class Calculation return '"'.$value.'"'; // Convert numeric errors to NaN error } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { - return Calculation\Functions::NaN(); + return Calculation\Functions::NAN(); } return $value; @@ -2545,9 +2545,9 @@ class Calculation if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) { return substr($value, 1, -1); } - // Convert numeric errors to NaN error + // Convert numeric errors to NAN error } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { - return Calculation\Functions::NaN(); + return Calculation\Functions::NAN(); } return $value; } @@ -2645,7 +2645,7 @@ class Calculation if ($result === null) { return 0; } elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) { - return Calculation\Functions::NaN(); + return Calculation\Functions::NAN(); } return $result; } diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index 5f94a21d..f3c22614 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -327,7 +327,7 @@ class Database // Return $colData = self::getFilteredColumn($database, $field, $criteria); if (count($colData) > 1) { - return Functions::NaN(); + return Functions::NAN(); } return $colData[0]; diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 6e56171a..6b9383f0 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -309,10 +309,10 @@ class DateTime $baseYear = \PHPExcel\Shared\Date::getExcelCalendar(); // Validate parameters if ($year < ($baseYear-1900)) { - return Functions::NaN(); + return Functions::NAN(); } if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) { - return Functions::NaN(); + return Functions::NAN(); } if (($year < $baseYear) && ($year >= ($baseYear-1900))) { @@ -332,7 +332,7 @@ class DateTime // Re-validate the year parameter after adjustments if (($year < $baseYear) || ($year >= 10000)) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -422,7 +422,7 @@ class DateTime if ($hour > 23) { $hour = $hour % 24; } elseif ($hour < 0) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -662,7 +662,7 @@ class DateTime // Validate parameters if ($startDate >= $endDate) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -678,7 +678,7 @@ class DateTime $endMonths = $PHPEndDateObject->format('n'); $endYears = $PHPEndDateObject->format('Y'); - $retVal = Functions::NaN(); + $retVal = Functions::NAN(); switch ($unit) { case 'D': $retVal = intval($difference); @@ -735,7 +735,7 @@ class DateTime } break; default: - $retVal = Functions::NaN(); + $retVal = Functions::NAN(); } return $retVal; } @@ -1125,7 +1125,7 @@ class DateTime } elseif ($dateValue == 0.0) { return 0; } elseif ($dateValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -1160,7 +1160,7 @@ class DateTime if (!is_numeric($style)) { return Functions::VALUE(); } elseif (($style < 1) || ($style > 3)) { - return Functions::NaN(); + return Functions::NAN(); } $style = floor($style); @@ -1169,7 +1169,7 @@ class DateTime } elseif (is_string($dateValue = self::getDateValue($dateValue))) { return Functions::VALUE(); } elseif ($dateValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -1236,7 +1236,7 @@ class DateTime if (!is_numeric($method)) { return Functions::VALUE(); } elseif (($method < 1) || ($method > 2)) { - return Functions::NaN(); + return Functions::NAN(); } $method = floor($method); @@ -1245,7 +1245,7 @@ class DateTime } elseif (is_string($dateValue = self::getDateValue($dateValue))) { return Functions::VALUE(); } elseif ($dateValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -1284,7 +1284,7 @@ class DateTime } elseif (is_string($dateValue = self::getDateValue($dateValue))) { return Functions::VALUE(); } elseif ($dateValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -1316,7 +1316,7 @@ class DateTime } elseif (is_string($dateValue = self::getDateValue($dateValue))) { return Functions::VALUE(); } elseif ($dateValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } // Execute function @@ -1359,7 +1359,7 @@ class DateTime if ($timeValue >= 1) { $timeValue = fmod($timeValue, 1); } elseif ($timeValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } $timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue); @@ -1400,7 +1400,7 @@ class DateTime if ($timeValue >= 1) { $timeValue = fmod($timeValue, 1); } elseif ($timeValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } $timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue); @@ -1441,7 +1441,7 @@ class DateTime if ($timeValue >= 1) { $timeValue = fmod($timeValue, 1); } elseif ($timeValue < 0.0) { - return Functions::NaN(); + return Functions::NAN(); } $timeValue = \PHPExcel\Shared\Date::excelToPHP($timeValue); diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index ecbeae09..e74c98b9 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -830,7 +830,7 @@ class Engineering if (strlen($xVal) <= $places) { return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10); } else { - return Functions::NaN(); + return Functions::NAN(); } } @@ -865,7 +865,7 @@ class Engineering if ((is_numeric($x)) && (is_numeric($ord))) { $ord = floor($ord); if ($ord < 0) { - return Functions::NaN(); + return Functions::NAN(); } if (abs($x) <= 30) { @@ -886,7 +886,7 @@ class Engineering $fResult = -$fResult; } } - return (is_nan($fResult)) ? Functions::NaN() : $fResult; + return (is_nan($fResult)) ? Functions::NAN() : $fResult; } return Functions::VALUE(); } @@ -918,7 +918,7 @@ class Engineering if ((is_numeric($x)) && (is_numeric($ord))) { $ord = floor($ord); if ($ord < 0) { - return Functions::NaN(); + return Functions::NAN(); } $fResult = 0; @@ -941,7 +941,7 @@ class Engineering $fResult = -$fResult; } } - return (is_nan($fResult)) ? Functions::NaN() : $fResult; + return (is_nan($fResult)) ? Functions::NAN() : $fResult; } return Functions::VALUE(); } @@ -1009,7 +1009,7 @@ class Engineering if ((is_numeric($x)) && (is_numeric($ord))) { if (($ord < 0) || ($x == 0.0)) { - return Functions::NaN(); + return Functions::NAN(); } switch (floor($ord)) { @@ -1027,7 +1027,7 @@ class Engineering $fBk = $fBkp; } } - return (is_nan($fBk)) ? Functions::NaN() : $fBk; + return (is_nan($fBk)) ? Functions::NAN() : $fBk; } return Functions::VALUE(); } @@ -1093,7 +1093,7 @@ class Engineering if ((is_numeric($x)) && (is_numeric($ord))) { if (($ord < 0) || ($x == 0.0)) { - return Functions::NaN(); + return Functions::NAN(); } switch (floor($ord)) { @@ -1111,7 +1111,7 @@ class Engineering $fBy = $fByp; } } - return (is_nan($fBy)) ? Functions::NaN() : $fBy; + return (is_nan($fBy)) ? Functions::NAN() : $fBy; } return Functions::VALUE(); } @@ -1151,10 +1151,10 @@ class Engineering } $x = (string) $x; if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { - return Functions::NaN(); + return Functions::NAN(); } if (strlen($x) > 10) { - return Functions::NaN(); + return Functions::NAN(); } elseif (strlen($x) == 10) { // Two's Complement $x = substr($x, -9); @@ -1205,10 +1205,10 @@ class Engineering } $x = (string) $x; if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { - return Functions::NaN(); + return Functions::NAN(); } if (strlen($x) > 10) { - return Functions::NaN(); + return Functions::NAN(); } elseif (strlen($x) == 10) { // Two's Complement return str_repeat('F', 8).substr(strtoupper(dechex(bindec(substr($x, -9)))), -2); @@ -1260,10 +1260,10 @@ class Engineering } $x = (string) $x; if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { - return Functions::NaN(); + return Functions::NAN(); } if (strlen($x) > 10) { - return Functions::NaN(); + return Functions::NAN(); } elseif (strlen($x) == 10) { // Two's Complement return str_repeat('7', 7).substr(strtoupper(decoct(bindec(substr($x, -9)))), -3); @@ -1324,7 +1324,7 @@ class Engineering // Two's Complement $r = substr($r, -10); } elseif (strlen($r) > 11) { - return Functions::NaN(); + return Functions::NAN(); } return self::nbrConversionFormat($r, $places); @@ -1482,7 +1482,7 @@ class Engineering } $x = (string) $x; if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { - return Functions::NaN(); + return Functions::NAN(); } $binVal = decbin(hexdec($x)); @@ -1518,7 +1518,7 @@ class Engineering } $x = (string) $x; if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { - return Functions::NaN(); + return Functions::NAN(); } return hexdec($x); } @@ -1566,7 +1566,7 @@ class Engineering } $x = (string) $x; if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { - return Functions::NaN(); + return Functions::NAN(); } $octVal = decoct(hexdec($x)); @@ -1618,7 +1618,7 @@ class Engineering } $x = (string) $x; if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { - return Functions::NaN(); + return Functions::NAN(); } $r = decbin(octdec($x)); @@ -1654,7 +1654,7 @@ class Engineering } $x = (string) $x; if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { - return Functions::NaN(); + return Functions::NAN(); } return octdec($x); } @@ -1699,7 +1699,7 @@ class Engineering } $x = (string) $x; if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { - return Functions::NaN(); + return Functions::NAN(); } $hexVal = strtoupper(dechex(octdec($x))); @@ -2007,7 +2007,7 @@ class Engineering $parsedComplex = self::parseComplex($complexNumber); if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { - return Functions::NaN(); + return Functions::NAN(); } $logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']))); @@ -2039,7 +2039,7 @@ class Engineering $parsedComplex = self::parseComplex($complexNumber); if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { - return Functions::NaN(); + return Functions::NAN(); } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) { return log10($parsedComplex['real']); } @@ -2066,7 +2066,7 @@ class Engineering $parsedComplex = self::parseComplex($complexNumber); if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { - return Functions::NaN(); + return Functions::NAN(); } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) { return log($parsedComplex['real'], 2); } @@ -2166,7 +2166,7 @@ class Engineering if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') && ($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) { - return Functions::NaN(); + return Functions::NAN(); } if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) { $parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix']; @@ -2211,7 +2211,7 @@ class Engineering if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) && ($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) { - return Functions::NaN(); + return Functions::NAN(); } elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) { $parsedComplex1['suffix'] = $parsedComplex2['suffix']; } @@ -2288,7 +2288,7 @@ class Engineering if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) { $activeSuffix = $parsedComplex['suffix']; } elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) { - return Functions::NaN(); + return Functions::NAN(); } $returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']); $returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']); diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index fbc9ffe4..65401087 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -127,7 +127,7 @@ class Financial $daysPerYear = (DateTime::isLeapYear($year)) ? 366 : 365; break; default: - return Functions::NaN(); + return Functions::NAN(); } return $daysPerYear; } @@ -196,7 +196,7 @@ class Financial $rate = (float) $rate; $par = (float) $par; if (($rate <= 0) || ($par <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis); if (!is_numeric($daysBetweenIssueAndSettlement)) { @@ -246,7 +246,7 @@ class Financial $rate = (float) $rate; $par = (float) $par; if (($rate <= 0) || ($par <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis); if (!is_numeric($daysBetweenIssueAndSettlement)) { @@ -451,7 +451,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); @@ -510,7 +510,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } switch ($basis) { @@ -583,7 +583,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); @@ -643,7 +643,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } return self::couponFirstPeriodDate($settlement, $maturity, $frequency, true); @@ -700,7 +700,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } $settlement = self::couponFirstPeriodDate($settlement, $maturity, $frequency, true); @@ -772,7 +772,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } return self::couponFirstPeriodDate($settlement, $maturity, $frequency, false); @@ -811,7 +811,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } if ($start < 1 || $start > $end) { return Functions::VALUE(); @@ -859,7 +859,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } if ($start < 1 || $start > $end) { return Functions::VALUE(); @@ -919,7 +919,7 @@ class Financial if ($cost == 0) { return 0.0; } elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) { - return Functions::NaN(); + return Functions::NAN(); } // Set Fixed Depreciation Rate $fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life)); @@ -985,7 +985,7 @@ class Financial $period = (int) $period; $factor = (float) $factor; if (($cost <= 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($factor <= 0.0) || ($period > $life)) { - return Functions::NaN(); + return Functions::NAN(); } // Set Fixed Depreciation Rate $fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life)); @@ -1045,7 +1045,7 @@ class Financial $redemption = (float) $redemption; $basis = (int) $basis; if (($price <= 0) || ($redemption <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); if (!is_numeric($daysBetweenSettlementAndMaturity)) { @@ -1082,7 +1082,7 @@ class Financial // Validate parameters if (is_null($fractional_dollar) || $fraction < 0) { - return Functions::NaN(); + return Functions::NAN(); } if ($fraction == 0) { return Functions::DIV0(); @@ -1119,7 +1119,7 @@ class Financial // Validate parameters if (is_null($decimal_dollar) || $fraction < 0) { - return Functions::NaN(); + return Functions::NAN(); } if ($fraction == 0) { return Functions::DIV0(); @@ -1155,7 +1155,7 @@ class Financial // Validate parameters if ($nominal_rate <= 0 || $npery < 1) { - return Functions::NaN(); + return Functions::NAN(); } return pow((1 + $nominal_rate / $npery), $npery) - 1; @@ -1194,7 +1194,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } // Calculate @@ -1267,7 +1267,7 @@ class Financial $redemption = (float) $redemption; $basis = (int) $basis; if (($investment <= 0) || ($redemption <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); if (!is_numeric($daysBetweenSettlementAndMaturity)) { @@ -1308,7 +1308,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } if ($per <= 0 || $per > $nper) { return Functions::VALUE(); @@ -1496,7 +1496,7 @@ class Financial // Validate parameters if ($effect_rate <= 0 || $npery < 1) { - return Functions::NaN(); + return Functions::NAN(); } // Calculate @@ -1526,18 +1526,18 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } // Calculate if (!is_null($rate) && $rate != 0) { if ($pmt == 0 && $pv == 0) { - return Functions::NaN(); + return Functions::NAN(); } return log(($pmt * (1 + $rate * $type) / $rate - $fv) / ($pv + $pmt * (1 + $rate * $type) / $rate)) / log(1 + $rate); } if ($pmt == 0) { - return Functions::NaN(); + return Functions::NAN(); } return (-$pv -$fv) / $pmt; } @@ -1592,7 +1592,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } // Calculate @@ -1627,7 +1627,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } if ($per <= 0 || $per > $nper) { return Functions::VALUE(); @@ -1659,7 +1659,7 @@ class Financial if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || (($basis < 0) || ($basis > 4))) { - return Functions::NaN(); + return Functions::NAN(); } $dsc = self::COUPDAYSNC($settlement, $maturity, $frequency, $basis); @@ -1711,7 +1711,7 @@ class Financial // Validate if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) { if (($discount <= 0) || ($redemption <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); if (!is_numeric($daysBetweenSettlementAndMaturity)) { @@ -1757,7 +1757,7 @@ class Financial // Validate if (is_numeric($rate) && is_numeric($yield)) { if (($rate <= 0) || ($yield <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); if (!is_numeric($daysPerYear)) { @@ -1812,7 +1812,7 @@ class Financial // Validate parameters if ($type != 0 && $type != 1) { - return Functions::NaN(); + return Functions::NAN(); } // Calculate @@ -1927,7 +1927,7 @@ class Financial // Validate if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) { if (($investment <= 0) || ($discount <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); if (!is_numeric($daysBetweenSettlementAndMaturity)) { @@ -1960,7 +1960,7 @@ class Financial // Calculate if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life))) { if ($life < 0) { - return Functions::NaN(); + return Functions::NAN(); } return ($cost - $salvage) / $life; } @@ -1989,7 +1989,7 @@ class Financial // Calculate if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period))) { if (($life < 1) || ($period > $life)) { - return Functions::NaN(); + return Functions::NAN(); } return (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1)); } @@ -2061,7 +2061,7 @@ class Financial // Validate if (is_numeric($discount)) { if ($discount <= 0) { - return Functions::NaN(); + return Functions::NAN(); } if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { @@ -2076,12 +2076,12 @@ class Financial } if ($daysBetweenSettlementAndMaturity > 360) { - return Functions::NaN(); + return Functions::NAN(); } $price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360)); if ($price <= 0) { - return Functions::NaN(); + return Functions::NAN(); } return $price; } @@ -2110,7 +2110,7 @@ class Financial // Validate if (is_numeric($price)) { if ($price <= 0) { - return Functions::NaN(); + return Functions::NAN(); } if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { @@ -2125,7 +2125,7 @@ class Financial } if ($daysBetweenSettlementAndMaturity > 360) { - return Functions::NaN(); + return Functions::NAN(); } return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity); @@ -2143,7 +2143,7 @@ class Financial $dates = Functions::flattenArray($dates); $guess = Functions::flattenSingleValue($guess); if (count($values) != count($dates)) { - return Functions::NaN(); + return Functions::NAN(); } // create an initial range, with a root somewhere between 0 and guess @@ -2220,7 +2220,7 @@ class Financial $dates = Functions::flattenArray($dates); $valCount = count($values); if ($valCount != count($dates)) { - return Functions::NaN(); + return Functions::NAN(); } if ((min($values) > 0) || (max($values) < 0)) { return Functions::VALUE(); @@ -2267,7 +2267,7 @@ class Financial // Validate if (is_numeric($price) && is_numeric($redemption)) { if (($price <= 0) || ($redemption <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); if (!is_numeric($daysPerYear)) { @@ -2318,7 +2318,7 @@ class Financial // Validate if (is_numeric($rate) && is_numeric($price)) { if (($rate <= 0) || ($price <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); if (!is_numeric($daysPerYear)) { diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index dfbff0a5..63285275 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -222,7 +222,7 @@ class Functions * @category Error Returns * @return string #NUM! */ - public static function NaN() + public static function NAN() { return self::$errorCodes['num']; } @@ -336,7 +336,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function ERROR_TYPE($value = '') + public static function errorType($value = '') { $value = self::flattenSingleValue($value); @@ -357,7 +357,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_BLANK($value = null) + public static function isBlank($value = null) { if (!is_null($value)) { $value = self::flattenSingleValue($value); @@ -373,11 +373,11 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_ERR($value = '') + public static function isErr($value = '') { $value = self::flattenSingleValue($value); - return self::IS_ERROR($value) && (!self::IS_NA($value)); + return self::isError($value) && (!self::isNa(($value)); } @@ -387,7 +387,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_ERROR($value = '') + public static function isError($value = '') { $value = self::flattenSingleValue($value); @@ -404,7 +404,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_NA($value = '') + public static function isNa(($value = '') { $value = self::flattenSingleValue($value); @@ -418,7 +418,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_EVEN($value = null) + public static function isEven($value = null) { $value = self::flattenSingleValue($value); @@ -438,7 +438,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_ODD($value = null) + public static function isOdd($value = null) { $value = self::flattenSingleValue($value); @@ -458,7 +458,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_NUMBER($value = null) + public static function isNumber($value = null) { $value = self::flattenSingleValue($value); @@ -475,7 +475,7 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_LOGICAL($value = null) + public static function isLogical($value = null) { $value = self::flattenSingleValue($value); @@ -489,11 +489,11 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_TEXT($value = null) + public static function isText($value = null) { $value = self::flattenSingleValue($value); - return (is_string($value) && !self::IS_ERROR($value)); + return (is_string($value) && !self::isError($value)); } @@ -503,9 +503,9 @@ class Functions * @param mixed $value Value to check * @return boolean */ - public static function IS_NONTEXT($value = null) + public static function isNonText($value = null) { - return !self::IS_TEXT($value); + return !self::isText($value); } diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index 812dd3f6..6e923fa7 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -273,6 +273,6 @@ class Logical $testValue = (is_null($testValue)) ? '' : Functions::flattenSingleValue($testValue); $errorpart = (is_null($errorpart)) ? '' : Functions::flattenSingleValue($errorpart); - return self::STATEMENT_IF(Functions::IS_ERROR($testValue), $errorpart, $testValue); + return self::STATEMENT_IF(Functions::isError($testValue), $errorpart, $testValue); } } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 8a4310cb..60b50af9 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -139,7 +139,7 @@ class MathTrig } elseif (self::SIGN($number) == self::SIGN($significance)) { return ceil($number / $significance) * $significance; } else { - return Functions::NaN(); + return Functions::NAN(); } } return Functions::VALUE(); @@ -168,9 +168,9 @@ class MathTrig if ((is_numeric($numObjs)) && (is_numeric($numInSet))) { if ($numObjs < $numInSet) { - return Functions::NaN(); + return Functions::NAN(); } elseif ($numInSet < 0) { - return Functions::NaN(); + return Functions::NAN(); } return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet); } @@ -233,12 +233,12 @@ class MathTrig if (is_numeric($factVal)) { if ($factVal < 0) { - return Functions::NaN(); + return Functions::NAN(); } $factLoop = floor($factVal); if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { if ($factVal > $factLoop) { - return Functions::NaN(); + return Functions::NAN(); } } @@ -272,7 +272,7 @@ class MathTrig if (is_numeric($factLoop)) { $factLoop = floor($factLoop); if ($factVal < 0) { - return Functions::NaN(); + return Functions::NAN(); } $factorial = 1; while ($factLoop > 1) { @@ -317,7 +317,7 @@ class MathTrig } elseif (self::SIGN($number) == self::SIGN($significance)) { return floor($number / $significance) * $significance; } else { - return Functions::NaN(); + return Functions::NAN(); } } @@ -351,7 +351,7 @@ class MathTrig } elseif ($value == 0) { continue; } elseif ($value < 0) { - return Functions::NaN(); + return Functions::NAN(); } $myFactors = self::factors($value); $myCountedFactors = array_count_values($myFactors); @@ -459,7 +459,7 @@ class MathTrig if ($value == 0) { return 0; } elseif ($value < 0) { - return Functions::NaN(); + return Functions::NAN(); } $myFactors = self::factors(floor($value)); $myCountedFactors = array_count_values($myFactors); @@ -507,7 +507,7 @@ class MathTrig return Functions::VALUE(); } if (($base <= 0) || ($number <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } return log($number, $base); } @@ -724,7 +724,7 @@ class MathTrig $multiplier = 1 / $multiple; return round($number * $multiplier) / $multiplier; } - return Functions::NaN(); + return Functions::NAN(); } return Functions::VALUE(); } @@ -747,7 +747,7 @@ class MathTrig // Is it a numeric value? if (is_numeric($arg)) { if ($arg < 1) { - return Functions::NaN(); + return Functions::NAN(); } $summer += floor($arg); $divisor *= self::FACT($arg); @@ -814,14 +814,14 @@ class MathTrig // Validate parameters if ($x == 0.0 && $y == 0.0) { - return Functions::NaN(); + return Functions::NAN(); } elseif ($x == 0.0 && $y < 0.0) { return Functions::DIV0(); } // Return $result = pow($x, $y); - return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NaN(); + return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN(); } @@ -1087,7 +1087,7 @@ class MathTrig if (is_numeric($number)) { if ($number < 0) { - return Functions::NaN(); + return Functions::NAN(); } return sqrt($number * M_PI) ; } diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 6245b3fc..a13c17c0 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -743,7 +743,7 @@ class Statistical } return $returnValue / $aCount; } - return Functions::NaN(); + return Functions::NAN(); } @@ -906,7 +906,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) { if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) { - return Functions::NaN(); + return Functions::NAN(); } if ($rMin > $rMax) { $tmp = $rMin; @@ -945,7 +945,7 @@ class Statistical if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) { if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) { - return Functions::NaN(); + return Functions::NAN(); } if ($rMin > $rMax) { $tmp = $rMin; @@ -1002,10 +1002,10 @@ class Statistical if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) { if (($value < 0) || ($value > $trials)) { - return Functions::NaN(); + return Functions::NAN(); } if (($probability < 0) || ($probability > 1)) { - return Functions::NaN(); + return Functions::NAN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { @@ -1039,13 +1039,13 @@ class Statistical if ((is_numeric($value)) && (is_numeric($degrees))) { if ($degrees < 1) { - return Functions::NaN(); + return Functions::NAN(); } if ($value < 0) { if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { return 1; } - return Functions::NaN(); + return Functions::NAN(); } return 1 - (self::incompleteGamma($degrees/2, $value/2) / self::gamma($degrees/2)); } @@ -1128,10 +1128,10 @@ class Statistical if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) { if (($alpha <= 0) || ($alpha >= 1)) { - return Functions::NaN(); + return Functions::NAN(); } if (($stdDev <= 0) || ($size < 1)) { - return Functions::NaN(); + return Functions::NAN(); } return self::NORMSINV(1 - $alpha / 2) * $stdDev / sqrt($size); } @@ -1355,11 +1355,11 @@ class Statistical if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) { if ($trials < 0) { - return Functions::NaN(); + return Functions::NAN(); } elseif (($probability < 0) || ($probability > 1)) { - return Functions::NaN(); + return Functions::NAN(); } elseif (($alpha < 0) || ($alpha > 1)) { - return Functions::NaN(); + return Functions::NAN(); } elseif ($alpha <= 0.5) { $t = sqrt(log(1 / ($alpha * $alpha))); $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)); @@ -1494,7 +1494,7 @@ class Statistical // Return if (is_null($returnValue)) { - return Functions::NaN(); + return Functions::NAN(); } else { return $returnValue; } @@ -1523,7 +1523,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($lambda))) { if (($value < 0) || ($lambda < 0)) { - return Functions::NaN(); + return Functions::NAN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { @@ -1553,7 +1553,7 @@ class Statistical if (is_numeric($value)) { if (($value <= -1) || ($value >= 1)) { - return Functions::NaN(); + return Functions::NAN(); } return 0.5 * log((1+$value)/(1-$value)); } @@ -1634,7 +1634,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($a)) && (is_numeric($b))) { if (($value < 0) || ($a <= 0) || ($b <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { @@ -1667,7 +1667,7 @@ class Statistical if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) { if (($alpha <= 0) || ($beta <= 0) || ($probability < 0) || ($probability > 1)) { - return Functions::NaN(); + return Functions::NAN(); } $xLo = 0; @@ -1724,7 +1724,7 @@ class Statistical if (is_numeric($value)) { if ($value <= 0) { - return Functions::NaN(); + return Functions::NAN(); } return log(self::gamma($value)); } @@ -1758,7 +1758,7 @@ class Statistical return pow($aMean, (1 / $aCount)); } } - return Functions::NaN(); + return Functions::NAN(); } @@ -1816,14 +1816,14 @@ class Statistical // Loop through arguments $aArgs = Functions::flattenArray(func_get_args()); if (self::MIN($aArgs) < 0) { - return Functions::NaN(); + return Functions::NAN(); } $aCount = 0; foreach ($aArgs as $arg) { // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { if ($arg <= 0) { - return Functions::NaN(); + return Functions::NAN(); } if (is_null($returnValue)) { $returnValue = (1 / $arg); @@ -1865,13 +1865,13 @@ class Statistical if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) { if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) { - return Functions::NaN(); + return Functions::NAN(); } if (($sampleNumber <= 0) || ($sampleNumber > $populationNumber)) { - return Functions::NaN(); + return Functions::NAN(); } if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) { - return Functions::NaN(); + return Functions::NAN(); } return MathTrig::COMBIN($populationSuccesses, $sampleSuccesses) * MathTrig::COMBIN($populationNumber - $populationSuccesses, $sampleNumber - $sampleSuccesses) / @@ -1984,7 +1984,7 @@ class Statistical $count = self::COUNT($mArgs); $entry = floor(--$entry); if (($entry < 0) || ($entry >= $count) || ($count == 0)) { - return Functions::NaN(); + return Functions::NAN(); } rsort($mArgs); return $mArgs[$entry]; @@ -2081,7 +2081,7 @@ class Statistical foreach ($yValues as $value) { if ($value <= 0.0) { - return Functions::NaN(); + return Functions::NAN(); } } @@ -2141,7 +2141,7 @@ class Statistical if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } return exp($mean + $stdDev * self::NORMSINV($probability)); } @@ -2168,7 +2168,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { if (($value <= 0) || ($stdDev <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } return self::NORMSDIST((log($value) - $mean) / $stdDev); } @@ -2307,7 +2307,7 @@ class Statistical */ public static function MEDIAN() { - $returnValue = Functions::NaN(); + $returnValue = Functions::NAN(); $mArgs = array(); // Loop through arguments @@ -2548,13 +2548,13 @@ class Statistical if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) { if (($failures < 0) || ($successes < 1)) { - return Functions::NaN(); + return Functions::NAN(); } elseif (($probability < 0) || ($probability > 1)) { - return Functions::NaN(); + return Functions::NAN(); } if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { if (($failures + $successes - 1) <= 0) { - return Functions::NaN(); + return Functions::NAN(); } } return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures)); @@ -2585,7 +2585,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { if ($stdDev < 0) { - return Functions::NaN(); + return Functions::NAN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { @@ -2618,10 +2618,10 @@ class Statistical if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { if (($probability < 0) || ($probability > 1)) { - return Functions::NaN(); + return Functions::NAN(); } if ($stdDev < 0) { - return Functions::NaN(); + return Functions::NAN(); } return (self::inverseNcdf($probability) * $stdDev) + $mean; } @@ -2684,7 +2684,7 @@ class Statistical if ((is_numeric($entry)) && (!is_string($entry))) { if (($entry < 0) || ($entry > 1)) { - return Functions::NaN(); + return Functions::NAN(); } $mArgs = array(); foreach ($aArgs as $arg) { @@ -2736,7 +2736,7 @@ class Statistical sort($valueSet, SORT_NUMERIC); $valueCount = count($valueSet); if ($valueCount == 0) { - return Functions::NaN(); + return Functions::NAN(); } $valueAdjustor = $valueCount - 1; @@ -2780,7 +2780,7 @@ class Statistical if ((is_numeric($numObjs)) && (is_numeric($numInSet))) { $numInSet = floor($numInSet); if ($numObjs < $numInSet) { - return Functions::NaN(); + return Functions::NAN(); } return round(MathTrig::FACT($numObjs) / MathTrig::FACT($numObjs - $numInSet)); } @@ -2808,7 +2808,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($mean))) { if (($value < 0) || ($mean <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { @@ -2850,7 +2850,7 @@ class Statistical if ((is_numeric($entry)) && (!is_string($entry))) { $entry /= 4; if (($entry < 0) || ($entry > 1)) { - return Functions::NaN(); + return Functions::NAN(); } return self::PERCENTILE($aArgs, $entry); } @@ -3021,7 +3021,7 @@ class Statistical $count = self::COUNT($mArgs); $entry = floor(--$entry); if (($entry < 0) || ($entry >= $count) || ($count == 0)) { - return Functions::NaN(); + return Functions::NAN(); } sort($mArgs); return $mArgs[$entry]; @@ -3048,7 +3048,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { if ($stdDev <= 0) { - return Functions::NaN(); + return Functions::NAN(); } return ($value - $mean) / $stdDev ; } @@ -3299,7 +3299,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) { if (($value < 0) || ($degrees < 1) || ($tails < 1) || ($tails > 2)) { - return Functions::NaN(); + return Functions::NAN(); } // tdist, which finds the probability that corresponds to a given value // of t with k degrees of freedom. This algorithm is translated from a @@ -3458,7 +3458,7 @@ class Statistical if ((is_numeric($percent)) && (!is_string($percent))) { if (($percent < 0) || ($percent > 1)) { - return Functions::NaN(); + return Functions::NAN(); } $mArgs = array(); foreach ($aArgs as $arg) { @@ -3691,7 +3691,7 @@ class Statistical if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) { if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) { - return Functions::NaN(); + return Functions::NAN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php index 5464ffac..7950fe47 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -199,7 +199,7 @@ class TextData // Validate parameters if (!is_numeric($value) || !is_numeric($decimals)) { - return Functions::NaN(); + return Functions::NAN(); } $decimals = floor($decimals); @@ -309,7 +309,7 @@ class TextData // Validate parameters if (!is_numeric($value) || !is_numeric($decimals)) { - return Functions::NaN(); + return Functions::NAN(); } $decimals = floor($decimals); diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index 59a9a72d..9473a3e1 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -532,7 +532,7 @@ class Matrix if ($validValues) { $this->A[$i][$j] += $value; } else { - $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN(); + $this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN(); } } } @@ -626,7 +626,7 @@ class Matrix if ($validValues) { $this->A[$i][$j] -= $value; } else { - $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN(); + $this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN(); } } } @@ -722,7 +722,7 @@ class Matrix if ($validValues) { $this->A[$i][$j] *= $value; } else { - $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN(); + $this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN(); } } } @@ -782,7 +782,7 @@ class Matrix $M->set($i, $j, $this->A[$i][$j] / $value); } } else { - $M->set($i, $j, PHPExcel_Calculation_Functions::NaN()); + $M->set($i, $j, PHPExcel_Calculation_Functions::NAN()); } } } @@ -1058,7 +1058,7 @@ class Matrix if ($validValues) { $this->A[$i][$j] = pow($this->A[$i][$j], $value); } else { - $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN(); + $this->A[$i][$j] = PHPExcel_Calculation_Functions::NAN(); } } } diff --git a/unitTests/Classes/src/Calculation/FunctionsTest.php b/unitTests/Classes/src/Calculation/FunctionsTest.php index 9ee1b5a5..054e8908 100644 --- a/unitTests/Classes/src/Calculation/FunctionsTest.php +++ b/unitTests/Classes/src/Calculation/FunctionsTest.php @@ -30,9 +30,9 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase $this->assertEquals('#N/A', $result); } - public function testNaN() + public function testNAN() { - $result = \PHPExcel\Calculation\Functions::NaN(); + $result = \PHPExcel\Calculation\Functions::NAN(); $this->assertEquals('#NUM!', $result); } @@ -67,7 +67,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_BLANK'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isBlank'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -115,13 +115,13 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','ERROR_TYPE'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','errorType'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } public function providerERROR_TYPE() { - return new \testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data'); + return new \testDataFileIterator('rawTestData/Calculation/Functions/errorType.data'); } /** @@ -131,7 +131,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_LOGICAL'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isLogical'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -147,7 +147,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_NA'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isError('), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -163,7 +163,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_NUMBER'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isNumber'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -179,7 +179,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_TEXT'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isText'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -195,7 +195,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_NONTEXT'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isNonText'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -211,7 +211,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_EVEN'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isEven'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); } @@ -227,7 +227,7 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase { $args = func_get_args(); $expectedResult = array_pop($args); - $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','IS_ODD'), $args); + $result = call_user_func_array(array('\PHPExcel\Calculation\Functions','isOdd'), $args); $this->assertEquals($expectedResult, $result, null, 1E-8); }