PhpSpreadsheet/tests/data/Calculation/MathTrig
oleibman 4134ff246a
Problems Using Builtin PHP Functions Directly As Excel Functions (#1799)
* Problems Using Builtin PHP Functions Directly As Excel Functions

This fixes issue #1789.
As originally reported, stricter typing was causing PHP8 to throw
an exception when a non-numeric value was passed to the Round function.
Previous releases of PHP did not see this problem, however, on further
analysis, they were also incorrect in returning 0 as the result in the
erroneous situation, when they should have been returning a VALUE error.
Yet more analysis showed that other functions would also have problems,
and, in addition, might not handle invalid input (e.g. a negative length
passed to REPT) or output (e.g. NAN in the case of ACOS(2)) correctly.

The following MathTrig functions are affected:
ABS, ACOS, ACOSH, ASIN, ASINH, ATAN, ATANH,
COS, COSH, DEGREES (rad2deg), EXP, LN (log), LOG10,
RADIANS (deg2rad), REPT (str_repeat), SIN, SINH, SQRT, TAN, TANH.
One TextData function (REPT) is also affected.

This change lets PhpSpreadsheet validate the input for each of these
functions before passing control to the builtin, and handle the output
afterwards.

There were no explicit tests for any of these functions, a fact made
easy to ignore by the fact that PhpSpreadsheet delegated the heavy
lifting to PHP itself for these cases. A full suite of tests is
now added for each of the affected functions.

* Scrutinizer Recommendations

Only in 3 modules which are part of this PR.

* Improved Handling of Tan(PI/2)

Return DIV0 error for TAN when COS is very small.

* Additional Trig Tests

Results which should be infinity, i.e. DIV/0 error.
2021-01-26 22:55:06 +01:00
..
ABS.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ACOS.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ACOSH.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ACOT.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
ACOTH.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
ARABIC.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
ASIN.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ASINH.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ATAN.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ATAN2.php Refactoring of math trig tests (#1102) 2019-07-23 00:50:30 +02:00
ATANH.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
BASE.php Added support for the base function (#1344) 2020-02-19 20:12:30 +01:00
CEILING.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
COMBIN.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
COS.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
COSH.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
COT.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
COTH.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
CSC.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
CSCH.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
DEGREES.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
EVEN.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
EXP.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
FACT.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
FACTDOUBLE.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
FLOOR.php FLOOR() function accept negative number and negative significance 2019-11-30 15:18:04 +01:00
FLOORMATH.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
FLOORPRECISE.php Added support for the FLOOR.MATH and FLOOR.PRECISE functions 2020-04-26 22:19:33 +09:00
GCD.php style fixes 2017-11-26 23:18:11 +00:00
INT.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
LCM.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
LN.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
LOG.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
LOG10.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
MDETERM.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
MINVERSE.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
MMULT.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
MOD.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
MROUND.php Mrand of zero to any multiple should return 0 (#1773) 2021-01-07 12:06:26 +01:00
MULTINOMIAL.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
ODD.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
POWER.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
PRODUCT.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
QUOTIENT.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
RADIANS.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ROMAN.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
ROUND.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
ROUNDDOWN.php Fix bug #1626 where values of 0 were "rounded" up/down as if they were not 0 (#1627) 2020-12-10 21:49:53 +01:00
ROUNDUP.php Fix bug #1626 where values of 0 were "rounded" up/down as if they were not 0 (#1627) 2020-12-10 21:49:53 +01:00
SEC.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
SECH.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
SERIESSUM.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
SIGN.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
SIN.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
SINH.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
SQRT.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
SQRTPI.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
SUBTOTAL.php Fix unit tests for PHP 5.6 2018-05-07 11:53:55 +09:00
SUBTOTALHIDDEN.php Fix unit tests for PHP 5.6 2018-05-07 11:53:55 +09:00
SUBTOTALNESTED.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
SUMIF.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
SUMIFS.php SUMIFS sum values only once 2018-10-28 13:09:08 +11:00
SUMPRODUCT.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
SUMSQ.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00
SUMX2MY2.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
SUMX2PY2.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
SUMXMY2.php Add further new Functions introduced in MS Excel 2013 and 2016 (#608) 2018-07-22 19:17:04 +01:00
TAN.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
TANH.php Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
TRUNC.php Use proper syntax for variadic functions 2017-01-23 15:01:20 +09:00