PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig
oleibman a89572107a
Handling of #REF! Errors in Subtotal, and More (#2902)
* Handling of #REF! Errors in Subtotal, and More

This PR derives from, and supersedes, PR #2870, submitted by @ndench. The problem reported in the original is that SUBTOTAL does not handle #REF! errors in its arguments properly; however, my investigation has enlarged the scope.

The main problem is in Calculation, and it has a simple fix. When the calculation engine finds a reference to an uninitialized cell, it uses `null` as the value. This is appropriate when the cell belongs to a defined sheet; however, for an undefined sheet, #REF! is more appropriate.

With that fix in place, SUBTOTAL still needs a small fix of its own. It tries to parse its cell reference arguments into an array, but, if the reference does not match the expected format (as #REF! will not), this results in referencing undefined array indexes, with attendant messages. That assignment is changed to be more flexible, eliminating the problem and the messages.

Those 2 fixes are sufficient to ensure that the original problem is resolved. It also resolves a similar problem with some other functions (e.g. SUM). However, it does not resolve it for all functions. Or, to be more particular, many functions will return #VALUE! rather than #REF! if this arises, and the same is true for other errors in the function arguments, e.g. #DIV/0!. This PR does not attempt to address all functions; I need to think of a systematic way to pursue that. However, at least for most MathTrig functions, which validate their arguments using a common method, it is relatively easy to get the function to propagate the proper error result.

* Arrange Array The Way call_user_func_array Wants

Problem with Php8.0+ - array passed to call_user_func_array must have int keys before string keys, otherwise Php thinks we are passing positional parameters after keyword parameters.

7 other functions use flattenArrayIndexed, but Subtotal is the only one which uses that result to subsequently pass arguments to call_user_func_array. So the others should not require a change. A specific test is added for SUM to validate that conclusion.

* Change Needed for Hidden Row Filter

Same as change made to Formula Args filter.
2022-06-25 22:08:32 -07:00
..
AbsTest.php Initial work on implementing Array-enabled for the HLOOKUP() and VLOOKUP() functions (#2611) 2022-02-21 19:56:21 +01:00
AcosTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AcoshTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AcotTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AcothTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AllSetupTeardown.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
ArabicTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AsinTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AsinhTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
Atan2Test.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AtanTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
AtanhTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
BaseTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
CeilingMathTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
CeilingPreciseTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
CeilingTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
CombinATest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CombinTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CosTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CoshTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CotTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CothTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CscTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
CschTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
DegreesTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
EvenTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
ExpTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
FactDoubleTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
FactTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
FloorMathTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
FloorPreciseTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
FloorTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
GcdTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
IntTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
LcmTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
LnTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
Log10Test.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
LogTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00
MInverseTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
MMultTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
MRoundTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
MUnitTest.php MathTrig - Change Names of funcWhatever to evaluate (#2008) 2021-04-20 22:43:29 +02:00
MdeTermTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
ModTest.php Enable array-readiness for more Math/Trig functions 2022-02-12 16:56:06 +01:00
MovedFunctionsTest.php Continue MathTrig Breakup - Completion! (#1985) 2021-04-05 16:39:03 +02:00
MultinomialTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
OddTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
PowerTest.php Enable array-readiness for more Math/Trig functions 2022-02-12 16:56:06 +01:00
ProductTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
QuotientTest.php Enable array-readiness for more Math/Trig functions 2022-02-12 16:56:06 +01:00
RadiansTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
RandArrayTest.php Eliminate Most Scrutinizer Problems in Test Suite (#2699) 2022-03-21 13:58:42 -07:00
RandBetweenTest.php Eliminate Most Scrutinizer Problems in Test Suite (#2699) 2022-03-21 13:58:42 -07:00
RandTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
RomanTest.php Enable array-readiness for more Math/Trig functions 2022-02-12 16:56:06 +01:00
RoundDownTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
RoundTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
RoundUpTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SecTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SechTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SequenceTest.php Eliminate Most Scrutinizer Problems in Test Suite (#2699) 2022-03-21 13:58:42 -07:00
SeriesSumTest.php I'm ignoring SUMIF() and SUMIFS() for the moment; so this should complete all the applicable Math/Trig functions;so the subset SERIESSUM() function and RANDBETWEEN() should complete Math/Trig (#2586) 2022-02-13 12:50:05 +01:00
SignTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SinTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SinhTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SqrtPiTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SqrtTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
SubTotalTest.php Handling of #REF! Errors in Subtotal, and More (#2902) 2022-06-25 22:08:32 -07:00
SumIfTest.php Fix for Issue 2158 (AverageIf Calculation Problem) (#2160) 2021-06-15 09:54:57 +02:00
SumIfsTest.php Reduce PHPStan error in tests 2021-04-12 11:10:23 +09:00
SumProductTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
SumSqTest.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
SumTest.php Missed One 2021-05-14 09:54:24 +02:00
SumX2MY2Test.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
SumX2PY2Test.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
SumXMY2Test.php Minor Improvement to Test Cleanup MathTrig 2021-05-14 09:54:24 +02:00
TanTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
TanhTest.php Initial work enabling Excel function implementations for handling arrays as arguments when used in "array formulae". (#2562) 2022-02-09 15:12:54 +01:00
TruncTest.php Enable array-readiness for more Math/Trig functions (#2584) 2022-02-12 20:47:47 +01:00