From 83a50537b200a9942ea593863f04fa1bb77b388a Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 4 Jan 2020 22:17:40 +0100 Subject: [PATCH] Return type docblock fixes (#1305) * Return type docblock fixes --- .../Calculation/Calculation.php | 4 +- src/PhpSpreadsheet/Calculation/DateTime.php | 4 +- .../Calculation/Engineering.php | 8 +-- src/PhpSpreadsheet/Calculation/Financial.php | 40 +++++++------- src/PhpSpreadsheet/Calculation/MathTrig.php | 52 +++++++++---------- .../Calculation/Statistical.php | 50 +++++++++--------- 6 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 3bf592c9..1e299f47 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2864,13 +2864,13 @@ class Calculation $this->debugLog->clearLog(); $this->cyclicReferenceStack->clear(); + $resetCache = $this->getCalculationCacheEnabled(); if ($this->spreadsheet !== null && $cellID === null && $pCell === null) { $cellID = 'A1'; $pCell = $this->spreadsheet->getActiveSheet()->getCell($cellID); } else { // Disable calculation cacheing because it only applies to cell calculations, not straight formulae // But don't actually flush any cache - $resetCache = $this->getCalculationCacheEnabled(); $this->calculationCacheEnabled = false; } @@ -3239,7 +3239,7 @@ class Calculation /** * @param string $formula * - * @return string + * @return false|string False indicates an error */ private function convertMatrixReferences($formula) { diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 796e7959..55740fc1 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -491,7 +491,7 @@ class DateTime $yearFound = true; } } - if ((count($t1) == 1) && (strpos($t, ':') != false)) { + if ((count($t1) == 1) && (strpos($t, ':') !== false)) { // We've been fed a time value without any date return 0.0; } elseif (count($t1) == 2) { @@ -892,7 +892,7 @@ class DateTime * 3 Actual/365 * 4 European 30/360 * - * @return float fraction of the year + * @return float|string fraction of the year, or a string containing an error */ public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) { diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 458d0e86..c3942b2b 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -785,7 +785,7 @@ class Engineering * If $ord is nonnumeric, BESSELI returns the #VALUE! error value. * If $ord < 0, BESSELI returns the #NUM! error value. * - * @return float + * @return float|string Result, or a string containing an error */ public static function BESSELI($x, $ord) { @@ -839,7 +839,7 @@ class Engineering * If $ord is nonnumeric, BESSELJ returns the #VALUE! error value. * If $ord < 0, BESSELJ returns the #NUM! error value. * - * @return float + * @return float|string Result, or a string containing an error */ public static function BESSELJ($x, $ord) { @@ -932,7 +932,7 @@ class Engineering * If $ord is nonnumeric, BESSELK returns the #VALUE! error value. * If $ord < 0, BESSELK returns the #NUM! error value. * - * @return float + * @return float|string Result, or a string containing an error */ public static function BESSELK($x, $ord) { @@ -1021,7 +1021,7 @@ class Engineering * If $ord is nonnumeric, BESSELK returns the #VALUE! error value. * If $ord < 0, BESSELK returns the #NUM! error value. * - * @return float + * @return float|string Result, or a string containing an error */ public static function BESSELY($x, $ord) { diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 90bb36df..412b7a62 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -71,7 +71,7 @@ class Financial * 3 365 * 4 European 360 * - * @return int + * @return int|string Result, or a string containing an error */ private static function daysPerYear($year, $basis = 0) { @@ -144,7 +144,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par = 1000, $frequency = 1, $basis = 0) { @@ -197,7 +197,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function ACCRINTM($issue, $settlement, $rate, $par = 1000, $basis = 0) { @@ -1424,7 +1424,7 @@ class Financial * @param float $finance_rate The interest rate you pay on the money used in the cash flows * @param float $reinvestment_rate The interest rate you receive on the cash flows as you reinvest them * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function MIRR($values, $finance_rate, $reinvestment_rate) { @@ -1466,7 +1466,7 @@ class Financial * @param float $effect_rate Effective interest rate * @param int $npery Number of compounding payments per year * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function NOMINAL($effect_rate = 0, $npery = 0) { @@ -1493,7 +1493,7 @@ class Financial * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) { @@ -1561,7 +1561,7 @@ class Financial * @param float $pv Present Value * @param float $fv Future Value * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function PDURATION($rate = 0, $pv = 0, $fv = 0) { @@ -1590,7 +1590,7 @@ class Financial * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period * - * @return float + * @return float|string Result, or a string containing an error */ public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) { @@ -1625,7 +1625,7 @@ class Financial * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period * - * @return float + * @return float|string Result, or a string containing an error */ public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) { @@ -1709,7 +1709,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float + * @return float|string Result, or a string containing an error */ public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis = 0) { @@ -1755,7 +1755,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float + * @return float|string Result, or a string containing an error */ public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis = 0) { @@ -1813,7 +1813,7 @@ class Financial * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period * - * @return float + * @return float|string Result, or a string containing an error */ public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) { @@ -1929,7 +1929,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float + * @return float|string Result, or a string containing an error */ public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis = 0) { @@ -1965,7 +1965,7 @@ class Financial * @param float $pv Present Value * @param float $fv Future Value * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function RRI($nper = 0, $pv = 0, $fv = 0) { @@ -1992,7 +1992,7 @@ class Financial * @param mixed $salvage Value at the end of the depreciation * @param mixed $life Number of periods over which the asset is depreciated * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function SLN($cost, $salvage, $life) { @@ -2022,7 +2022,7 @@ class Financial * @param mixed $life Number of periods over which the asset is depreciated * @param mixed $period Period * - * @return float|string + * @return float|string Result, or a string containing an error */ public static function SYD($cost, $salvage, $life, $period) { @@ -2054,7 +2054,7 @@ class Financial * The maturity date is the date when the Treasury bill expires. * @param int $discount The Treasury bill's discount rate * - * @return float + * @return float|string Result, or a string containing an error */ public static function TBILLEQ($settlement, $maturity, $discount) { @@ -2093,7 +2093,7 @@ class Financial * The maturity date is the date when the Treasury bill expires. * @param int $discount The Treasury bill's discount rate * - * @return float + * @return float|string Result, or a string containing an error */ public static function TBILLPRICE($settlement, $maturity, $discount) { @@ -2339,7 +2339,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float + * @return float|string Result, or a string containing an error */ public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis = 0) { @@ -2390,7 +2390,7 @@ class Financial * 3 Actual/365 * 4 European 30/360 * - * @return float + * @return float|string Result, or a string containing an error */ public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis = 0) { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index fc9211b8..a73e14e1 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -59,7 +59,7 @@ class MathTrig * @param float $xCoordinate the x-coordinate of the point * @param float $yCoordinate the y-coordinate of the point * - * @return float the inverse tangent of the specified x- and y-coordinates + * @return float|string the inverse tangent of the specified x- and y-coordinates, or a string containing an error */ public static function ATAN2($xCoordinate = null, $yCoordinate = null) { @@ -100,7 +100,7 @@ class MathTrig * @param float $number the number you want to round * @param float $significance the multiple to which you want to round * - * @return float Rounded Number + * @return float|string Rounded Number, or a string containing an error */ public static function CEILING($number, $significance = null) { @@ -139,7 +139,7 @@ class MathTrig * @param int $numObjs Number of different objects * @param int $numInSet Number of objects in each combination * - * @return int Number of combinations + * @return int|string Number of combinations, or a string containing an error */ public static function COMBIN($numObjs, $numInSet) { @@ -175,7 +175,7 @@ class MathTrig * * @param float $number Number to round * - * @return int Rounded Number + * @return int|string Rounded Number, or a string containing an error */ public static function EVEN($number) { @@ -209,7 +209,7 @@ class MathTrig * * @param float $factVal Factorial Value * - * @return int Factorial + * @return int|string Factorial, or a string containing an error */ public static function FACT($factVal) { @@ -248,7 +248,7 @@ class MathTrig * * @param float $factVal Factorial Value * - * @return int Double Factorial + * @return int|string Double Factorial, or a string containing an error */ public static function FACTDOUBLE($factVal) { @@ -284,7 +284,7 @@ class MathTrig * @param float $number Number to round * @param float $significance Significance * - * @return float Rounded Number + * @return float|string Rounded Number, or a string containing an error */ public static function FLOOR($number, $significance = null) { @@ -332,7 +332,7 @@ class MathTrig * * @param mixed ...$args Data values * - * @return int Greatest Common Divisor + * @return int|mixed|string Greatest Common Divisor, or a string containing an error */ public static function GCD(...$args) { @@ -366,7 +366,7 @@ class MathTrig * * @param float $number Number to cast to an integer * - * @return int Integer value + * @return int|string Integer value, or a string containing an error */ public static function INT($number) { @@ -399,7 +399,7 @@ class MathTrig * * @param mixed ...$args Data values * - * @return int Lowest Common Multiplier + * @return int|string Lowest Common Multiplier, or a string containing an error */ public static function LCM(...$args) { @@ -451,7 +451,7 @@ class MathTrig * @param float $number The positive real number for which you want the logarithm * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10. * - * @return float + * @return float|string The result, or a string containing an error */ public static function logBase($number = null, $base = 10) { @@ -480,7 +480,7 @@ class MathTrig * * @param array $matrixValues A matrix of values * - * @return float + * @return float|string The result, or a string containing an error */ public static function MDETERM($matrixValues) { @@ -532,7 +532,7 @@ class MathTrig * * @param array $matrixValues A matrix of values * - * @return array + * @return array|string The result, or a string containing an error */ public static function MINVERSE($matrixValues) { @@ -582,7 +582,7 @@ class MathTrig * @param array $matrixData1 A matrix of values * @param array $matrixData2 A matrix of values * - * @return array + * @return array|string The result, or a string containing an error */ public static function MMULT($matrixData1, $matrixData2) { @@ -644,7 +644,7 @@ class MathTrig * @param int $a Dividend * @param int $b Divisor * - * @return int Remainder + * @return int|string Remainder, or a string containing an error */ public static function MOD($a = 1, $b = 1) { @@ -670,7 +670,7 @@ class MathTrig * @param float $number Number to round * @param int $multiple Multiple to which you want to round $number * - * @return float Rounded Number + * @return float|string Rounded Number, or a string containing an error */ public static function MROUND($number, $multiple) { @@ -700,7 +700,7 @@ class MathTrig * * @param array of mixed Data Series * - * @return float + * @return float|string The result, or a string containing an error */ public static function MULTINOMIAL(...$args) { @@ -737,7 +737,7 @@ class MathTrig * * @param float $number Number to round * - * @return int Rounded Number + * @return int|string Rounded Number, or a string containing an error */ public static function ODD($number) { @@ -772,7 +772,7 @@ class MathTrig * @param float $x * @param float $y * - * @return float + * @return float|string The result, or a string containing an error */ public static function POWER($x = 0, $y = 2) { @@ -931,7 +931,7 @@ class MathTrig * @param float $number Number to round * @param int $digits Number of digits to which you want to round $number * - * @return float Rounded Number + * @return float|string Rounded Number, or a string containing an error */ public static function ROUNDUP($number, $digits) { @@ -958,7 +958,7 @@ class MathTrig * @param float $number Number to round * @param int $digits Number of digits to which you want to round $number * - * @return float Rounded Number + * @return float|string Rounded Number, or a string containing an error */ public static function ROUNDDOWN($number, $digits) { @@ -987,7 +987,7 @@ class MathTrig * @param float $m Step by which to increase $n for each term in the series * @param array of mixed Data Series * - * @return float + * @return float|string The result, or a string containing an error */ public static function SERIESSUM(...$args) { @@ -1026,7 +1026,7 @@ class MathTrig * * @param float $number Number to round * - * @return int sign value + * @return int|string sign value, or a string containing an error */ public static function SIGN($number) { @@ -1053,7 +1053,7 @@ class MathTrig * * @param float $number Number * - * @return float Square Root of Number * Pi + * @return float|string Square Root of Number * Pi, or a string containing an error */ public static function SQRTPI($number) { @@ -1307,7 +1307,7 @@ class MathTrig * * @param mixed ...$args Data values * - * @return float + * @return float|string The result, or a string containing an error */ public static function SUMPRODUCT(...$args) { @@ -1452,7 +1452,7 @@ class MathTrig * @param float $value * @param int $digits * - * @return float Truncated value + * @return float|string Truncated value, or a string containing an error */ public static function TRUNC($value = 0, $digits = 0) { diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 1f9c7665..b1c7fb02 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -1929,7 +1929,7 @@ class Statistical * @param mixed $args Data values * @param int $entry Position (ordered from the largest) in the array or range of data to return * - * @return float + * @return float|string The result, or a string containing an error */ public static function LARGE(...$args) { @@ -1970,7 +1970,7 @@ class Statistical * @param bool $const a logical value specifying whether to force the intersect to equal 0 * @param bool $stats a logical value specifying whether to return additional regression statistics * - * @return array + * @return array|int|string The result, or a string containing an error */ public static function LINEST($yValues, $xValues = null, $const = true, $stats = false) { @@ -2029,7 +2029,7 @@ class Statistical * @param bool $const a logical value specifying whether to force the intersect to equal 0 * @param bool $stats a logical value specifying whether to return additional regression statistics * - * @return array + * @return array|int|string The result, or a string containing an error */ public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false) { @@ -2092,7 +2092,7 @@ class Statistical * @param float $mean * @param float $stdDev * - * @return float + * @return float|string The result, or a string containing an error * * @todo Try implementing P J Acklam's refinement algorithm for greater * accuracy if I can get my head round the mathematics @@ -2125,7 +2125,7 @@ class Statistical * @param float $mean * @param float $stdDev * - * @return float + * @return float|string The result, or a string containing an error */ public static function LOGNORMDIST($value, $mean, $stdDev) { @@ -2293,7 +2293,7 @@ class Statistical * * @param mixed ...$args Data values * - * @return float + * @return float|string The result, or a string containing an error */ public static function MEDIAN(...$args) { @@ -2511,7 +2511,7 @@ class Statistical * * @param mixed ...$args Data values * - * @return float + * @return float|string The result, or a string containing an error */ public static function MODE(...$args) { @@ -2548,7 +2548,7 @@ class Statistical * @param float $successes Threshold number of Successes * @param float $probability Probability of success on each trial * - * @return float + * @return float|string The result, or a string containing an error */ public static function NEGBINOMDIST($failures, $successes, $probability) { @@ -2586,7 +2586,7 @@ class Statistical * @param float $stdDev Standard Deviation * @param bool $cumulative * - * @return float + * @return float|string The result, or a string containing an error */ public static function NORMDIST($value, $mean, $stdDev, $cumulative) { @@ -2619,7 +2619,7 @@ class Statistical * @param float $mean Mean Value * @param float $stdDev Standard Deviation * - * @return float + * @return float|string The result, or a string containing an error */ public static function NORMINV($probability, $mean, $stdDev) { @@ -2650,7 +2650,7 @@ class Statistical * * @param float $value * - * @return float + * @return float|string The result, or a string containing an error */ public static function NORMSDIST($value) { @@ -2666,7 +2666,7 @@ class Statistical * * @param float $value * - * @return float + * @return float|string The result, or a string containing an error */ public static function NORMSINV($value) { @@ -2686,7 +2686,7 @@ class Statistical * @param mixed $args Data values * @param float $entry Percentile value in the range 0..1, inclusive. * - * @return float + * @return float|string The result, or a string containing an error */ public static function PERCENTILE(...$args) { @@ -2784,7 +2784,7 @@ class Statistical * @param int $numObjs Number of different objects * @param int $numInSet Number of objects in each permutation * - * @return int|string Number of permutations + * @return int|string Number of permutations, or a string containing an error */ public static function PERMUT($numObjs, $numInSet) { @@ -2814,7 +2814,7 @@ class Statistical * @param float $mean Mean Value * @param bool $cumulative * - * @return float + * @return float|string The result, or a string containing an error */ public static function POISSON($value, $mean, $cumulative) { @@ -2856,7 +2856,7 @@ class Statistical * @param mixed $args Data values * @param int $entry Quartile value in the range 1..3, inclusive. * - * @return float + * @return float|string The result, or a string containing an error */ public static function QUARTILE(...$args) { @@ -2886,7 +2886,7 @@ class Statistical * @param float[] $valueSet An array of, or a reference to, a list of numbers * @param int $order Order to sort the values in the value set * - * @return float + * @return float|string The result, or a string containing an error */ public static function RANK($value, $valueSet, $order = 0) { @@ -2921,7 +2921,7 @@ class Statistical * @param mixed[] $yValues Data Series Y * @param mixed[] $xValues Data Series X * - * @return float|string + * @return float|string The result, or a string containing an error */ public static function RSQ($yValues, $xValues) { @@ -2952,7 +2952,7 @@ class Statistical * * @param array ...$args Data Series * - * @return float|string + * @return float|string The result, or a string containing an error */ public static function SKEW(...$args) { @@ -2989,7 +2989,7 @@ class Statistical * @param mixed[] $yValues Data Series Y * @param mixed[] $xValues Data Series X * - * @return float|string + * @return float|string The result, or a string containing an error */ public static function SLOPE($yValues, $xValues) { @@ -3024,7 +3024,7 @@ class Statistical * @param mixed $args Data values * @param int $entry Position (ordered from the smallest) in the array or range of data to return * - * @return float + * @return float|string The result, or a string containing an error */ public static function SMALL(...$args) { @@ -3063,7 +3063,7 @@ class Statistical * @param float $mean Mean Value * @param float $stdDev Standard Deviation * - * @return float Standardized value + * @return float|string Standardized value, or a string containing an error */ public static function STANDARDIZE($value, $mean, $stdDev) { @@ -3095,7 +3095,7 @@ class Statistical * * @param mixed ...$args Data values * - * @return float|string + * @return float|string The result, or a string containing an error */ public static function STDEV(...$args) { @@ -3321,7 +3321,7 @@ class Statistical * @param float $degrees degrees of freedom * @param float $tails number of tails (1 or 2) * - * @return float + * @return float|string The result, or a string containing an error */ public static function TDIST($value, $degrees, $tails) { @@ -3385,7 +3385,7 @@ class Statistical * @param float $probability Probability for the function * @param float $degrees degrees of freedom * - * @return float + * @return float|string The result, or a string containing an error */ public static function TINV($probability, $degrees) {