Skip to content

Commit c2b5cb3

Browse files
committed
ArrayEnabled and Database Functions
1 parent 6cec624 commit c2b5cb3

File tree

15 files changed

+93
-29
lines changed

15 files changed

+93
-29
lines changed

src/PhpSpreadsheet/Calculation/ArrayEnabled.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ trait ArrayEnabled
1212
private static ArrayArgumentHelper $arrayArgumentHelper;
1313

1414
/**
15-
* @param array|false $arguments Can be changed to array for Php8.1+
15+
* @param mixed[] $arguments
1616
*/
17-
private static function initialiseHelper($arguments): void
17+
private static function initialiseHelper(array $arguments): void
1818
{
1919
if (self::$initializationNeeded === true) {
2020
self::$arrayArgumentHelper = new ArrayArgumentHelper();
2121
self::$initializationNeeded = false;
2222
}
23-
self::$arrayArgumentHelper->initialise(($arguments === false) ? [] : $arguments);
23+
self::$arrayArgumentHelper->initialise($arguments);
2424
}
2525

2626
/**
2727
* Handles array argument processing when the function accepts a single argument that can be an array argument.
2828
* Example use for:
2929
* DAYOFMONTH() or FACT().
30+
*
31+
* @param mixed[] $values
32+
*
33+
* @return mixed[]
3034
*/
3135
protected static function evaluateSingleArgumentArray(callable $method, array $values): array
3236
{
@@ -43,6 +47,8 @@ protected static function evaluateSingleArgumentArray(callable $method, array $v
4347
* and any of them can be an array argument.
4448
* Example use for:
4549
* ROUND() or DATE().
50+
*
51+
* @return mixed[]
4652
*/
4753
protected static function evaluateArrayArguments(callable $method, mixed ...$arguments): array
4854
{
@@ -58,6 +64,8 @@ protected static function evaluateArrayArguments(callable $method, mixed ...$arg
5864
* Example use for:
5965
* NETWORKDAYS() or CONCATENATE(), where the last argument is a matrix (or a series of values) that need
6066
* to be treated as a such rather than as an array arguments.
67+
*
68+
* @return mixed[]
6169
*/
6270
protected static function evaluateArrayArgumentsSubset(callable $method, int $limit, mixed ...$arguments): array
6371
{
@@ -80,6 +88,8 @@ private static function testFalse(mixed $value): bool
8088
* Example use for:
8189
* Z.TEST() or INDEX(), where the first argument 1 is a matrix that needs to be treated as a dataset
8290
* rather than as an array argument.
91+
*
92+
* @return mixed[]
8393
*/
8494
protected static function evaluateArrayArgumentsSubsetFrom(callable $method, int $start, mixed ...$arguments): array
8595
{
@@ -105,6 +115,8 @@ protected static function evaluateArrayArgumentsSubsetFrom(callable $method, int
105115
* Example use for:
106116
* HLOOKUP() and VLOOKUP(), where argument 1 is a matrix that needs to be treated as a database
107117
* rather than as an array argument.
118+
*
119+
* @return mixed[]
108120
*/
109121
protected static function evaluateArrayArgumentsIgnore(callable $method, int $ignore, mixed ...$arguments): array
110122
{

src/PhpSpreadsheet/Calculation/CalculationLocale.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CalculationLocale extends CalculationBase
3333
*/
3434
protected static string $localeArgumentSeparator = ',';
3535

36+
/** @var string[] */
3637
protected static array $localeFunctions = [];
3738

3839
/**
@@ -271,6 +272,10 @@ public static function translateSeparator(
271272
return $formula;
272273
}
273274

275+
/**
276+
* @param string[] $from
277+
* @param string[] $to
278+
*/
274279
protected static function translateFormulaBlock(
275280
array $from,
276281
array $to,
@@ -295,6 +300,10 @@ protected static function translateFormulaBlock(
295300
return $formula;
296301
}
297302

303+
/**
304+
* @param string[] $from
305+
* @param string[] $to
306+
*/
298307
protected static function translateFormula(array $from, array $to, string $formula, string $fromSeparator, string $toSeparator): string
299308
{
300309
// Convert any Excel function names and constant names to the required language;
@@ -327,8 +336,10 @@ protected static function translateFormula(array $from, array $to, string $formu
327336
return $formula;
328337
}
329338

339+
/** @var null|string[] */
330340
private static ?array $functionReplaceFromExcel;
331341

342+
/** @var null|string[] */
332343
private static ?array $functionReplaceToLocale;
333344

334345
public function translateFormulaToLocale(string $formula): string
@@ -364,8 +375,10 @@ public function translateFormulaToLocale(string $formula): string
364375
);
365376
}
366377

378+
/** @var null|string[] */
367379
protected static ?array $functionReplaceFromLocale;
368380

381+
/** @var null|string[] */
369382
protected static ?array $functionReplaceToExcel;
370383

371384
public function translateFormulaToEnglish(string $formula): string

src/PhpSpreadsheet/Calculation/Database/DAverage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class DAverage extends DatabaseAbstract
1919
* A database is a list of related data in which rows of related
2020
* information are records, and columns of data are fields. The
2121
* first row of the list contains labels for each column.
22-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
22+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2323
* column label enclosed between double quotation marks, such as
2424
* "Age" or "Yield," or a number (without quotation marks) that
2525
* represents the position of the column within the list: 1 for
2626
* the first column, 2 for the second column, and so on.
27-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
27+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2828
* You can use any range for the criteria argument, as long as it
2929
* includes at least one column label and at least one cell below
3030
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DCount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class DCount extends DatabaseAbstract
2020
* A database is a list of related data in which rows of related
2121
* information are records, and columns of data are fields. The
2222
* first row of the list contains labels for each column.
23-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
23+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2424
* column label enclosed between double quotation marks, such as
2525
* "Age" or "Yield," or a number (without quotation marks) that
2626
* represents the position of the column within the list: 1 for
2727
* the first column, 2 for the second column, and so on.
28-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
28+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2929
* You can use any range for the criteria argument, as long as it
3030
* includes at least one column label and at least one cell below
3131
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DCountA.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class DCountA extends DatabaseAbstract
1919
* A database is a list of related data in which rows of related
2020
* information are records, and columns of data are fields. The
2121
* first row of the list contains labels for each column.
22-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
22+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2323
* column label enclosed between double quotation marks, such as
2424
* "Age" or "Yield," or a number (without quotation marks) that
2525
* represents the position of the column within the list: 1 for
2626
* the first column, 2 for the second column, and so on.
27-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
27+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2828
* You can use any range for the criteria argument, as long as it
2929
* includes at least one column label and at least one cell below
3030
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DGet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class DGet extends DatabaseAbstract
1919
* A database is a list of related data in which rows of related
2020
* information are records, and columns of data are fields. The
2121
* first row of the list contains labels for each column.
22-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
22+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2323
* column label enclosed between double quotation marks, such as
2424
* "Age" or "Yield," or a number (without quotation marks) that
2525
* represents the position of the column within the list: 1 for
2626
* the first column, 2 for the second column, and so on.
27-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
27+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2828
* You can use any range for the criteria argument, as long as it
2929
* includes at least one column label and at least one cell below
3030
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DMax.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class DMax extends DatabaseAbstract
2020
* A database is a list of related data in which rows of related
2121
* information are records, and columns of data are fields. The
2222
* first row of the list contains labels for each column.
23-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
23+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2424
* column label enclosed between double quotation marks, such as
2525
* "Age" or "Yield," or a number (without quotation marks) that
2626
* represents the position of the column within the list: 1 for
2727
* the first column, 2 for the second column, and so on.
28-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
28+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2929
* You can use any range for the criteria argument, as long as it
3030
* includes at least one column label and at least one cell below
3131
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DMin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class DMin extends DatabaseAbstract
2020
* A database is a list of related data in which rows of related
2121
* information are records, and columns of data are fields. The
2222
* first row of the list contains labels for each column.
23-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
23+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2424
* column label enclosed between double quotation marks, such as
2525
* "Age" or "Yield," or a number (without quotation marks) that
2626
* represents the position of the column within the list: 1 for
2727
* the first column, 2 for the second column, and so on.
28-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
28+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2929
* You can use any range for the criteria argument, as long as it
3030
* includes at least one column label and at least one cell below
3131
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DProduct.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class DProduct extends DatabaseAbstract
1919
* A database is a list of related data in which rows of related
2020
* information are records, and columns of data are fields. The
2121
* first row of the list contains labels for each column.
22-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
22+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2323
* column label enclosed between double quotation marks, such as
2424
* "Age" or "Yield," or a number (without quotation marks) that
2525
* represents the position of the column within the list: 1 for
2626
* the first column, 2 for the second column, and so on.
27-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
27+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2828
* You can use any range for the criteria argument, as long as it
2929
* includes at least one column label and at least one cell below
3030
* the column label in which you specify a condition for the

src/PhpSpreadsheet/Calculation/Database/DStDev.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class DStDev extends DatabaseAbstract
2020
* A database is a list of related data in which rows of related
2121
* information are records, and columns of data are fields. The
2222
* first row of the list contains labels for each column.
23-
* @param null|array|int|string $field Indicates which column is used in the function. Enter the
23+
* @param null|array<mixed>|int|string $field Indicates which column is used in the function. Enter the
2424
* column label enclosed between double quotation marks, such as
2525
* "Age" or "Yield," or a number (without quotation marks) that
2626
* represents the position of the column within the list: 1 for
2727
* the first column, 2 for the second column, and so on.
28-
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
28+
* @param mixed[][] $criteria The range of cells that contains the conditions you specify.
2929
* You can use any range for the criteria argument, as long as it
3030
* includes at least one column label and at least one cell below
3131
* the column label in which you specify a condition for the

0 commit comments

Comments
 (0)