Skip to content

Commit b05dc31

Browse files
oleibmanMark Baker
and
Mark Baker
authored
MathTrig - Change Names of funcWhatever to evaluate (PHPOffice#2008)
* MathTrig - Change Names of funcWhatever to evaluate Per discussions while MathTrig was being broken up, this would help standardize the code. That idea was adopted partway through the breakup. This PR applies that standardization to the earlier efforts. A similar effort is required for DateTime; that will come later. This PR replaces PHPOffice#2006. The only 2 remaining funcWhatevers in MathTrig are both in SUM, which required two different methods depending on whether or not string parameters were to be ignored. It seems appropriate to leave those method names non-standardized in order to require a decision about which is to be used if they are invoked internally. 3 Phpstan grandfathered errors were eliminated as part of this change, and its baseline has changed accordingly. Co-authored-by: Mark Baker <[email protected]>
1 parent c79a9a8 commit b05dc31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+249
-262
lines changed

phpstan-baseline.neon

-15
Original file line numberDiff line numberDiff line change
@@ -1725,21 +1725,6 @@ parameters:
17251725
count: 2
17261726
path: src/PhpSpreadsheet/Calculation/TextData/Extract.php
17271727

1728-
-
1729-
message: "#^Parameter \\#1 \\$number of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Mround\\:\\:funcMround\\(\\) expects float, float\\|int\\|string given\\.$#"
1730-
count: 1
1731-
path: src/PhpSpreadsheet/Calculation/TextData/Format.php
1732-
1733-
-
1734-
message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#"
1735-
count: 1
1736-
path: src/PhpSpreadsheet/Calculation/TextData/Format.php
1737-
1738-
-
1739-
message: "#^Parameter \\#1 \\$number of function round expects float, float\\|int\\|string given\\.$#"
1740-
count: 1
1741-
path: src/PhpSpreadsheet/Calculation/TextData/Format.php
1742-
17431728
-
17441729
message: "#^Cannot cast array\\|float\\|int\\|string to float\\.$#"
17451730
count: 1

src/PhpSpreadsheet/Calculation/Calculation.php

+47-47
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,22 @@ class Calculation
243243
],
244244
'ACOS' => [
245245
'category' => Category::CATEGORY_MATH_AND_TRIG,
246-
'functionCall' => [MathTrig\Acos::class, 'funcAcos'],
246+
'functionCall' => [MathTrig\Acos::class, 'evaluate'],
247247
'argumentCount' => '1',
248248
],
249249
'ACOSH' => [
250250
'category' => Category::CATEGORY_MATH_AND_TRIG,
251-
'functionCall' => [MathTrig\Acosh::class, 'funcAcosh'],
251+
'functionCall' => [MathTrig\Acosh::class, 'evaluate'],
252252
'argumentCount' => '1',
253253
],
254254
'ACOT' => [
255255
'category' => Category::CATEGORY_MATH_AND_TRIG,
256-
'functionCall' => [MathTrig\Acot::class, 'funcAcot'],
256+
'functionCall' => [MathTrig\Acot::class, 'evaluate'],
257257
'argumentCount' => '1',
258258
],
259259
'ACOTH' => [
260260
'category' => Category::CATEGORY_MATH_AND_TRIG,
261-
'functionCall' => [MathTrig\Acoth::class, 'funcAcoth'],
261+
'functionCall' => [MathTrig\Acoth::class, 'evaluate'],
262262
'argumentCount' => '1',
263263
],
264264
'ADDRESS' => [
@@ -303,27 +303,27 @@ class Calculation
303303
],
304304
'ASIN' => [
305305
'category' => Category::CATEGORY_MATH_AND_TRIG,
306-
'functionCall' => [MathTrig\Asin::class, 'funcAsin'],
306+
'functionCall' => [MathTrig\Asin::class, 'evaluate'],
307307
'argumentCount' => '1',
308308
],
309309
'ASINH' => [
310310
'category' => Category::CATEGORY_MATH_AND_TRIG,
311-
'functionCall' => [MathTrig\Asinh::class, 'funcAsinh'],
311+
'functionCall' => [MathTrig\Asinh::class, 'evaluate'],
312312
'argumentCount' => '1',
313313
],
314314
'ATAN' => [
315315
'category' => Category::CATEGORY_MATH_AND_TRIG,
316-
'functionCall' => [MathTrig\Atan::class, 'funcAtan'],
316+
'functionCall' => [MathTrig\Atan::class, 'evaluate'],
317317
'argumentCount' => '1',
318318
],
319319
'ATAN2' => [
320320
'category' => Category::CATEGORY_MATH_AND_TRIG,
321-
'functionCall' => [MathTrig\Atan2::class, 'funcAtan2'],
321+
'functionCall' => [MathTrig\Atan2::class, 'evaluate'],
322322
'argumentCount' => '2',
323323
],
324324
'ATANH' => [
325325
'category' => Category::CATEGORY_MATH_AND_TRIG,
326-
'functionCall' => [MathTrig\Atanh::class, 'funcAtanh'],
326+
'functionCall' => [MathTrig\Atanh::class, 'evaluate'],
327327
'argumentCount' => '1',
328328
],
329329
'AVEDEV' => [
@@ -358,7 +358,7 @@ class Calculation
358358
],
359359
'BASE' => [
360360
'category' => Category::CATEGORY_MATH_AND_TRIG,
361-
'functionCall' => [MathTrig\Base::class, 'funcBase'],
361+
'functionCall' => [MathTrig\Base::class, 'evaluate'],
362362
'argumentCount' => '2,3',
363363
],
364364
'BESSELI' => [
@@ -463,17 +463,17 @@ class Calculation
463463
],
464464
'CEILING' => [
465465
'category' => Category::CATEGORY_MATH_AND_TRIG,
466-
'functionCall' => [MathTrig\Ceiling::class, 'funcCeiling'],
466+
'functionCall' => [MathTrig\Ceiling::class, 'evaluate'],
467467
'argumentCount' => '1-2', // 2 for Excel, 1-2 for Ods/Gnumeric
468468
],
469469
'CEILING.MATH' => [
470470
'category' => Category::CATEGORY_MATH_AND_TRIG,
471-
'functionCall' => [MathTrig\CeilingMath::class, 'funcCeilingMath'],
471+
'functionCall' => [MathTrig\CeilingMath::class, 'evaluate'],
472472
'argumentCount' => '1-3',
473473
],
474474
'CEILING.PRECISE' => [
475475
'category' => Category::CATEGORY_MATH_AND_TRIG,
476-
'functionCall' => [MathTrig\CeilingPrecise::class, 'funcCeilingPrecise'],
476+
'functionCall' => [MathTrig\CeilingPrecise::class, 'evaluate'],
477477
'argumentCount' => '1,2',
478478
],
479479
'CELL' => [
@@ -605,22 +605,22 @@ class Calculation
605605
],
606606
'COS' => [
607607
'category' => Category::CATEGORY_MATH_AND_TRIG,
608-
'functionCall' => [MathTrig\Cos::class, 'funcCos'],
608+
'functionCall' => [MathTrig\Cos::class, 'evaluate'],
609609
'argumentCount' => '1',
610610
],
611611
'COSH' => [
612612
'category' => Category::CATEGORY_MATH_AND_TRIG,
613-
'functionCall' => [MathTrig\Cosh::class, 'funcCosh'],
613+
'functionCall' => [MathTrig\Cosh::class, 'evaluate'],
614614
'argumentCount' => '1',
615615
],
616616
'COT' => [
617617
'category' => Category::CATEGORY_MATH_AND_TRIG,
618-
'functionCall' => [MathTrig\Cot::class, 'funcCot'],
618+
'functionCall' => [MathTrig\Cot::class, 'evaluate'],
619619
'argumentCount' => '1',
620620
],
621621
'COTH' => [
622622
'category' => Category::CATEGORY_MATH_AND_TRIG,
623-
'functionCall' => [MathTrig\Coth::class, 'funcCoth'],
623+
'functionCall' => [MathTrig\Coth::class, 'evaluate'],
624624
'argumentCount' => '1',
625625
],
626626
'COUNT' => [
@@ -700,12 +700,12 @@ class Calculation
700700
],
701701
'CSC' => [
702702
'category' => Category::CATEGORY_MATH_AND_TRIG,
703-
'functionCall' => [MathTrig\Csc::class, 'funcCsc'],
703+
'functionCall' => [MathTrig\Csc::class, 'evaluate'],
704704
'argumentCount' => '1',
705705
],
706706
'CSCH' => [
707707
'category' => Category::CATEGORY_MATH_AND_TRIG,
708-
'functionCall' => [MathTrig\Csch::class, 'funcCsch'],
708+
'functionCall' => [MathTrig\Csch::class, 'evaluate'],
709709
'argumentCount' => '1',
710710
],
711711
'CUBEKPIMEMBER' => [
@@ -965,7 +965,7 @@ class Calculation
965965
],
966966
'EVEN' => [
967967
'category' => Category::CATEGORY_MATH_AND_TRIG,
968-
'functionCall' => [MathTrig\Even::class, 'funcEven'],
968+
'functionCall' => [MathTrig\Even::class, 'evaluate'],
969969
'argumentCount' => '1',
970970
],
971971
'EXACT' => [
@@ -990,7 +990,7 @@ class Calculation
990990
],
991991
'FACT' => [
992992
'category' => Category::CATEGORY_MATH_AND_TRIG,
993-
'functionCall' => [MathTrig\Fact::class, 'funcFact'],
993+
'functionCall' => [MathTrig\Fact::class, 'evaluate'],
994994
'argumentCount' => '1',
995995
],
996996
'FACTDOUBLE' => [
@@ -1070,17 +1070,17 @@ class Calculation
10701070
],
10711071
'FLOOR' => [
10721072
'category' => Category::CATEGORY_MATH_AND_TRIG,
1073-
'functionCall' => [MathTrig\Floor::class, 'funcFloor'],
1073+
'functionCall' => [MathTrig\Floor::class, 'evaluate'],
10741074
'argumentCount' => '1-2', // Excel requries 2, Ods/Gnumeric 1-2
10751075
],
10761076
'FLOOR.MATH' => [
10771077
'category' => Category::CATEGORY_MATH_AND_TRIG,
1078-
'functionCall' => [MathTrig\FloorMath::class, 'funcFloorMath'],
1078+
'functionCall' => [MathTrig\FloorMath::class, 'evaluate'],
10791079
'argumentCount' => '1-3',
10801080
],
10811081
'FLOOR.PRECISE' => [
10821082
'category' => Category::CATEGORY_MATH_AND_TRIG,
1083-
'functionCall' => [MathTrig\FloorPrecise::class, 'funcFloorPrecise'],
1083+
'functionCall' => [MathTrig\FloorPrecise::class, 'evaluate'],
10841084
'argumentCount' => '1-2',
10851085
],
10861086
'FORECAST' => [
@@ -1419,7 +1419,7 @@ class Calculation
14191419
],
14201420
'INT' => [
14211421
'category' => Category::CATEGORY_MATH_AND_TRIG,
1422-
'functionCall' => [MathTrig\IntClass::class, 'funcInt'],
1422+
'functionCall' => [MathTrig\IntClass::class, 'evaluate'],
14231423
'argumentCount' => '1',
14241424
],
14251425
'INTERCEPT' => [
@@ -1536,7 +1536,7 @@ class Calculation
15361536
],
15371537
'LCM' => [
15381538
'category' => Category::CATEGORY_MATH_AND_TRIG,
1539-
'functionCall' => [MathTrig\Lcm::class, 'funcLcm'],
1539+
'functionCall' => [MathTrig\Lcm::class, 'evaluate'],
15401540
'argumentCount' => '1+',
15411541
],
15421542
'LEFT' => [
@@ -1726,17 +1726,17 @@ class Calculation
17261726
],
17271727
'MROUND' => [
17281728
'category' => Category::CATEGORY_MATH_AND_TRIG,
1729-
'functionCall' => [MathTrig\Mround::class, 'funcMround'],
1729+
'functionCall' => [MathTrig\Mround::class, 'evaluate'],
17301730
'argumentCount' => '2',
17311731
],
17321732
'MULTINOMIAL' => [
17331733
'category' => Category::CATEGORY_MATH_AND_TRIG,
1734-
'functionCall' => [MathTrig\Multinomial::class, 'funcMultinomial'],
1734+
'functionCall' => [MathTrig\Multinomial::class, 'evaluate'],
17351735
'argumentCount' => '1+',
17361736
],
17371737
'MUNIT' => [
17381738
'category' => Category::CATEGORY_MATH_AND_TRIG,
1739-
'functionCall' => [MathTrig\MatrixFunctions::class, 'funcMUnit'],
1739+
'functionCall' => [MathTrig\MatrixFunctions::class, 'identity'],
17401740
'argumentCount' => '1',
17411741
],
17421742
'N' => [
@@ -1856,7 +1856,7 @@ class Calculation
18561856
],
18571857
'ODD' => [
18581858
'category' => Category::CATEGORY_MATH_AND_TRIG,
1859-
'functionCall' => [MathTrig\Odd::class, 'funcOdd'],
1859+
'functionCall' => [MathTrig\Odd::class, 'evaluate'],
18601860
'argumentCount' => '1',
18611861
],
18621862
'ODDFPRICE' => [
@@ -2003,7 +2003,7 @@ class Calculation
20032003
],
20042004
'PRODUCT' => [
20052005
'category' => Category::CATEGORY_MATH_AND_TRIG,
2006-
'functionCall' => [MathTrig\Product::class, 'funcProduct'],
2006+
'functionCall' => [MathTrig\Product::class, 'evaluate'],
20072007
'argumentCount' => '1+',
20082008
],
20092009
'PROPER' => [
@@ -2033,7 +2033,7 @@ class Calculation
20332033
],
20342034
'QUOTIENT' => [
20352035
'category' => Category::CATEGORY_MATH_AND_TRIG,
2036-
'functionCall' => [MathTrig\Quotient::class, 'funcQuotient'],
2036+
'functionCall' => [MathTrig\Quotient::class, 'evaluate'],
20372037
'argumentCount' => '2',
20382038
],
20392039
'RADIANS' => [
@@ -2108,22 +2108,22 @@ class Calculation
21082108
],
21092109
'ROMAN' => [
21102110
'category' => Category::CATEGORY_MATH_AND_TRIG,
2111-
'functionCall' => [MathTrig\Roman::class, 'funcRoman'],
2111+
'functionCall' => [MathTrig\Roman::class, 'evaluate'],
21122112
'argumentCount' => '1,2',
21132113
],
21142114
'ROUND' => [
21152115
'category' => Category::CATEGORY_MATH_AND_TRIG,
2116-
'functionCall' => [MathTrig\Round::class, 'builtinROUND'],
2116+
'functionCall' => [MathTrig\Round::class, 'evaluate'],
21172117
'argumentCount' => '2',
21182118
],
21192119
'ROUNDDOWN' => [
21202120
'category' => Category::CATEGORY_MATH_AND_TRIG,
2121-
'functionCall' => [MathTrig\RoundDown::class, 'funcRoundDown'],
2121+
'functionCall' => [MathTrig\RoundDown::class, 'evaluate'],
21222122
'argumentCount' => '2',
21232123
],
21242124
'ROUNDUP' => [
21252125
'category' => Category::CATEGORY_MATH_AND_TRIG,
2126-
'functionCall' => [MathTrig\RoundUp::class, 'funcRoundUp'],
2126+
'functionCall' => [MathTrig\RoundUp::class, 'evaluate'],
21272127
'argumentCount' => '2',
21282128
],
21292129
'ROW' => [
@@ -2165,12 +2165,12 @@ class Calculation
21652165
],
21662166
'SEC' => [
21672167
'category' => Category::CATEGORY_MATH_AND_TRIG,
2168-
'functionCall' => [MathTrig\Sec::class, 'funcSec'],
2168+
'functionCall' => [MathTrig\Sec::class, 'evaluate'],
21692169
'argumentCount' => '1',
21702170
],
21712171
'SECH' => [
21722172
'category' => Category::CATEGORY_MATH_AND_TRIG,
2173-
'functionCall' => [MathTrig\Sech::class, 'funcSech'],
2173+
'functionCall' => [MathTrig\Sech::class, 'evaluate'],
21742174
'argumentCount' => '1',
21752175
],
21762176
'SECOND' => [
@@ -2185,7 +2185,7 @@ class Calculation
21852185
],
21862186
'SERIESSUM' => [
21872187
'category' => Category::CATEGORY_MATH_AND_TRIG,
2188-
'functionCall' => [MathTrig\SeriesSum::class, 'funcSeriesSum'],
2188+
'functionCall' => [MathTrig\SeriesSum::class, 'evaluate'],
21892189
'argumentCount' => '4',
21902190
],
21912191
'SHEET' => [
@@ -2200,17 +2200,17 @@ class Calculation
22002200
],
22012201
'SIGN' => [
22022202
'category' => Category::CATEGORY_MATH_AND_TRIG,
2203-
'functionCall' => [MathTrig\Sign::class, 'funcSign'],
2203+
'functionCall' => [MathTrig\Sign::class, 'evaluate'],
22042204
'argumentCount' => '1',
22052205
],
22062206
'SIN' => [
22072207
'category' => Category::CATEGORY_MATH_AND_TRIG,
2208-
'functionCall' => [MathTrig\Sin::class, 'funcSin'],
2208+
'functionCall' => [MathTrig\Sin::class, 'evaluate'],
22092209
'argumentCount' => '1',
22102210
],
22112211
'SINH' => [
22122212
'category' => Category::CATEGORY_MATH_AND_TRIG,
2213-
'functionCall' => [MathTrig\Sinh::class, 'funcSinh'],
2213+
'functionCall' => [MathTrig\Sinh::class, 'evaluate'],
22142214
'argumentCount' => '1',
22152215
],
22162216
'SKEW' => [
@@ -2305,7 +2305,7 @@ class Calculation
23052305
],
23062306
'SUBTOTAL' => [
23072307
'category' => Category::CATEGORY_MATH_AND_TRIG,
2308-
'functionCall' => [MathTrig\Subtotal::class, 'funcSubtotal'],
2308+
'functionCall' => [MathTrig\Subtotal::class, 'evaluate'],
23092309
'argumentCount' => '2+',
23102310
'passCellReference' => true,
23112311
],
@@ -2326,7 +2326,7 @@ class Calculation
23262326
],
23272327
'SUMPRODUCT' => [
23282328
'category' => Category::CATEGORY_MATH_AND_TRIG,
2329-
'functionCall' => [MathTrig\SumProduct::class, 'funcSumProduct'],
2329+
'functionCall' => [MathTrig\SumProduct::class, 'evaluate'],
23302330
'argumentCount' => '1+',
23312331
],
23322332
'SUMSQ' => [
@@ -2366,12 +2366,12 @@ class Calculation
23662366
],
23672367
'TAN' => [
23682368
'category' => Category::CATEGORY_MATH_AND_TRIG,
2369-
'functionCall' => [MathTrig\Tan::class, 'funcTan'],
2369+
'functionCall' => [MathTrig\Tan::class, 'evaluate'],
23702370
'argumentCount' => '1',
23712371
],
23722372
'TANH' => [
23732373
'category' => Category::CATEGORY_MATH_AND_TRIG,
2374-
'functionCall' => [MathTrig\Tanh::class, 'funcTanh'],
2374+
'functionCall' => [MathTrig\Tanh::class, 'evaluate'],
23752375
'argumentCount' => '1',
23762376
],
23772377
'TBILLEQ' => [
@@ -2476,7 +2476,7 @@ class Calculation
24762476
],
24772477
'TRUNC' => [
24782478
'category' => Category::CATEGORY_MATH_AND_TRIG,
2479-
'functionCall' => [MathTrig\Trunc::class, 'funcTrunc'],
2479+
'functionCall' => [MathTrig\Trunc::class, 'evaluate'],
24802480
'argumentCount' => '1,2',
24812481
],
24822482
'TTEST' => [

src/PhpSpreadsheet/Calculation/Database/DProduct.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function evaluate($database, $field, $criteria)
3838
return null;
3939
}
4040

41-
return MathTrig\Product::funcProduct(
41+
return MathTrig\Product::evaluate(
4242
self::getFilteredColumn($database, $field, $criteria)
4343
);
4444
}

0 commit comments

Comments
 (0)