4
4
5
5
use PhpOffice \PhpSpreadsheet \Calculation \Engine \CyclicReferenceStack ;
6
6
use PhpOffice \PhpSpreadsheet \Calculation \Engine \Logger ;
7
+ use PhpOffice \PhpSpreadsheet \Calculation \Information \Value ;
7
8
use PhpOffice \PhpSpreadsheet \Calculation \Token \Stack ;
8
9
use PhpOffice \PhpSpreadsheet \Cell \Cell ;
9
10
use PhpOffice \PhpSpreadsheet \Cell \Coordinate ;
@@ -973,7 +974,7 @@ class Calculation
973
974
],
974
975
'ERROR.TYPE ' => [
975
976
'category ' => Category::CATEGORY_INFORMATION ,
976
- 'functionCall ' => [Functions ::class, 'errorType ' ],
977
+ 'functionCall ' => [Information \ExcelError ::class, 'type ' ],
977
978
'argumentCount ' => '1 ' ,
978
979
],
979
980
'EVEN ' => [
@@ -1457,49 +1458,49 @@ class Calculation
1457
1458
],
1458
1459
'ISBLANK ' => [
1459
1460
'category ' => Category::CATEGORY_INFORMATION ,
1460
- 'functionCall ' => [Functions ::class, 'isBlank ' ],
1461
+ 'functionCall ' => [Information \Value ::class, 'isBlank ' ],
1461
1462
'argumentCount ' => '1 ' ,
1462
1463
],
1463
1464
'ISERR ' => [
1464
1465
'category ' => Category::CATEGORY_INFORMATION ,
1465
- 'functionCall ' => [Functions ::class, 'isErr ' ],
1466
+ 'functionCall ' => [Information \Value ::class, 'isErr ' ],
1466
1467
'argumentCount ' => '1 ' ,
1467
1468
],
1468
1469
'ISERROR ' => [
1469
1470
'category ' => Category::CATEGORY_INFORMATION ,
1470
- 'functionCall ' => [Functions ::class, 'isError ' ],
1471
+ 'functionCall ' => [Information \Value ::class, 'isError ' ],
1471
1472
'argumentCount ' => '1 ' ,
1472
1473
],
1473
1474
'ISEVEN ' => [
1474
1475
'category ' => Category::CATEGORY_INFORMATION ,
1475
- 'functionCall ' => [Functions ::class, 'isEven ' ],
1476
+ 'functionCall ' => [Information \Value ::class, 'isEven ' ],
1476
1477
'argumentCount ' => '1 ' ,
1477
1478
],
1478
1479
'ISFORMULA ' => [
1479
1480
'category ' => Category::CATEGORY_INFORMATION ,
1480
- 'functionCall ' => [Functions ::class, 'isFormula ' ],
1481
+ 'functionCall ' => [Information \Value ::class, 'isFormula ' ],
1481
1482
'argumentCount ' => '1 ' ,
1482
1483
'passCellReference ' => true ,
1483
1484
'passByReference ' => [true ],
1484
1485
],
1485
1486
'ISLOGICAL ' => [
1486
1487
'category ' => Category::CATEGORY_INFORMATION ,
1487
- 'functionCall ' => [Functions ::class, 'isLogical ' ],
1488
+ 'functionCall ' => [Information \Value ::class, 'isLogical ' ],
1488
1489
'argumentCount ' => '1 ' ,
1489
1490
],
1490
1491
'ISNA ' => [
1491
1492
'category ' => Category::CATEGORY_INFORMATION ,
1492
- 'functionCall ' => [Functions ::class, 'isNa ' ],
1493
+ 'functionCall ' => [Information \Value ::class, 'isNa ' ],
1493
1494
'argumentCount ' => '1 ' ,
1494
1495
],
1495
1496
'ISNONTEXT ' => [
1496
1497
'category ' => Category::CATEGORY_INFORMATION ,
1497
- 'functionCall ' => [Functions ::class, 'isNonText ' ],
1498
+ 'functionCall ' => [Information \Value ::class, 'isNonText ' ],
1498
1499
'argumentCount ' => '1 ' ,
1499
1500
],
1500
1501
'ISNUMBER ' => [
1501
1502
'category ' => Category::CATEGORY_INFORMATION ,
1502
- 'functionCall ' => [Functions ::class, 'isNumber ' ],
1503
+ 'functionCall ' => [Information \Value ::class, 'isNumber ' ],
1503
1504
'argumentCount ' => '1 ' ,
1504
1505
],
1505
1506
'ISO.CEILING ' => [
@@ -1509,7 +1510,7 @@ class Calculation
1509
1510
],
1510
1511
'ISODD ' => [
1511
1512
'category ' => Category::CATEGORY_INFORMATION ,
1512
- 'functionCall ' => [Functions ::class, 'isOdd ' ],
1513
+ 'functionCall ' => [Information \Value ::class, 'isOdd ' ],
1513
1514
'argumentCount ' => '1 ' ,
1514
1515
],
1515
1516
'ISOWEEKNUM ' => [
@@ -1529,7 +1530,7 @@ class Calculation
1529
1530
],
1530
1531
'ISTEXT ' => [
1531
1532
'category ' => Category::CATEGORY_INFORMATION ,
1532
- 'functionCall ' => [Functions ::class, 'isText ' ],
1533
+ 'functionCall ' => [Information \Value ::class, 'isText ' ],
1533
1534
'argumentCount ' => '1 ' ,
1534
1535
],
1535
1536
'ISTHAIDIGIT ' => [
@@ -1759,7 +1760,7 @@ class Calculation
1759
1760
],
1760
1761
'N ' => [
1761
1762
'category ' => Category::CATEGORY_INFORMATION ,
1762
- 'functionCall ' => [Functions ::class, 'n ' ],
1763
+ 'functionCall ' => [Information \Value ::class, 'asNumber ' ],
1763
1764
'argumentCount ' => '1 ' ,
1764
1765
],
1765
1766
'NA ' => [
@@ -2559,7 +2560,7 @@ class Calculation
2559
2560
],
2560
2561
'TYPE ' => [
2561
2562
'category ' => Category::CATEGORY_INFORMATION ,
2562
- 'functionCall ' => [Functions ::class, 'TYPE ' ],
2563
+ 'functionCall ' => [Information \Value ::class, 'type ' ],
2563
2564
'argumentCount ' => '1 ' ,
2564
2565
],
2565
2566
'UNICHAR ' => [
@@ -3252,7 +3253,7 @@ public static function wrapResult($value)
3252
3253
return self ::FORMULA_STRING_QUOTE . $ value . self ::FORMULA_STRING_QUOTE ;
3253
3254
} elseif ((is_float ($ value )) && ((is_nan ($ value )) || (is_infinite ($ value )))) {
3254
3255
// Convert numeric errors to NaN error
3255
- return Functions ::NAN ();
3256
+ return Information \ExcelError ::NAN ();
3256
3257
}
3257
3258
3258
3259
return $ value ;
@@ -3273,7 +3274,7 @@ public static function unwrapResult($value)
3273
3274
}
3274
3275
// Convert numeric errors to NAN error
3275
3276
} elseif ((is_float ($ value )) && ((is_nan ($ value )) || (is_infinite ($ value )))) {
3276
- return Functions ::NAN ();
3277
+ return Information \ExcelError ::NAN ();
3277
3278
}
3278
3279
3279
3280
return $ value ;
@@ -3342,21 +3343,21 @@ public function calculateCellValue(?Cell $cell = null, $resetLog = true)
3342
3343
self ::$ returnArrayAsType = $ returnArrayAsType ;
3343
3344
$ testResult = Functions::flattenArray ($ result );
3344
3345
if (self ::$ returnArrayAsType == self ::RETURN_ARRAY_AS_ERROR ) {
3345
- return Functions ::VALUE ();
3346
+ return Information \ExcelError ::VALUE ();
3346
3347
}
3347
3348
// If there's only a single cell in the array, then we allow it
3348
3349
if (count ($ testResult ) != 1 ) {
3349
3350
// If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it
3350
3351
$ r = array_keys ($ result );
3351
3352
$ r = array_shift ($ r );
3352
3353
if (!is_numeric ($ r )) {
3353
- return Functions ::VALUE ();
3354
+ return Information \ExcelError ::VALUE ();
3354
3355
}
3355
3356
if (is_array ($ result [$ r ])) {
3356
3357
$ c = array_keys ($ result [$ r ]);
3357
3358
$ c = array_shift ($ c );
3358
3359
if (!is_numeric ($ c )) {
3359
- return Functions ::VALUE ();
3360
+ return Information \ExcelError ::VALUE ();
3360
3361
}
3361
3362
}
3362
3363
}
@@ -3367,7 +3368,7 @@ public function calculateCellValue(?Cell $cell = null, $resetLog = true)
3367
3368
if ($ result === null && $ cell ->getWorksheet ()->getSheetView ()->getShowZeros ()) {
3368
3369
return 0 ;
3369
3370
} elseif ((is_float ($ result )) && ((is_nan ($ result )) || (is_infinite ($ result )))) {
3370
- return Functions ::NAN ();
3371
+ return Information \ExcelError ::NAN ();
3371
3372
}
3372
3373
3373
3374
return $ result ;
@@ -4428,7 +4429,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4428
4429
isset ($ storeValue )
4429
4430
&& (
4430
4431
!$ storeValueAsBool
4431
- || Functions ::isError ($ storeValue )
4432
+ || Value ::isError ($ storeValue )
4432
4433
|| ($ storeValue === 'Pruned branch ' )
4433
4434
)
4434
4435
) {
@@ -4463,7 +4464,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4463
4464
isset ($ storeValue )
4464
4465
&& (
4465
4466
$ storeValueAsBool
4466
- || Functions ::isError ($ storeValue )
4467
+ || Value ::isError ($ storeValue )
4467
4468
|| ($ storeValue === 'Pruned branch ' )
4468
4469
)
4469
4470
) {
@@ -4569,7 +4570,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4569
4570
4570
4571
$ stack ->push ('Cell Reference ' , $ cellValue , $ cellRef );
4571
4572
} else {
4572
- $ stack ->push ('Error ' , Functions ::REF (), null );
4573
+ $ stack ->push ('Error ' , Information \ExcelError ::REF (), null );
4573
4574
}
4574
4575
4575
4576
break ;
@@ -4704,7 +4705,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4704
4705
if (isset ($ matches [8 ])) {
4705
4706
if ($ cell === null ) {
4706
4707
// We can't access the range, so return a REF error
4707
- $ cellValue = Functions ::REF ();
4708
+ $ cellValue = Information \ExcelError ::REF ();
4708
4709
} else {
4709
4710
$ cellRef = $ matches [6 ] . $ matches [7 ] . ': ' . $ matches [9 ] . $ matches [10 ];
4710
4711
if ($ matches [2 ] > '' ) {
@@ -4734,7 +4735,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4734
4735
} else {
4735
4736
if ($ cell === null ) {
4736
4737
// We can't access the cell, so return a REF error
4737
- $ cellValue = Functions ::REF ();
4738
+ $ cellValue = Information \ExcelError ::REF ();
4738
4739
} else {
4739
4740
$ cellRef = $ matches [6 ] . $ matches [7 ];
4740
4741
if ($ matches [2 ] > '' ) {
@@ -5069,7 +5070,7 @@ private function executeNumericBinaryOperation($operand1, $operand2, $operation,
5069
5070
((is_string ($ operand1 ) && !is_numeric ($ operand1 ) && strlen ($ operand1 ) > 0 ) ||
5070
5071
(is_string ($ operand2 ) && !is_numeric ($ operand2 ) && strlen ($ operand2 ) > 0 ))
5071
5072
) {
5072
- $ result = Functions ::VALUE ();
5073
+ $ result = Information \ExcelError ::VALUE ();
5073
5074
} else {
5074
5075
// If we're dealing with non-matrix operations, execute the necessary operation
5075
5076
switch ($ operation ) {
@@ -5217,7 +5218,7 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet =
5217
5218
// Named range?
5218
5219
$ namedRange = DefinedName::resolveName ($ range , $ worksheet );
5219
5220
if ($ namedRange === null ) {
5220
- return Functions ::REF ();
5221
+ return Information \ExcelError ::REF ();
5221
5222
}
5222
5223
5223
5224
$ worksheet = $ namedRange ->getWorksheet ();
@@ -5406,7 +5407,7 @@ private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksh
5406
5407
$ definedNameScope = $ namedRange ->getScope ();
5407
5408
if ($ definedNameScope !== null && $ definedNameScope !== $ cellWorksheet ) {
5408
5409
// The defined name isn't in our current scope, so #REF
5409
- $ result = Functions ::REF ();
5410
+ $ result = Information \ExcelError ::REF ();
5410
5411
$ stack ->push ('Error ' , $ result , $ namedRange ->getName ());
5411
5412
5412
5413
return $ result ;
0 commit comments