diff --git a/docs/topics/accessing-cells.md b/docs/topics/accessing-cells.md index 9d3fb1cbdd..b9149fde56 100644 --- a/docs/topics/accessing-cells.md +++ b/docs/topics/accessing-cells.md @@ -131,10 +131,10 @@ Formats handled by the advanced value binder include: - TRUE or FALSE (dependent on locale settings) are converted to booleans. - Numeric strings identified as scientific (exponential) format are converted to numbers. -- Fractions and vulgar fractions are converted to numbers, and +- Fractions and "vulgar" fractions are converted to numbers, and an appropriate number format mask applied. -- Percentages are converted - to numbers, divided by 100, and an appropriate number format mask +- Percentages are converted to numbers, divided by 100, and an + appropriate number format mask applied. - Dates and times are converted to Excel timestamp values (numbers), and an appropriate number format mask applied. diff --git a/docs/topics/calculation-engine.md b/docs/topics/calculation-engine.md index 7dc838f742..7a8a6b1443 100644 --- a/docs/topics/calculation-engine.md +++ b/docs/topics/calculation-engine.md @@ -10,6 +10,8 @@ formula calculation capabilities. A cell can be of a value type which can be evaluated). For example, the formula `=SUM(A1:A10)` evaluates to the sum of values in A1, A2, ..., A10. +Calling `getValue()` on a cell that contains a formula will return the formula itself. + To calculate a formula, you can call the cell containing the formula’s method `getCalculatedValue()`, for example: @@ -22,6 +24,30 @@ with PhpSpreadsheet, it evaluates to the value "64": ![09-command-line-calculation.png](./images/09-command-line-calculation.png) +Calling `getCalculatedValue()` on a cell that doesn't contain a formula will simply return the value of that cell; but if the cell does contain a formula, then PhpSpreadsheet will evaluate that formula to calculate the result. + +There are a few useful mehods to help identify whether a cell contains a formula or a simple value; and if a formula, to provide further information about it: + +```php +$spreadsheet->getActiveSheet()->getCell('E11')->isFormula(); +``` +will return a boolean true/false, telling you whether that cell contains a formula or not, so you can determine if a call to `getCalculatedVaue()` will need to perform an evaluation. + +A formula can be either a simple formula, or an array formula; and another method will identify which it is: +```php +$spreadsheet->getActiveSheet()->getCell('E11')->isArrayFormula(); +``` +Finally, an array formula might result in a single cell result, or a result that can spill over into a range of cells; so for array formulae the following method also exists: +```php +$spreadsheet->getActiveSheet()->getCell('E11')->arrayFormulaRange(); +``` +which returns a string containing a cell reference (e.g. `E11`) or a cell range reference (e.g. `E11:G13`). + + +For more details on working with array formulae, see the [the recipes documentationn](./recipes.md/#array-formulae). + +### Adjustments to formulae when Inserting/Deleting Columns/Rows + When writing a formula to a cell, formulae should always be set as they would appear in an English version of Microsoft Office Excel, and PhpSpreadsheet handles all formulae internally in this format. This means that the following rules hold: - Decimal separator is `.` (period) @@ -91,6 +117,11 @@ formula calculation is subject to PHP's language characteristics. Not all functions are supported, for a comprehensive list, read the [function list by name](../references/function-list-by-name.md). +#### Array arguments for Function Calls in Formulae + +While most of the Excel function implementations now support array arguments, there are a few that should accept arrays as arguments but don't do so. +In these cases, the result may be a single value rather than an array; or it may be a `#VALUE!` error. + #### Operator precedence In Excel `+` wins over `&`, just like `*` wins over `+` in ordinary @@ -112,7 +143,7 @@ content. - [Reference for this behaviour in PHP](https://php.net/manual/en/language.types.string.php#language.types.string.conversion) -#### Formulas don’t seem to be calculated in Excel2003 using compatibility pack? +#### Formulae don’t seem to be calculated in Excel2003 using compatibility pack? This is normal behaviour of the compatibility pack, Xlsx displays this correctly. Use `\PhpOffice\PhpSpreadsheet\Writer\Xls` if you really need @@ -161,8 +192,7 @@ number of seconds from the PHP/Unix base date. The PHP/Unix base date (0) is 00:00 UST on 1st January 1970. This value can be positive or negative: so a value of -3600 would be 23:00 hrs on 31st December 1969; while a value of +3600 would be 01:00 hrs on 1st January 1970. This -gives PHP a date range of between 14th December 1901 and 19th January -2038. +gives 32-bit PHP a date range of between 14th December 1901 and 19th January 2038. #### PHP `DateTime` Objects diff --git a/docs/topics/images/12-CalculationEngine-Array-Formula-2.png b/docs/topics/images/12-CalculationEngine-Array-Formula-2.png new file mode 100644 index 0000000000..45fc3ce5e8 Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Array-Formula-2.png differ diff --git a/docs/topics/images/12-CalculationEngine-Array-Formula-3.png b/docs/topics/images/12-CalculationEngine-Array-Formula-3.png new file mode 100644 index 0000000000..2f01e9d2ae Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Array-Formula-3.png differ diff --git a/docs/topics/images/12-CalculationEngine-Array-Formula.png b/docs/topics/images/12-CalculationEngine-Array-Formula.png new file mode 100644 index 0000000000..77987b2707 Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Array-Formula.png differ diff --git a/docs/topics/images/12-CalculationEngine-Basic-Formula-2.png b/docs/topics/images/12-CalculationEngine-Basic-Formula-2.png new file mode 100644 index 0000000000..465f27a278 Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Basic-Formula-2.png differ diff --git a/docs/topics/images/12-CalculationEngine-Basic-Formula.png b/docs/topics/images/12-CalculationEngine-Basic-Formula.png new file mode 100644 index 0000000000..03cd82a686 Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Basic-Formula.png differ diff --git a/docs/topics/images/12-CalculationEngine-Spillage-Formula-2.png b/docs/topics/images/12-CalculationEngine-Spillage-Formula-2.png new file mode 100644 index 0000000000..8fc397d1d6 Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Spillage-Formula-2.png differ diff --git a/docs/topics/images/12-CalculationEngine-Spillage-Formula.png b/docs/topics/images/12-CalculationEngine-Spillage-Formula.png new file mode 100644 index 0000000000..4189cb47fa Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Spillage-Formula.png differ diff --git a/docs/topics/images/12-CalculationEngine-Spillage-Operator.png b/docs/topics/images/12-CalculationEngine-Spillage-Operator.png new file mode 100644 index 0000000000..c096875e94 Binary files /dev/null and b/docs/topics/images/12-CalculationEngine-Spillage-Operator.png differ diff --git a/docs/topics/reading-files.md b/docs/topics/reading-files.md index 767052812c..129ca43a3e 100644 --- a/docs/topics/reading-files.md +++ b/docs/topics/reading-files.md @@ -168,6 +168,68 @@ Once you have created a reader object for the workbook that you want to load, you have the opportunity to set additional options before executing the `load()` method. +All of these options can be set by calling the appropriate methods against the Reader (as described below), but some options (those with only two possible values) can also be set through flags, either by calling the Reader's `setFlags()` method, or passing the flags as an argument in the call to `load()`. +Those options that can be set through flags are: + +Option | Flag | Default +-------------------|------------------------------|--- +Ignore Empty Cells | IReader::IGNORE_EMPTY_CELLS | Load empty cells +Read Data Only | IReader::READ_DATA_ONLY | Read data, structure and style +Include Charts | IReader::LOAD_WITH_CHARTS | Don't read charts + +Several flags can be combined in a single call: +```php +$inputFileType = 'Xlsx'; +$inputFileName = './sampleData/example1.xlsx'; + +/** Create a new Reader of the type defined in $inputFileType **/ +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +/** Set additional flags before the call to load() */ +$reader->setFlags(IReader::IGNORE_EMPTY_CELLS | IReader::LOAD_WITH_CHARTS); +$reader->load($inputFileName); +``` +or +```php +$inputFileType = 'Xlsx'; +$inputFileName = './sampleData/example1.xlsx'; + +/** Create a new Reader of the type defined in $inputFileType **/ +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +/** Set additional flags in the call to load() */ +$reader->load($inputFileName, IReader::IGNORE_EMPTY_CELLS | IReader::LOAD_WITH_CHARTS); +``` + +### Ignoring Empty Cells + +Many Excel files have empty rows or columns at the end of a worksheet, which can't easily be seen when looking at the file in Excel (Try using Ctrl-End to see the last cell in a worksheet). +By default, PhpSpreadsheet will load these cells, because they are valid Excel values; but you may find that an apparently small spreadsheet requires a lot of memory for all those empty cells. +If you are running into memory issues with seemingly small files, you can tell PhpSpreadsheet not to load those empty cells using the `setReadEmptyCells()` method. + +```php +$inputFileType = 'Xls'; +$inputFileName = './sampleData/example1.xls'; + +/** Create a new Reader of the type defined in $inputFileType **/ +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +/** Advise the Reader that we only want to load cell's that contain actual content **/ +$reader->setReadEmptyCells(false); +/** Load $inputFileName to a Spreadsheet Object **/ +$spreadsheet = $reader->load($inputFileName); +``` + +Note that cells containing formulae will still be loaded, even if that formula evaluates to a NULL or an empty string. +Similarly, Conditional Styling might also hide the value of a cell; but cells that contain Conditional Styling or Data Validation will always be loaded regardless of their value. + +This option is available for the following formats: + +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | YES | Xls | YES | Xml | NO | +Ods | NO | SYLK | NO | Gnumeric | NO | +CSV | NO | HTML | NO + +This option is also available through flags. + ### Reading Only Data from a Spreadsheet File If you're only interested in the cell values in a workbook, but don't @@ -210,6 +272,8 @@ Xlsx | YES | Xls | YES | Xml | YES | Ods | YES | SYLK | NO | Gnumeric | YES | CSV | NO | HTML | NO +This option is also available through flags. + ### Reading Only Named WorkSheets from a File If your workbook contains a number of worksheets, but you are only @@ -642,7 +706,7 @@ Xlsx | NO | Xls | NO | Xml | NO | Ods | NO | SYLK | NO | Gnumeric | NO | CSV | YES | HTML | NO -### A Brief Word about the Advanced Value Binder +## A Brief Word about the Advanced Value Binder When loading data from a file that contains no formatting information, such as a CSV file, then data is read either as strings or numbers @@ -694,6 +758,9 @@ Xlsx | NO | Xls | NO | Xml | NO Ods | NO | SYLK | NO | Gnumeric | NO CSV | YES | HTML | YES +Note that you can also use the Binder to determine how PhpSpreadsheet identified datatypes for values when you set a cell value without explicitly setting a datatype. +Value Binders can also be used to set formatting for a cell appropriate to the value. + ## Error Handling Of course, you should always apply some error handling to your scripts diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index 04a4e6aad9..57525a8c32 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -165,6 +165,168 @@ is further explained in [the calculation engine](./calculation-engine.md). $value = $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue(); ``` +### Array Formulae + +With version 2.0.0 of PhpSpreadsheet, we've introduced support for Excel "array formulae". + +As a basic example, let's look at a receipt for buying some fruit: + +![12-CalculationEngine-Basic-Formula.png](./images/12-CalculationEngine-Basic-Formula.png) + +We can provide a "Cost" formula for each row of the receipt by multiplying the "Quantity" (column `B`) by the "Price" (column `C`); so for the "Apples" in row `2` we enter the formula `=$B2*$C2`. In PhpSpreadsheet, we would set this formula in cell `D2` using: +```php +$spreadsheet->getActiveSheet()->setCellValue('D2','=$B2*$C2'); +``` +and then do the equivalent for rows `3` to `6`. + +To calculate the "Total", we would use a different formula, telling it to calculate the sum value of rows 2 to 6 in the "Cost" column: + +![12-CalculationEngine-Basic-Formula-2.png](./images/12-CalculationEngine-Basic-Formula-2.png) + +I'd imagine that most developers are familiar with this: we're setting a formula that uses an Excel function (the `SUM()` function) and specifying a range of cells to include in the sum (`$D$2:$D6`) +```php +$spreadsheet->getActiveSheet()->setCellValue('D7','=SUM($D$2:$D6'); +``` +However, we could have specified an alternative formula to calculate that result, using the arrays of the "Quantity" and "Cost" columns multiplied directly, and then summed together: + +![12-CalculationEngine-Array-Formula.png](./images/12-CalculationEngine-Array-Formula.png) + +Entering the formula `=SUM(B2:B6*C2:C6)` will calculate the same result; but because it's using arrays, we need to enter it as an "array formula". In MS Excel itself, we'd do this by using `Shift-Ctrl-Enter` rather than simply `Enter` when we define the formula in the formula edit box. MS Excel then shows that this is an array formula in the formula edit box by wrapping it in the `{}` braces (you don't enter these in the formula yourself; MS Excel does it). + +If we want to create an array formula in PhpSpreadsheet, we also have to indicate that it is an array formula. +```php +$spreadsheet->getActiveSheet()->setCellValue('D7','=SUM(B2:B6*C2:C6)', true); +``` +We do this by providing a third argument in the call to `setCellValue()` that is only appropriate when setting a cell value to a formula, and that is the boolean value `true` passed as the `$isArrayFormula` argument. If the value we're setting in the cell isn't a formula value, then this additional argument will be ignored. + +Or to identify the biggest increase in like-for-like sales from one month to the next: + +![12-CalculationEngine-Array-Formula-3.png](./images/12-CalculationEngine-Array-Formula-3.png) +```php +$spreadsheet->getActiveSheet()->setCellValue('F1','=MAX(B2:B6-C2:C6)', true); +``` +Which tells us that the biggest increase in sales between December and January was 30 more (in this case, 30 more Lemons). + +--- + +These are examples of array formula where the results are displayed in a single cell; but other array formulae might be displayed across several cells. +As an example, consider transposing a grid of data: MS Excel provides the `TRANSPOSE()` function for that purpose. Let's transpose our shopping list for the fruit: + +![12-CalculationEngine-Array-Formula-2.png](./images/12-CalculationEngine-Array-Formula-2.png) + +When we do this in MS Excel, we need to indicate ___all___ the cells that will contain the transposed data from cells `A1` to `D7`. We do this by selecting the cells where we want to display our transposed data either by holding the left mouse button down while we move with the mouse, or pressing `Shift` and using the arrow keys. +Once we've selected all the cells to hold our data, then we enter the formula `TRANSPOSE(A1:D7)` in the formula edit box, remembering to use `Shift-Ctrl-Enter` to tell MS Excel that this is an array formula. + +We also need to specify that selected range if we create the same array formula in PhpSpreadsheet. +In addition to passing true for the `$isArrayFormula` argument, we also pass a fourth argument telling PhpSpreadsheet the range of cells that we want the transposed array to cover. +```php +$spreadsheet->getActiveSheet()->setCellValue('A10','=TRANSPOSE(A1:D7)', true, 'A10:G13'); +``` +Specifying this range tells PhpSpreadsheet (and MS Excel) that the result of the formula in cell `A10` is allowed to "spill" out into cells in that specified range; but also that it is limited to that range. +If you don't specify a range, then PhpSpreadsheet will only apply this formula to a single cell. + +Note also that we still set this as the formula for the top-left cell of that range, cell `A10`. + +If you want to use other methods like `setCellValueExplicit()`, `setCellValueByColumnAndRow()` or `setCellValueExplicitByColumnAndRow()`, then the same additional arguments are also available with these methods. +```php +$spreadsheet->getActiveSheet() + ->setCellValueExplicit( + 'A10', + '=TRANSPOSE(A1:D7)', + \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA, + true, + 'A10:G13' + ); +``` + +Simply setting an array formula in a cell and specifying the range won't populate the spillage area for that formula. +```php +$spreadsheet->getActiveSheet() + ->setCellValue( + 'A10', + '=SEQUENCE(3,3)', + true, + 'A1:C3' + ); + +// Will return a null, because the formula for A1 hasn't been calculated to populate the spillage area +$result = $spreadsheet->getActiveSheet()->getCell('C3')->getValue(); +``` +To do that, we need to retrieve the calculated value for the cell. +```php +$spreadsheet->getActiveSheet() + ->setCellValue( + 'A10', + '=SEQUENCE(3,3)', + true, + 'A1:C3' + ); + +$spreadsheet->getActiveSheet()->getCell('A1')->getCalculatedValue(); + +// Will return 9, because the formula for A1 has now been calculated, and the spillage area is populated +$result = $spreadsheet->getActiveSheet()->getCell('C3')->getValue(); +``` +When we call `getCalculatedValue()` for a cell that contains an array formula, PhpSpreadsheet returns the single value that would appear in that cell in MS Excel. +```php +// Will return integer 1, the value for that cell within the array +$a1result = $spreadsheet->getActiveSheet()->getCell('A1')->getCalculatedValue(); +``` + +If we want to return the full array, then we need to call `getCalculatedValue()` with an additional argument, a boolean `true` to return the value as an array. +```php +// Will return an array [[1, 2, 3], [4, 5, 6], [7, 8, 9]] +$a1result = $spreadsheet->getActiveSheet()->getCell('A1')->getCalculatedValue(true); +``` + +--- + +Excel365 introduced a number of new functions that return arrays of results. +These include the `UNIQUE()`, `SORT()`, `SORTBY()`, `FILTER()`, `SEQUENCE()` and `RANDARRAY()` functions. +While not all of these have been implemented by the Calculation Engine in PhpSpreadsheet, so they cannot all be calculated within your PHP applications, they can still be read from and written to Xlsx files. + +The way these functions are presented in MS Excel itself is slightly different to that of other array functions. + +The `SEQUENCE()` function generates a series of values (in this case, starting with `-10` and increasing in steps of `2.5`); and here we're telling the formula to populate a 3x3 grid with these values. + +![12-CalculationEngine-Spillage-Formula.png](./images/12-CalculationEngine-Spillage-Formula.png) + +Note that this is visually different to the multi-cell array formulae like `TRANSPOSE()`. When we are positioned in the "spill" range for the grid, MS Excel highlights the area with a blue border; and the formula displayed in the formula editing field isn't wrapped in braces (`{}`). + +And if we select any other cell inside the "spill" area other than the top-left cell, the formula in the formula edit field is greyed rather than displayed in black. + +![12-CalculationEngine-Spillage-Formula-2.png](./images/12-CalculationEngine-Spillage-Formula-2.png) + +When we enter this formula in MS Excel, we don't need to select the range of cells that it should occupy; nor do we need to enter it using `Ctrl-Shift-Enter`. MS Excel identifies that it is a multi-cell array formula because of the function that it uses, the `SEQUENCE()` function (and if there are nested function calls in the formula, then it must be the outermost functionin the tree). + +However, PhpSpreadsheet isn't quite as intelligent (yet) and doesn't parse the formula to identify if it should be treated as an array formula or not; a formula is just a string of characters until it is actually evaluated. If we want to use this function through code, we still need to specify that it is an "array" function with the `$isArrayFormula` argument, and the range of cells that it should cover. + +```php +$spreadsheet->getActiveSheet()->setCellValue('A1','=SEQUENCE(3,3,-10,2.5)', true, 'A1:C3'); +``` + +### The Spill Operator + +If you want to reference the entire spillage range of an array formula within another formula, you could do so using the standard Excel range operator (`:`, e.g. `A1:C3`); but you may not always know the range, especially for array functions that spill across as many cells as they need, like `UNIQUE()` and `FILTER()`. +To simplify this, MS Excel has introduced the "Spill" Operator (`#`). + +![12-CalculationEngine-Spillage-Operator.png](./images/12-CalculationEngine-Spillage-Operator.png) + +Using our `SEQUENCE()"`example, where the formula cell is `A1` and the result spills across the range `A1:C3`, we can use the Spill operator `A1#` to reference all the cells in that spillage range. +In this case, we're taking the absolute value of each cell in that range, and adding them together using the `SUM()` function to give us a result of 50. + +PhpSpreadsheet doesn't currently support entry of a formula like this directly; but interally MS Excel implements the Spill Operator as a function (`ANCHORARRAY()`). MS Excel itself doesn't allow you to use this function in a formula, you have to use the "Spill" operator; but PhpSpreadsheet does allow you to use this internal Excel function. + +To create this same function in PhpSpreadsheet, use: +```php +$spreadsheet->getActiveSheet()->setCellValue('D1','=SUM(ABS(ANCHORARRAY(A1)))', true); +``` +Note that this does need to be flagged as an array function with the `$isArrayFormula` argument. + +When the file is saved, and opened in MS Excel, it will be rendered correctly. + + + ## Locale Settings for Formulae Some localisation elements have been included in PhpSpreadsheet. You can @@ -187,7 +349,7 @@ internal English coding. ```php $formula = $spreadsheet->getActiveSheet()->getCell('B8')->getValue(); -$translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->_translateFormulaToLocale($formula); +$translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->translateFormulaToLocale($formula); ``` You can also create a formula using the function names and argument @@ -201,7 +363,7 @@ $spreadsheet->getActiveSheet()->setCellValue('B8',$internalFormula); ``` Currently, formula translation only translates the function names, the -constants TRUE and FALSE, and the function argument separators. Cell addressing using R1C1 formatting is not supported. +constants TRUE and FALSE (and NULL), Excel error messages, and the function argument separators. Cell addressing using R1C1 formatting is not supported. At present, the following locale settings are supported: @@ -224,6 +386,8 @@ Russian | русский язык | ru Swedish | Svenska | sv Turkish | Türkçe | tr +If anybody can provide translations for additional languages, particularly Basque (Euskara), Catalan (Català), Croatian (Hrvatski jezik), Galician (Galego), Greek (Ελληνικά), Slovak (Slovenčina) or Slovenian (Slovenščina); please feel free to volunteer your services, and we'll happily show you what is needed to contribute a new language. + ## Write a newline character "\n" in a cell (ALT+"Enter") In Microsoft Office Excel you get a line break in a cell by hitting diff --git a/infra/DocumentGenerator.php b/infra/DocumentGenerator.php index 8a6be076c0..6704a687d9 100644 --- a/infra/DocumentGenerator.php +++ b/infra/DocumentGenerator.php @@ -16,6 +16,9 @@ public static function generateFunctionListByCategory(array $phpSpreadsheetFunct { $result = "# Function list by category\n"; foreach (self::getCategories() as $categoryConstant => $category) { + if ($category === Category::CATEGORY_MICROSOFT_INTERNAL_PSEUDOFUNCTION) { + continue; + } $result .= "\n"; $result .= "## {$categoryConstant}\n"; $result .= "\n"; @@ -57,7 +60,7 @@ private static function getPhpSpreadsheetFunctionText($functionCall): string if (is_string($functionCall)) { return $functionCall; } - if ($functionCall === [Functions::class, 'DUMMY']) { + if ($functionCall === [Functions::class, 'dummy']) { return '**Not yet Implemented**'; } if (is_array($functionCall)) { @@ -78,6 +81,9 @@ public static function generateFunctionListByName(array $phpSpreadsheetFunctions $result = "# Function list by name\n"; $lastAlphabet = null; foreach ($phpSpreadsheetFunctions as $excelFunction => $functionInfo) { + if ($functionInfo['category'] === Category::CATEGORY_MICROSOFT_INTERNAL_PSEUDOFUNCTION) { + continue; + } /** @var string $excelFunction */ $lengths = [25, 31, 37]; if ($lastAlphabet !== $excelFunction[0]) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c4b76cdd7c..f01a6ad4b3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -31,23 +31,8 @@ parameters: path: src/PhpSpreadsheet/Calculation/Calculation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToEnglish\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToEnglish\\(\\) has parameter \\$formula with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToLocale\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToLocale\\(\\) has parameter \\$formula with no type specified\\.$#" - count: 1 + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 6 path: src/PhpSpreadsheet/Calculation/Calculation.php - @@ -60,41 +45,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Calculation.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:getTokensAsString\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:getTokensAsString\\(\\) has parameter \\$tokens with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:localeFunc\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:localeFunc\\(\\) has parameter \\$function with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:validateBinaryOperand\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:validateBinaryOperand\\(\\) has parameter \\$operand with no type specified\\.$#" count: 1 path: src/PhpSpreadsheet/Calculation/Calculation.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:validateBinaryOperand\\(\\) has parameter \\$stack with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Calculation.php - - message: "#^Offset 'value' does not exist on array\\|null\\.$#" count: 5 @@ -190,6 +145,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Calculation.php + - + message: "#^Result of && is always false\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/Calculation.php + - message: "#^Static property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:\\$instance \\(PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\) in isset\\(\\) is not nullable\\.$#" count: 1 @@ -206,49 +166,9 @@ parameters: path: src/PhpSpreadsheet/Calculation/Calculation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DMAX\\(\\) should return float but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DMIN\\(\\) should return float but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DPRODUCT\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DSTDEV\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DSTDEVP\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DSUM\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DVAR\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\:\\:DVARP\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php - - - - message: "#^Parameter \\#2 \\$field of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\\\DCountA\\:\\:evaluate\\(\\) expects int\\|string, int\\|string\\|null given\\.$#" + message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Database.php + path: src/PhpSpreadsheet/Calculation/Calculation.php - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Database\\\\DatabaseAbstract\\:\\:buildCondition\\(\\) has parameter \\$criterion with no type specified\\.$#" @@ -350,21 +270,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\:\\:ISPMT\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\:\\:ISPMT\\(\\) has parameter \\$args with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\:\\:NPV\\(\\) has parameter \\$args with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial.php - - message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:isLeapYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#" count: 1 @@ -565,6 +470,21 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Functions.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/Information/Value.php + + - + message: "#^Cannot call method getCell\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#" + count: 2 + path: src/PhpSpreadsheet/Calculation/Internal/ExcelArrayPseudoFunctions.php + + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 2 + path: src/PhpSpreadsheet/Calculation/Internal/ExcelArrayPseudoFunctions.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Internal\\\\MakeMatrix\\:\\:make\\(\\) has parameter \\$args with no type specified\\.$#" count: 1 @@ -580,16 +500,6 @@ parameters: count: 3 path: src/PhpSpreadsheet/Calculation/Logical/Operations.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\:\\:CHOOSE\\(\\) has parameter \\$chooseArgs with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/LookupRef.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\:\\:OFFSET\\(\\) should return array\\|string but returns array\\|int\\|string\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/LookupRef.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\Address\\:\\:sheetName\\(\\) has no return type specified\\.$#" count: 1 @@ -675,6 +585,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/LookupRef/Helpers.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\Lookup\\:\\:verifyResultVector\\(\\) has no return type specified\\.$#" count: 1 @@ -695,6 +610,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\Offset\\:\\:adjustEndCellColumnForWidth\\(\\) has no return type specified\\.$#" count: 1 @@ -735,6 +655,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 2 + path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php + - message: "#^Binary operation \"/\" between array\\|float\\|int\\|string and array\\|float\\|int\\|string results in an error\\.$#" count: 2 @@ -755,16 +680,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\:\\:MAXIFS\\(\\) should return float but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Statistical.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\:\\:MINIFS\\(\\) should return float but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Statistical.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Averages\\:\\:filterArguments\\(\\) has no return type specified\\.$#" count: 1 @@ -785,11 +700,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/Averages.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Conditional\\:\\:SUMIF\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Statistical/Conditional.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Conditional\\:\\:buildConditionSet\\(\\) has parameter \\$args with no type specified\\.$#" count: 1 @@ -820,6 +730,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/Conditional.php + - + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Conditional\\:\\:sumIf\\(\\) should return float\\|string but returns float\\|string\\|null\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/Statistical/Conditional.php + - message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Distributions\\\\Beta\\:\\:\\$logBetaCacheP has no type specified\\.$#" count: 1 @@ -1006,22 +921,22 @@ parameters: path: src/PhpSpreadsheet/Calculation/Statistical/Permutations.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:GROWTH\\(\\) should return array\\ but returns array\\\\>\\>\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:checkTrendArrays\\(\\) has parameter \\$array1 with no type specified\\.$#" count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:TREND\\(\\) should return array\\ but returns array\\\\>\\>\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:checkTrendArrays\\(\\) has parameter \\$array2 with no type specified\\.$#" count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:checkTrendArrays\\(\\) has parameter \\$array1 with no type specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:growth\\(\\) should return array\\ but returns array\\\\>\\>\\.$#" count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:checkTrendArrays\\(\\) has parameter \\$array2 with no type specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Trends\\:\\:trend\\(\\) should return array\\ but returns array\\\\>\\>\\.$#" count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -1045,11 +960,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/Statistical/VarianceBase.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\TextData\\:\\:CONCATENATE\\(\\) has parameter \\$args with no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/TextData.php - - message: "#^Variable \\$value on left side of \\?\\? always exists and is not nullable\\.$#" count: 4 @@ -1060,34 +970,24 @@ parameters: count: 1 path: src/PhpSpreadsheet/Calculation/TextData/Text.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\:\\:getFormulaAttributes\\(\\) has no return type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Cell/Cell.php - - message: "#^Parameter \\#2 \\$format of static method PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\:\\:toFormattedString\\(\\) expects string, string\\|null given\\.$#" count: 1 path: src/PhpSpreadsheet/Cell/Cell.php - - - message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\:\\:\\$formulaAttributes has no type specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Cell/Cell.php - - message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\:\\:\\$parent \\(PhpOffice\\\\PhpSpreadsheet\\\\Collection\\\\Cells\\) in isset\\(\\) is not nullable\\.$#" count: 6 path: src/PhpSpreadsheet/Cell/Cell.php - - message: "#^Unreachable statement \\- code above always terminates\\.$#" + message: "#^Call to an undefined method object\\:\\:getHashCode\\(\\)\\.$#" count: 1 - path: src/PhpSpreadsheet/Cell/Cell.php + path: src/PhpSpreadsheet/Cell/Coordinate.php - - message: "#^Call to an undefined method object\\:\\:getHashCode\\(\\)\\.$#" - count: 1 + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 3 path: src/PhpSpreadsheet/Cell/Coordinate.php - @@ -1100,6 +1000,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Cell/Coordinate.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + - message: "#^Parameter \\#1 \\$namedRange of method PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet\\:\\:addNamedRange\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\NamedRange, \\$this\\(PhpOffice\\\\PhpSpreadsheet\\\\DefinedName\\) given\\.$#" count: 1 @@ -1295,6 +1200,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Reader/BaseReader.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Reader/Gnumeric.php + - message: "#^Comparison operation \"\\<\" between int and SimpleXMLElement\\|null results in an error\\.$#" count: 2 @@ -1371,14 +1281,9 @@ parameters: path: src/PhpSpreadsheet/Reader/Ods.php - - message: "#^Parameter \\#1 \\$settings of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Ods\\:\\:lookForActiveSheet\\(\\) expects DOMElement, DOMElement\\|null given\\.$#" + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" count: 1 - path: src/PhpSpreadsheet/Reader/Ods.php - - - - message: "#^Parameter \\#1 \\$settings of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Ods\\:\\:lookForSelectedCells\\(\\) expects DOMElement, DOMElement\\|null given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Reader/Ods.php + path: src/PhpSpreadsheet/Reader/Ods/DefinedNames.php - message: "#^Cannot call method getElementsByTagNameNS\\(\\) on DOMElement\\|null\\.$#" @@ -1565,6 +1470,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Reader/Xls.php + - + message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\\\|string given\\.$#" + count: 1 + path: src/PhpSpreadsheet/Reader/Xls.php + - message: "#^Parameter \\#2 \\$row of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\IReadFilter\\:\\:readCell\\(\\) expects int, string given\\.$#" count: 1 @@ -1665,6 +1575,11 @@ parameters: count: 2 path: src/PhpSpreadsheet/Reader/Xlsx.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Reader/Xlsx.php + - message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given\\.$#" count: 1 @@ -2580,6 +2495,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 2 + path: src/PhpSpreadsheet/Worksheet/AutoFilter.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\CellIterator\\:\\:adjustForExistingOnlyRange\\(\\) has no return type specified\\.$#" count: 1 @@ -2610,6 +2530,16 @@ parameters: count: 1 path: src/PhpSpreadsheet/Worksheet/SheetView.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Worksheet/Table.php + + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 2 + path: src/PhpSpreadsheet/Worksheet/Validations.php + - message: "#^Cannot call method getCalculatedValue\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Cell\\|null\\.$#" count: 1 @@ -2650,6 +2580,11 @@ parameters: count: 2 path: src/PhpSpreadsheet/Worksheet/Worksheet.php + - + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:extractSheetTitle\\(\\) should return array\\\\|string but returns array\\\\|null\\.$#" + count: 1 + path: src/PhpSpreadsheet/Worksheet/Worksheet.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:getChartByName\\(\\) should return PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false but returns PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|null\\.$#" count: 1 @@ -2850,6 +2785,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Writer/Xls/Font.php + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 2 + path: src/PhpSpreadsheet/Writer/Xls/Parser.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Parser\\:\\:advance\\(\\) has no return type specified\\.$#" count: 1 @@ -3014,3 +2954,14 @@ parameters: message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Xf\\:\\:\\$diag is never read, only written\\.$#" count: 1 path: src/PhpSpreadsheet/Writer/Xls/Xf.php + + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Writer/Xlsx/DefinedNames.php + + - + message: "#^Cannot use array destructuring on array\\\\|string\\.$#" + count: 1 + path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php + diff --git a/samples/Basic/24_Readfilter.php b/samples/Basic/24_Readfilter.php index e5b613a67e..0f73818f9e 100644 --- a/samples/Basic/24_Readfilter.php +++ b/samples/Basic/24_Readfilter.php @@ -18,7 +18,7 @@ class MyReadFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Read title row and rows 20 - 30 if ($row == 1 || ($row >= 20 && $row <= 30)) { diff --git a/samples/Reader/09_Simple_file_reader_using_a_read_filter.php b/samples/Reader/09_Simple_file_reader_using_a_read_filter.php index 4603164c65..ed394c5926 100644 --- a/samples/Reader/09_Simple_file_reader_using_a_read_filter.php +++ b/samples/Reader/09_Simple_file_reader_using_a_read_filter.php @@ -13,7 +13,7 @@ class MyReadFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Read rows 1 to 7 and columns A to E only if ($row >= 1 && $row <= 7) { diff --git a/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php b/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php index 82ca22349e..dd039a9348 100644 --- a/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php +++ b/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php @@ -26,7 +26,7 @@ public function __construct($startRow, $endRow, $columns) $this->columns = $columns; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { if ($row >= $this->startRow && $row <= $this->endRow) { if (in_array($columnAddress, $this->columns)) { diff --git a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php index cf070054b7..321b228bc8 100644 --- a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php +++ b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php @@ -29,7 +29,7 @@ public function __construct($startRow, $chunkSize) $this->endRow = $startRow + $chunkSize; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that were configured in the constructor if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php index 13692e3aa5..54296fe9d9 100644 --- a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php +++ b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php @@ -29,7 +29,7 @@ public function setRows($startRow, $chunkSize): void $this->endRow = $startRow + $chunkSize; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php index eab7ec01d2..749f98d1fb 100644 --- a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php +++ b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php @@ -29,7 +29,7 @@ public function setRows($startRow, $chunkSize): void $this->endRow = $startRow + $chunkSize; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 4f95af54f2..6f923a1df7 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -19,6 +19,7 @@ use ReflectionClassConstant; use ReflectionMethod; use ReflectionParameter; +use Throwable; class Calculation { @@ -274,32 +275,32 @@ class Calculation ], 'AGGREGATE' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3+', ], 'AMORDEGRC' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Amortization::class, 'AMORDEGRC'], + 'functionCall' => [Financial\Amortization::class, 'withCoefficient'], 'argumentCount' => '6,7', ], 'AMORLINC' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Amortization::class, 'AMORLINC'], + 'functionCall' => [Financial\Amortization::class, 'depreciation'], 'argumentCount' => '6,7', ], 'AND' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Operations::class, 'logicalAnd'], + 'functionCall' => [Logical\Operations::class, 'and'], 'argumentCount' => '1+', ], 'ARABIC' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [MathTrig\Arabic::class, 'evaluate'], + 'functionCall' => [MathTrig\Arabic::class, 'toRoman'], 'argumentCount' => '1', ], 'AREAS' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'ARRAYTOTEXT' => [ @@ -309,7 +310,7 @@ class Calculation ], 'ASC' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'ASIN' => [ @@ -354,17 +355,17 @@ class Calculation ], 'AVERAGEIF' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Conditional::class, 'AVERAGEIF'], + 'functionCall' => [Statistical\Conditional::class, 'averageIf'], 'argumentCount' => '2,3', ], 'AVERAGEIFS' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Conditional::class, 'AVERAGEIFS'], + 'functionCall' => [Statistical\Conditional::class, 'averageIfSeries'], 'argumentCount' => '3+', ], 'BAHTTEXT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'BASE' => [ @@ -374,22 +375,22 @@ class Calculation ], 'BESSELI' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BesselI::class, 'BESSELI'], + 'functionCall' => [Engineering\BesselI::class, 'besselI'], 'argumentCount' => '2', ], 'BESSELJ' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BesselJ::class, 'BESSELJ'], + 'functionCall' => [Engineering\BesselJ::class, 'besselJ'], 'argumentCount' => '2', ], 'BESSELK' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BesselK::class, 'BESSELK'], + 'functionCall' => [Engineering\BesselK::class, 'besselK'], 'argumentCount' => '2', ], 'BESSELY' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BesselY::class, 'BESSELY'], + 'functionCall' => [Engineering\BesselY::class, 'besselY'], 'argumentCount' => '2', ], 'BETADIST' => [ @@ -399,7 +400,7 @@ class Calculation ], 'BETA.DIST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '4-6', ], 'BETAINV' => [ @@ -449,27 +450,27 @@ class Calculation ], 'BITAND' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BitWise::class, 'BITAND'], + 'functionCall' => [Engineering\BitWise::class, 'and'], 'argumentCount' => '2', ], 'BITOR' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BitWise::class, 'BITOR'], + 'functionCall' => [Engineering\BitWise::class, 'or'], 'argumentCount' => '2', ], 'BITXOR' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BitWise::class, 'BITXOR'], + 'functionCall' => [Engineering\BitWise::class, 'xor'], 'argumentCount' => '2', ], 'BITLSHIFT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BitWise::class, 'BITLSHIFT'], + 'functionCall' => [Engineering\BitWise::class, 'leftShift'], 'argumentCount' => '2', ], 'BITRSHIFT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\BitWise::class, 'BITRSHIFT'], + 'functionCall' => [Engineering\BitWise::class, 'rightShift'], 'argumentCount' => '2', ], 'CEILING' => [ @@ -489,7 +490,7 @@ class Calculation ], 'CELL' => [ 'category' => Category::CATEGORY_INFORMATION, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1,2', ], 'CHAR' => [ @@ -539,17 +540,17 @@ class Calculation ], 'CHOOSE' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\Selection::class, 'CHOOSE'], + 'functionCall' => [LookupRef\Selection::class, 'choose'], 'argumentCount' => '2+', ], 'CHOOSECOLS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2+', ], 'CHOOSEROWS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2+', ], 'CLEAN' => [ @@ -564,14 +565,14 @@ class Calculation ], 'COLUMN' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\RowColumnInformation::class, 'COLUMN'], + 'functionCall' => [LookupRef\RowColumnInformation::class, 'column'], 'argumentCount' => '-1', 'passCellReference' => true, 'passByReference' => [true], ], 'COLUMNS' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\RowColumnInformation::class, 'COLUMNS'], + 'functionCall' => [LookupRef\RowColumnInformation::class, 'columns'], 'argumentCount' => '1', ], 'COMBIN' => [ @@ -586,42 +587,42 @@ class Calculation ], 'COMPLEX' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Complex::class, 'COMPLEX'], + 'functionCall' => [Engineering\Complex::class, 'complex'], 'argumentCount' => '2,3', ], 'CONCAT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Concatenate::class, 'CONCATENATE'], + 'functionCall' => [TextData\Concatenate::class, 'concatenate'], 'argumentCount' => '1+', ], 'CONCATENATE' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Concatenate::class, 'CONCATENATE'], + 'functionCall' => [TextData\Concatenate::class, 'concatenate'], 'argumentCount' => '1+', ], 'CONFIDENCE' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Confidence::class, 'CONFIDENCE'], + 'functionCall' => [Statistical\Confidence::class, 'confidence'], 'argumentCount' => '3', ], 'CONFIDENCE.NORM' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Confidence::class, 'CONFIDENCE'], + 'functionCall' => [Statistical\Confidence::class, 'confidence'], 'argumentCount' => '3', ], 'CONFIDENCE.T' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'CONVERT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ConvertUOM::class, 'CONVERT'], + 'functionCall' => [Engineering\ConvertUOM::class, 'convert'], 'argumentCount' => '3', ], 'CORREL' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'CORREL'], + 'functionCall' => [Statistical\Trends::class, 'correlation'], 'argumentCount' => '2', ], 'COS' => [ @@ -646,72 +647,72 @@ class Calculation ], 'COUNT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Counts::class, 'COUNT'], + 'functionCall' => [Statistical\Counts::class, 'count'], 'argumentCount' => '1+', ], 'COUNTA' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Counts::class, 'COUNTA'], + 'functionCall' => [Statistical\Counts::class, 'countA'], 'argumentCount' => '1+', ], 'COUNTBLANK' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Counts::class, 'COUNTBLANK'], + 'functionCall' => [Statistical\Counts::class, 'blank'], 'argumentCount' => '1', ], 'COUNTIF' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Conditional::class, 'COUNTIF'], + 'functionCall' => [Statistical\Conditional::class, 'countIf'], 'argumentCount' => '2', ], 'COUNTIFS' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Conditional::class, 'COUNTIFS'], + 'functionCall' => [Statistical\Conditional::class, 'countIfSeries'], 'argumentCount' => '2+', ], 'COUPDAYBS' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Coupons::class, 'COUPDAYBS'], + 'functionCall' => [Financial\Coupons::class, 'daysBeforeSettlement'], 'argumentCount' => '3,4', ], 'COUPDAYS' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Coupons::class, 'COUPDAYS'], + 'functionCall' => [Financial\Coupons::class, 'days'], 'argumentCount' => '3,4', ], 'COUPDAYSNC' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Coupons::class, 'COUPDAYSNC'], + 'functionCall' => [Financial\Coupons::class, 'daysToNextCoupon'], 'argumentCount' => '3,4', ], 'COUPNCD' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Coupons::class, 'COUPNCD'], + 'functionCall' => [Financial\Coupons::class, 'nextCouponDate'], 'argumentCount' => '3,4', ], 'COUPNUM' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Coupons::class, 'COUPNUM'], + 'functionCall' => [Financial\Coupons::class, 'numberPayable'], 'argumentCount' => '3,4', ], 'COUPPCD' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Coupons::class, 'COUPPCD'], + 'functionCall' => [Financial\Coupons::class, 'previousCouponDate'], 'argumentCount' => '3,4', ], 'COVAR' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'COVAR'], + 'functionCall' => [Statistical\Trends::class, 'covariance'], 'argumentCount' => '2', ], 'COVARIANCE.P' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'COVAR'], + 'functionCall' => [Statistical\Trends::class, 'covariance'], 'argumentCount' => '2', ], 'COVARIANCE.S' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'CRITBINOM' => [ @@ -731,37 +732,37 @@ class Calculation ], 'CUBEKPIMEMBER' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUBEMEMBER' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUBEMEMBERPROPERTY' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUBERANKEDMEMBER' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUBESET' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUBESETCOUNT' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUBEVALUE' => [ 'category' => Category::CATEGORY_CUBE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'CUMIPMT' => [ @@ -786,7 +787,7 @@ class Calculation ], 'DATESTRING' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'DATEVALUE' => [ @@ -816,12 +817,12 @@ class Calculation ], 'DB' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Depreciation::class, 'DB'], + 'functionCall' => [Financial\Depreciation::class, 'decliningBalance'], 'argumentCount' => '4,5', ], 'DBCS' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'DCOUNT' => [ @@ -836,7 +837,7 @@ class Calculation ], 'DDB' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Depreciation::class, 'DDB'], + 'functionCall' => [Financial\Depreciation::class, 'doubleDecliningBalance'], 'argumentCount' => '4,5', ], 'DEC2BIN' => [ @@ -856,7 +857,7 @@ class Calculation ], 'DECIMAL' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'DEGREES' => [ @@ -866,7 +867,7 @@ class Calculation ], 'DELTA' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Compare::class, 'DELTA'], + 'functionCall' => [Engineering\Compare::class, 'delta'], 'argumentCount' => '1,2', ], 'DEVSQ' => [ @@ -896,7 +897,7 @@ class Calculation ], 'DOLLAR' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Format::class, 'DOLLAR'], + 'functionCall' => [TextData\Format::class, 'dollar'], 'argumentCount' => '1,2', ], 'DOLLARDE' => [ @@ -916,7 +917,7 @@ class Calculation ], 'DROP' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-3', ], 'DSTDEV' => [ @@ -936,7 +937,7 @@ class Calculation ], 'DURATION' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '5,6', ], 'DVAR' => [ @@ -951,7 +952,7 @@ class Calculation ], 'ECMA.CEILING' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1,2', ], 'EDATE' => [ @@ -976,22 +977,22 @@ class Calculation ], 'ERF' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Erf::class, 'ERF'], + 'functionCall' => [Engineering\Erf::class, 'erf'], 'argumentCount' => '1,2', ], 'ERF.PRECISE' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Erf::class, 'ERFPRECISE'], + 'functionCall' => [Engineering\Erf::class, 'precise'], 'argumentCount' => '1', ], 'ERFC' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ErfC::class, 'ERFC'], + 'functionCall' => [Engineering\ErfC::class, 'complementary'], 'argumentCount' => '1', ], 'ERFC.PRECISE' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ErfC::class, 'ERFC'], + 'functionCall' => [Engineering\ErfC::class, 'complementary'], 'argumentCount' => '1', ], 'ERROR.TYPE' => [ @@ -1016,7 +1017,7 @@ class Calculation ], 'EXPAND' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-4', ], 'EXPONDIST' => [ @@ -1041,12 +1042,12 @@ class Calculation ], 'FALSE' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Boolean::class, 'FALSE'], + 'functionCall' => [Logical\Boolean::class, 'false'], 'argumentCount' => '0', ], 'FDIST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'F.DIST' => [ @@ -1056,17 +1057,18 @@ class Calculation ], 'F.DIST.RT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'FILTER' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [LookupRef\Filter::class, 'filter'], 'argumentCount' => '2-3', + 'spillageFunction' => true, ], 'FILTERXML' => [ 'category' => Category::CATEGORY_WEB, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'FIND' => [ @@ -1081,17 +1083,17 @@ class Calculation ], 'FINV' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'F.INV' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'F.INV.RT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'FISHER' => [ @@ -1106,7 +1108,7 @@ class Calculation ], 'FIXED' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Format::class, 'FIXEDFORMAT'], + 'functionCall' => [TextData\Format::class, 'fixedFormat'], 'argumentCount' => '1-3', ], 'FLOOR' => [ @@ -1126,32 +1128,32 @@ class Calculation ], 'FORECAST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'FORECAST'], + 'functionCall' => [Statistical\Trends::class, 'forecast'], 'argumentCount' => '3', ], 'FORECAST.ETS' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3-6', ], 'FORECAST.ETS.CONFINT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3-6', ], 'FORECAST.ETS.SEASONALITY' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-4', ], 'FORECAST.ETS.STAT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3-6', ], 'FORECAST.LINEAR' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'FORECAST'], + 'functionCall' => [Statistical\Trends::class, 'forecast'], 'argumentCount' => '3', ], 'FORMULATEXT' => [ @@ -1163,17 +1165,17 @@ class Calculation ], 'FREQUENCY' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'FTEST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'F.TEST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'FV' => [ @@ -1238,17 +1240,17 @@ class Calculation ], 'GESTEP' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Compare::class, 'GESTEP'], + 'functionCall' => [Engineering\Compare::class, 'geStep'], 'argumentCount' => '1,2', ], 'GETPIVOTDATA' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2+', ], 'GROWTH' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'GROWTH'], + 'functionCall' => [Statistical\Trends::class, 'growth'], 'argumentCount' => '1-4', ], 'HARMEAN' => [ @@ -1283,7 +1285,7 @@ class Calculation ], 'HSTACK' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1+', ], 'HYPERLINK' => [ @@ -1299,152 +1301,152 @@ class Calculation ], 'HYPGEOM.DIST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '5', ], 'IF' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Conditional::class, 'statementIf'], + 'functionCall' => [Logical\Conditional::class, 'if'], 'argumentCount' => '1-3', ], 'IFERROR' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Conditional::class, 'IFERROR'], + 'functionCall' => [Logical\Conditional::class, 'ifError'], 'argumentCount' => '2', ], 'IFNA' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Conditional::class, 'IFNA'], + 'functionCall' => [Logical\Conditional::class, 'ifNa'], 'argumentCount' => '2', ], 'IFS' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Conditional::class, 'IFS'], + 'functionCall' => [Logical\Conditional::class, 'ifSeries'], 'argumentCount' => '2+', ], 'IMABS' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMABS'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'absolute'], 'argumentCount' => '1', ], 'IMAGINARY' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Complex::class, 'IMAGINARY'], + 'functionCall' => [Engineering\Complex::class, 'imaginary'], 'argumentCount' => '1', ], 'IMARGUMENT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMARGUMENT'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'argument'], 'argumentCount' => '1', ], 'IMCONJUGATE' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCONJUGATE'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'conjugate'], 'argumentCount' => '1', ], 'IMCOS' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCOS'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'cos'], 'argumentCount' => '1', ], 'IMCOSH' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCOSH'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'cosh'], 'argumentCount' => '1', ], 'IMCOT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCOT'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'cot'], 'argumentCount' => '1', ], 'IMCSC' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCSC'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'csc'], 'argumentCount' => '1', ], 'IMCSCH' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCSCH'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'csch'], 'argumentCount' => '1', ], 'IMDIV' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexOperations::class, 'IMDIV'], + 'functionCall' => [Engineering\ComplexOperations::class, 'div'], 'argumentCount' => '2', ], 'IMEXP' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMEXP'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'exp'], 'argumentCount' => '1', ], 'IMLN' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMLN'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'ln'], 'argumentCount' => '1', ], 'IMLOG10' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMLOG10'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'log10'], 'argumentCount' => '1', ], 'IMLOG2' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMLOG2'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'log2'], 'argumentCount' => '1', ], 'IMPOWER' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMPOWER'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'power'], 'argumentCount' => '2', ], 'IMPRODUCT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexOperations::class, 'IMPRODUCT'], + 'functionCall' => [Engineering\ComplexOperations::class, 'product'], 'argumentCount' => '1+', ], 'IMREAL' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\Complex::class, 'IMREAL'], + 'functionCall' => [Engineering\Complex::class, 'real'], 'argumentCount' => '1', ], 'IMSEC' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSEC'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'sec'], 'argumentCount' => '1', ], 'IMSECH' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSECH'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'sech'], 'argumentCount' => '1', ], 'IMSIN' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSIN'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'sin'], 'argumentCount' => '1', ], 'IMSINH' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSINH'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'sinh'], 'argumentCount' => '1', ], 'IMSQRT' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSQRT'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'sqrt'], 'argumentCount' => '1', ], 'IMSUB' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexOperations::class, 'IMSUB'], + 'functionCall' => [Engineering\ComplexOperations::class, 'sub'], 'argumentCount' => '2', ], 'IMSUM' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexOperations::class, 'IMSUM'], + 'functionCall' => [Engineering\ComplexOperations::class, 'sum'], 'argumentCount' => '1+', ], 'IMTAN' => [ 'category' => Category::CATEGORY_ENGINEERING, - 'functionCall' => [Engineering\ComplexFunctions::class, 'IMTAN'], + 'functionCall' => [Engineering\ComplexFunctions::class, 'tan'], 'argumentCount' => '1', ], 'INDEX' => [ @@ -1454,13 +1456,13 @@ class Calculation ], 'INDIRECT' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\Indirect::class, 'INDIRECT'], + 'functionCall' => [LookupRef\Indirect::class, 'indirect'], 'argumentCount' => '1,2', 'passCellReference' => true, ], 'INFO' => [ 'category' => Category::CATEGORY_INFORMATION, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'INT' => [ @@ -1470,7 +1472,7 @@ class Calculation ], 'INTERCEPT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'INTERCEPT'], + 'functionCall' => [Statistical\Trends::class, 'intercept'], 'argumentCount' => '2', ], 'INTRATE' => [ @@ -1537,7 +1539,7 @@ class Calculation ], 'ISO.CEILING' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1,2', ], 'ISODD' => [ @@ -1569,12 +1571,12 @@ class Calculation ], 'ISTHAIDIGIT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'JIS' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'KURT' => [ @@ -1614,7 +1616,7 @@ class Calculation ], 'LINEST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'LINEST'], + 'functionCall' => [Statistical\Trends::class, 'lineEstimate'], 'argumentCount' => '1-4', ], 'LN' => [ @@ -1634,7 +1636,7 @@ class Calculation ], 'LOGEST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'LOGEST'], + 'functionCall' => [Statistical\Trends::class, 'logEstimate'], 'argumentCount' => '1-4', ], 'LOGINV' => [ @@ -1669,7 +1671,7 @@ class Calculation ], 'MATCH' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\ExcelMatch::class, 'MATCH'], + 'functionCall' => [LookupRef\ExcelMatch::class, 'match'], 'argumentCount' => '2,3', ], 'MAX' => [ @@ -1684,7 +1686,7 @@ class Calculation ], 'MAXIFS' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Conditional::class, 'MAXIFS'], + 'functionCall' => [Statistical\Conditional::class, 'maxIfSeries'], 'argumentCount' => '3+', ], 'MDETERM' => [ @@ -1694,7 +1696,7 @@ class Calculation ], 'MDURATION' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '5,6', ], 'MEDIAN' => [ @@ -1704,7 +1706,7 @@ class Calculation ], 'MEDIANIF' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2+', ], 'MID' => [ @@ -1729,7 +1731,7 @@ class Calculation ], 'MINIFS' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Conditional::class, 'MINIFS'], + 'functionCall' => [Statistical\Conditional::class, 'minIfSeries'], 'argumentCount' => '3+', ], 'MINUTE' => [ @@ -1764,7 +1766,7 @@ class Calculation ], 'MODE.MULT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1+', ], 'MODE.SNGL' => [ @@ -1809,7 +1811,7 @@ class Calculation ], 'NEGBINOM.DIST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '4', ], 'NETWORKDAYS' => [ @@ -1819,7 +1821,7 @@ class Calculation ], 'NETWORKDAYS.INTL' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-4', ], 'NOMINAL' => [ @@ -1869,7 +1871,7 @@ class Calculation ], 'NOT' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Operations::class, 'NOT'], + 'functionCall' => [Logical\Operations::class, 'not'], 'argumentCount' => '1', ], 'NOW' => [ @@ -1889,12 +1891,12 @@ class Calculation ], 'NUMBERSTRING' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'NUMBERVALUE' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Format::class, 'NUMBERVALUE'], + 'functionCall' => [TextData\Format::class, 'numberValue'], 'argumentCount' => '1+', ], 'OCT2BIN' => [ @@ -1919,34 +1921,34 @@ class Calculation ], 'ODDFPRICE' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '8,9', ], 'ODDFYIELD' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '8,9', ], 'ODDLPRICE' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '7,8', ], 'ODDLYIELD' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '7,8', ], 'OFFSET' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\Offset::class, 'OFFSET'], + 'functionCall' => [LookupRef\Offset::class, 'offset'], 'argumentCount' => '3-5', 'passCellReference' => true, 'passByReference' => [true], ], 'OR' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Operations::class, 'logicalOr'], + 'functionCall' => [Logical\Operations::class, 'or'], 'argumentCount' => '1+', ], 'PDURATION' => [ @@ -1956,57 +1958,57 @@ class Calculation ], 'PEARSON' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'CORREL'], + 'functionCall' => [Statistical\Trends::class, 'correlation'], 'argumentCount' => '2', ], 'PERCENTILE' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'PERCENTILE'], + 'functionCall' => [Statistical\Percentiles::class, 'percentile'], 'argumentCount' => '2', ], 'PERCENTILE.EXC' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'PERCENTILE.INC' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'PERCENTILE'], + 'functionCall' => [Statistical\Percentiles::class, 'percentile'], 'argumentCount' => '2', ], 'PERCENTRANK' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'PERCENTRANK'], + 'functionCall' => [Statistical\Percentiles::class, 'percentRank'], 'argumentCount' => '2,3', ], 'PERCENTRANK.EXC' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2,3', ], 'PERCENTRANK.INC' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'PERCENTRANK'], + 'functionCall' => [Statistical\Percentiles::class, 'percentRank'], 'argumentCount' => '2,3', ], 'PERMUT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Permutations::class, 'PERMUT'], + 'functionCall' => [Statistical\Permutations::class, 'permut'], 'argumentCount' => '2', ], 'PERMUTATIONA' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Permutations::class, 'PERMUTATIONA'], + 'functionCall' => [Statistical\Permutations::class, 'permutationA'], 'argumentCount' => '2', ], 'PHONETIC' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'PHI' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1', ], 'PI' => [ @@ -2056,7 +2058,7 @@ class Calculation ], 'PROB' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3,4', ], 'PRODUCT' => [ @@ -2076,17 +2078,17 @@ class Calculation ], 'QUARTILE' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'QUARTILE'], + 'functionCall' => [Statistical\Percentiles::class, 'quartile'], 'argumentCount' => '2', ], 'QUARTILE.EXC' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'QUARTILE.INC' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'QUARTILE'], + 'functionCall' => [Statistical\Percentiles::class, 'quartile'], 'argumentCount' => '2', ], 'QUOTIENT' => [ @@ -2108,6 +2110,7 @@ class Calculation 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [MathTrig\Random::class, 'randArray'], 'argumentCount' => '0-5', + 'spillageFunction' => true, ], 'RANDBETWEEN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, @@ -2116,17 +2119,17 @@ class Calculation ], 'RANK' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'RANK'], + 'functionCall' => [Statistical\Percentiles::class, 'rank'], 'argumentCount' => '2,3', ], 'RANK.AVG' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2,3', ], 'RANK.EQ' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Percentiles::class, 'RANK'], + 'functionCall' => [Statistical\Percentiles::class, 'rank'], 'argumentCount' => '2,3', ], 'RATE' => [ @@ -2151,7 +2154,7 @@ class Calculation ], 'REPT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Concatenate::class, 'builtinREPT'], + 'functionCall' => [TextData\Concatenate::class, 'repeat'], 'argumentCount' => '2', ], 'RIGHT' => [ @@ -2166,7 +2169,7 @@ class Calculation ], 'ROMAN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [MathTrig\Roman::class, 'evaluate'], + 'functionCall' => [MathTrig\Roman::class, 'toArabic'], 'argumentCount' => '1,2', ], 'ROUND' => [ @@ -2176,12 +2179,12 @@ class Calculation ], 'ROUNDBAHTDOWN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'ROUNDBAHTUP' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'ROUNDDOWN' => [ @@ -2196,14 +2199,14 @@ class Calculation ], 'ROW' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\RowColumnInformation::class, 'ROW'], + 'functionCall' => [LookupRef\RowColumnInformation::class, 'row'], 'argumentCount' => '-1', 'passCellReference' => true, 'passByReference' => [true], ], 'ROWS' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [LookupRef\RowColumnInformation::class, 'ROWS'], + 'functionCall' => [LookupRef\RowColumnInformation::class, 'rows'], 'argumentCount' => '1', ], 'RRI' => [ @@ -2213,12 +2216,12 @@ class Calculation ], 'RSQ' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'RSQ'], + 'functionCall' => [Statistical\Trends::class, 'pearsonSquares'], 'argumentCount' => '2', ], 'RTD' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1+', ], 'SEARCH' => [ @@ -2250,6 +2253,7 @@ class Calculation 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [MathTrig\MatrixFunctions::class, 'sequence'], 'argumentCount' => '1-4', + 'spillageFunction' => true, ], 'SERIESSUM' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, @@ -2258,12 +2262,12 @@ class Calculation ], 'SHEET' => [ 'category' => Category::CATEGORY_INFORMATION, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '0,1', ], 'SHEETS' => [ 'category' => Category::CATEGORY_INFORMATION, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '0,1', ], 'SIGN' => [ @@ -2288,17 +2292,17 @@ class Calculation ], 'SKEW.P' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1+', ], 'SLN' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Depreciation::class, 'SLN'], + 'functionCall' => [Financial\Depreciation::class, 'straightLine'], 'argumentCount' => '3', ], 'SLOPE' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'SLOPE'], + 'functionCall' => [Statistical\Trends::class, 'slope'], 'argumentCount' => '2', ], 'SMALL' => [ @@ -2310,11 +2314,13 @@ class Calculation 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [LookupRef\Sort::class, 'sort'], 'argumentCount' => '1-4', + 'spillageFunction' => true, ], 'SORTBY' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [LookupRef\Sort::class, 'sortBy'], 'argumentCount' => '2+', + 'spillageFunction' => true, ], 'SQRT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, @@ -2333,37 +2339,37 @@ class Calculation ], 'STDEV' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'], + 'functionCall' => [Statistical\StandardDeviations::class, 'stdev'], 'argumentCount' => '1+', ], 'STDEV.S' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'], + 'functionCall' => [Statistical\StandardDeviations::class, 'stdev'], 'argumentCount' => '1+', ], 'STDEV.P' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'], + 'functionCall' => [Statistical\StandardDeviations::class, 'stdevP'], 'argumentCount' => '1+', ], 'STDEVA' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVA'], + 'functionCall' => [Statistical\StandardDeviations::class, 'stdevA'], 'argumentCount' => '1+', ], 'STDEVP' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'], + 'functionCall' => [Statistical\StandardDeviations::class, 'stdevP'], 'argumentCount' => '1+', ], 'STDEVPA' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVPA'], + 'functionCall' => [Statistical\StandardDeviations::class, 'stdevPA'], 'argumentCount' => '1+', ], 'STEYX' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'STEYX'], + 'functionCall' => [Statistical\Trends::class, 'standardError'], 'argumentCount' => '2', ], 'SUBSTITUTE' => [ @@ -2384,12 +2390,12 @@ class Calculation ], 'SUMIF' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Statistical\Conditional::class, 'SUMIF'], + 'functionCall' => [Statistical\Conditional::class, 'sumIf'], 'argumentCount' => '2,3', ], 'SUMIFS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Statistical\Conditional::class, 'SUMIFS'], + 'functionCall' => [Statistical\Conditional::class, 'sumIfSeries'], 'argumentCount' => '3+', ], 'SUMPRODUCT' => [ @@ -2419,12 +2425,12 @@ class Calculation ], 'SWITCH' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Conditional::class, 'statementSwitch'], + 'functionCall' => [Logical\Conditional::class, 'switch'], 'argumentCount' => '3+', ], 'SYD' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial\Depreciation::class, 'SYD'], + 'functionCall' => [Financial\Depreciation::class, 'sumOfYears'], 'argumentCount' => '4', ], 'T' => [ @@ -2434,7 +2440,7 @@ class Calculation ], 'TAKE' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-3', ], 'TAN' => [ @@ -2469,22 +2475,22 @@ class Calculation ], 'T.DIST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3', ], 'T.DIST.2T' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'T.DIST.RT' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'TEXT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Format::class, 'TEXTFORMAT'], + 'functionCall' => [TextData\Format::class, 'textFormat'], 'argumentCount' => '2', ], 'TEXTAFTER' => [ @@ -2499,7 +2505,7 @@ class Calculation ], 'TEXTJOIN' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Concatenate::class, 'TEXTJOIN'], + 'functionCall' => [TextData\Concatenate::class, 'join'], 'argumentCount' => '3+', ], 'TEXTSPLIT' => [ @@ -2509,37 +2515,37 @@ class Calculation ], 'THAIDAYOFWEEK' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'THAIDIGIT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'THAIMONTHOFYEAR' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'THAINUMSOUND' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'THAINUMSTRING' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'THAISTRINGLENGTH' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'THAIYEAR' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '?', ], 'TIME' => [ @@ -2564,7 +2570,7 @@ class Calculation ], 'T.INV.2T' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2', ], 'TODAY' => [ @@ -2574,12 +2580,12 @@ class Calculation ], 'TOCOL' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1-3', ], 'TOROW' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1-3', ], 'TRANSPOSE' => [ @@ -2589,7 +2595,7 @@ class Calculation ], 'TREND' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Trends::class, 'TREND'], + 'functionCall' => [Statistical\Trends::class, 'trend'], 'argumentCount' => '1-4', ], 'TRIM' => [ @@ -2604,7 +2610,7 @@ class Calculation ], 'TRUE' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Boolean::class, 'TRUE'], + 'functionCall' => [Logical\Boolean::class, 'true'], 'argumentCount' => '0', ], 'TRUNC' => [ @@ -2614,12 +2620,12 @@ class Calculation ], 'TTEST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '4', ], 'T.TEST' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '4', ], 'TYPE' => [ @@ -2641,6 +2647,7 @@ class Calculation 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [LookupRef\Unique::class, 'unique'], 'argumentCount' => '1+', + 'spillageFunction' => true, ], 'UPPER' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, @@ -2654,7 +2661,7 @@ class Calculation ], 'VALUE' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [TextData\Format::class, 'VALUE'], + 'functionCall' => [TextData\Format::class, 'value'], 'argumentCount' => '1', ], 'VALUETOTEXT' => [ @@ -2664,37 +2671,37 @@ class Calculation ], 'VAR' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Variances::class, 'VAR'], + 'functionCall' => [Statistical\Variances::class, 'variance'], 'argumentCount' => '1+', ], 'VAR.P' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Variances::class, 'VARP'], + 'functionCall' => [Statistical\Variances::class, 'varianceP'], 'argumentCount' => '1+', ], 'VAR.S' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Variances::class, 'VAR'], + 'functionCall' => [Statistical\Variances::class, 'variance'], 'argumentCount' => '1+', ], 'VARA' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Variances::class, 'VARA'], + 'functionCall' => [Statistical\Variances::class, 'varianceA'], 'argumentCount' => '1+', ], 'VARP' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Variances::class, 'VARP'], + 'functionCall' => [Statistical\Variances::class, 'varianceP'], 'argumentCount' => '1+', ], 'VARPA' => [ 'category' => Category::CATEGORY_STATISTICAL, - 'functionCall' => [Statistical\Variances::class, 'VARPA'], + 'functionCall' => [Statistical\Variances::class, 'variancePA'], 'argumentCount' => '1+', ], 'VDB' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '5-7', ], 'VLOOKUP' => [ @@ -2704,7 +2711,7 @@ class Calculation ], 'VSTACK' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '1+', ], 'WEBSERVICE' => [ @@ -2739,17 +2746,17 @@ class Calculation ], 'WORKDAY.INTL' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-4', ], 'WRAPCOLS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-3', ], 'WRAPROWS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2-3', ], 'XIRR' => [ @@ -2759,7 +2766,7 @@ class Calculation ], 'XLOOKUP' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '3-6', ], 'XNPV' => [ @@ -2769,12 +2776,12 @@ class Calculation ], 'XMATCH' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '2,3', ], 'XOR' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Logical\Operations::class, 'logicalXor'], + 'functionCall' => [Logical\Operations::class, 'xor'], 'argumentCount' => '1+', ], 'YEAR' => [ @@ -2789,7 +2796,7 @@ class Calculation ], 'YIELD' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Functions::class, 'dummy'], 'argumentCount' => '6,7', ], 'YIELDDISC' => [ @@ -2812,6 +2819,21 @@ class Calculation 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'zTest'], 'argumentCount' => '2-3', ], + // Internal MS Excel Functions + 'ANCHORARRAY' => [ + 'category' => Category::CATEGORY_MICROSOFT_INTERNAL_PSEUDOFUNCTION, + 'functionCall' => [Internal\ExcelArrayPseudoFunctions::class, 'anchorArray'], + 'argumentCount' => '1', + 'passCellReference' => true, + 'passByReference' => [true], + ], + 'SINGLE' => [ + 'category' => Category::CATEGORY_MICROSOFT_INTERNAL_PSEUDOFUNCTION, + 'functionCall' => [Internal\ExcelArrayPseudoFunctions::class, 'single'], + 'argumentCount' => '1', + 'passCellReference' => true, + 'passByReference' => [true], + ], ]; // Internal functions used for special control purposes @@ -2822,7 +2844,7 @@ class Calculation ], 'NAME.ERROR' => [ 'argumentCount' => '*', - 'functionCall' => [Functions::class, 'NAME'], + 'functionCall' => [Information\ExcelError::class, 'NAME'], ], 'WILDCARDMATCH' => [ 'argumentCount' => '2', @@ -2927,7 +2949,7 @@ public static function getFALSE(): string * * @return bool Success or failure */ - public static function setArrayReturnType($returnType) + public static function setArrayReturnType(string $returnType): bool { if ( ($returnType == self::RETURN_ARRAY_AS_VALUE) || @@ -2947,17 +2969,15 @@ public static function setArrayReturnType($returnType) * * @return string $returnType Array return type */ - public static function getArrayReturnType() + public static function getArrayReturnType(): string { return self::$returnArrayAsType; } /** * Is calculation caching enabled? - * - * @return bool */ - public function getCalculationCacheEnabled() + public function getCalculationCacheEnabled(): bool { return $this->calculationCacheEnabled; } @@ -2999,10 +3019,8 @@ public function clearCalculationCache(): void /** * Clear calculation cache for a specified worksheet. - * - * @param string $worksheetName */ - public function clearCalculationCacheForWorksheet($worksheetName): void + public function clearCalculationCacheForWorksheet(string $worksheetName): void { if (isset($this->calculationCache[$worksheetName])) { unset($this->calculationCache[$worksheetName]); @@ -3011,13 +3029,10 @@ public function clearCalculationCacheForWorksheet($worksheetName): void /** * Rename calculation cache for a specified worksheet. - * - * @param string $fromWorksheetName - * @param string $toWorksheetName */ - public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void + public function renameCalculationCacheForWorksheet(?string $fromWorksheetName, string $toWorksheetName): void { - if (isset($this->calculationCache[$fromWorksheetName])) { + if ($fromWorksheetName !== null && isset($this->calculationCache[$fromWorksheetName])) { $this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName]; unset($this->calculationCache[$fromWorksheetName]); } @@ -3026,7 +3041,7 @@ public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksh /** * Enable/disable calculation cache. * - * @param mixed $enabled + * @param bool $enabled */ public function setBranchPruningEnabled($enabled): void { @@ -3046,10 +3061,8 @@ public function disableBranchPruning(): void /** * Get the currently defined locale code. - * - * @return string */ - public function getLocale() + public function getLocale(): string { return self::$localeLanguage; } @@ -3073,10 +3086,8 @@ private function getLocaleFile(string $localeDir, string $locale, string $langua * Set the locale code. * * @param string $locale The locale to use for formula translation, eg: 'en_us' - * - * @return bool */ - public function setLocale(string $locale) + public function setLocale(string $locale): bool { // Identify our locale and language $language = $locale = strtolower($locale); @@ -3247,7 +3258,7 @@ private static function translateFormula(array $from, array $to, string $formula private static $functionReplaceToLocale; - public function _translateFormulaToLocale($formula) + public function translateFormulaToLocale(string $formula): string { // Build list of function names and constants for translation if (self::$functionReplaceFromExcel === null) { @@ -3283,7 +3294,7 @@ public function _translateFormulaToLocale($formula) private static $functionReplaceToExcel; - public function _translateFormulaToEnglish($formula) + public function translateFormulaToEnglish(string $formula): string { if (self::$functionReplaceFromLocale === null) { self::$functionReplaceFromLocale = []; @@ -3309,7 +3320,7 @@ public function _translateFormulaToEnglish($formula) return self::translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$localeArgumentSeparator, ','); } - public static function localeFunc($function) + public static function localeFunc(string $function): string { if (self::$localeLanguage !== 'en_us') { $functionName = trim($function, '('); @@ -3380,10 +3391,10 @@ public static function unwrapResult($value) * * @return mixed */ - public function calculate(?Cell $cell = null) + public function calculate(?Cell $cell = null, bool $asArray = false, bool $resetLog = true) { try { - return $this->calculateCellValue($cell); + return $this->calculateCellValue($cell, $asArray, $resetLog); } catch (\Exception $e) { throw new Exception($e->getMessage()); } @@ -3397,7 +3408,7 @@ public function calculate(?Cell $cell = null) * * @return mixed */ - public function calculateCellValue(?Cell $cell = null, $resetLog = true) + public function calculateCellValue(?Cell $cell = null, bool $asArray = false, bool $resetLog = true) { if ($cell === null) { return null; @@ -3421,7 +3432,7 @@ public function calculateCellValue(?Cell $cell = null, $resetLog = true) ]; try { - $result = self::unwrapResult($this->_calculateFormulaValue($cell->getValue(), $cell->getCoordinate(), $cell)); + $result = self::unwrapResult($this->calculateFormulaValue($cell->getValue(), $cell->getCoordinate(), $cell)); $cellAddress = array_pop($this->cellStack); $this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']); } catch (\Exception $e) { @@ -3518,7 +3529,7 @@ public function calculateFormula($formula, $cellID = null, ?Cell $cell = null) // Execute the calculation try { - $result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $cell)); + $result = self::unwrapResult($this->calculateFormulaValue($formula, $cellID, $cell)); } catch (\Exception $e) { throw new Exception($e->getMessage()); } @@ -3571,7 +3582,7 @@ public function saveValueToCache($cellReference, $cellValue): void * * @return mixed */ - public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null) + public function calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null) { $cellValue = null; @@ -3652,7 +3663,7 @@ public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = n * 1 = shrink to fit * 2 = extend to fit * - * @return array + * @return array */ private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) { @@ -3671,7 +3682,9 @@ private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) [$matrix1Rows, $matrix1Columns] = self::getMatrixDimensions($operand1); [$matrix2Rows, $matrix2Columns] = self::getMatrixDimensions($operand2); if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) { - $resize = 1; + // Vectors increase size to match to build a square matrix; + // Non-vectors reduce size to a square that reflects min(rows1, rows2) and min(cols1, cols2) + $resize = ($matrix1Rows === 1 || $matrix2Rows === 1) ? 2 : 1; } if ($resize == 2) { @@ -3690,7 +3703,7 @@ private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) * * @param array $matrix matrix operand * - * @return int[] An array comprising the number of rows, and number of columns + * @return array An array comprising the number of rows, and number of columns */ public static function getMatrixDimensions(array &$matrix) { @@ -3803,7 +3816,7 @@ private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, /** * Format details of an operand for display in the log (based on operand type). * - * @param mixed $value First matrix operand + * @param mixed $value Operand value * * @return mixed */ @@ -3843,7 +3856,7 @@ private function showValue($value) /** * Format type and details of an operand for display in the log (based on operand type). * - * @param mixed $value First matrix operand + * @param mixed $value Operand value * * @return null|string */ @@ -4746,7 +4759,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null) } if (count(Functions::flattenArray($cellIntersect)) === 0) { $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($cellIntersect)); - $stack->push('Error', Functions::null(), null); + $stack->push('Error', ExcelError::null(), null); } else { $cellRef = Coordinate::stringFromColumnIndex(min($oCol) + 1) . min($oRow) . ':' . Coordinate::stringFromColumnIndex(max($oCol) + 1) . max($oRow); @@ -5002,12 +5015,13 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null) return $this->raiseFormulaError('internal error'); } $output = $stack->pop(); + $output = $output['value']; return $output; } - private function validateBinaryOperand(&$operand, &$stack) + private function validateBinaryOperand(&$operand, Stack &$stack): bool { if (is_array($operand)) { if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) { @@ -5144,11 +5158,16 @@ private function executeNumericBinaryOperation($operand1, $operand2, $operation, try { // Convert operand 1 from a PHP array to a matrix +// $matrix = new \Matrix\Matrix($operand1); +// var_dump($operand1, $matrixFunction, $operand2); $matrix = new Shared\JAMA\Matrix($operand1); // Perform the required operation against the operand 1 matrix, passing in operand 2 $matrixResult = $matrix->$matrixFunction($operand2); $result = $matrixResult->getArray(); - } catch (\Exception $ex) { +// $result = $matrixResult->toArray(); +// var_dump('=>', $result); + } catch (Throwable $ex) { +// var_dump($ex->getMessage()); $this->debugLog->writeDebugLog('JAMA Matrix Exception: %s', $ex->getMessage()); $result = '#VALUE!'; } @@ -5258,7 +5277,7 @@ public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, $ // Single cell in range sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow); if ($worksheet->cellExists($aReferences[0])) { - $returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue($resetLog); + $returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue(false, $resetLog); } else { $returnValue[$currentRow][$currentCol] = null; } @@ -5268,7 +5287,7 @@ public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, $ // Extract range sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow); if ($worksheet->cellExists($reference)) { - $returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue($resetLog); + $returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue(false, $resetLog); } else { $returnValue[$currentRow][$currentCol] = null; } @@ -5321,7 +5340,7 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = // Single cell (or single column or row) in range [$currentCol, $currentRow] = Coordinate::coordinateFromString($aReferences[0]); if ($worksheet->cellExists($aReferences[0])) { - $returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue($resetLog); + $returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue(true, $resetLog); } else { $returnValue[$currentRow][$currentCol] = null; } @@ -5331,7 +5350,7 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = // Extract range [$currentCol, $currentRow] = Coordinate::coordinateFromString($reference); if ($worksheet->cellExists($reference)) { - $returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue($resetLog); + $returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue(true, $resetLog); } else { $returnValue[$currentRow][$currentCol] = null; } @@ -5352,17 +5371,22 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = public function isImplemented($function) { $function = strtoupper($function); - $notImplemented = !isset(self::$phpSpreadsheetFunctions[$function]) || (is_array(self::$phpSpreadsheetFunctions[$function]['functionCall']) && self::$phpSpreadsheetFunctions[$function]['functionCall'][1] === 'DUMMY'); + $notImplemented = !isset(self::$phpSpreadsheetFunctions[$function]) || (is_array(self::$phpSpreadsheetFunctions[$function]['functionCall']) && self::$phpSpreadsheetFunctions[$function]['functionCall'][1] === 'dummy'); return !$notImplemented; } /** - * Get a list of all implemented functions as an array of function objects. + * Get a list of all functions as an array of function objects. */ public function getFunctions(): array { - return self::$phpSpreadsheetFunctions; + return array_filter( + self::$phpSpreadsheetFunctions, + function ($function) { + return $function['category'] !== Category::CATEGORY_MICROSOFT_INTERNAL_PSEUDOFUNCTION; + } + ); } /** @@ -5373,7 +5397,7 @@ public function getFunctions(): array public function getImplementedFunctionNames() { $returnValue = []; - foreach (self::$phpSpreadsheetFunctions as $functionName => $function) { + foreach ($this->getFunctions() as $functionName => $function) { if ($this->isImplemented($functionName)) { $returnValue[] = $functionName; } @@ -5461,7 +5485,7 @@ private function addCellReference(array $args, $passCellReference, $functionCall return $args; } - private function getTokensAsString($tokens) + private function getTokensAsString(array $tokens): string { $tokensStr = array_map(function ($token) { $value = $token['value'] ?? 'no value'; @@ -5516,7 +5540,7 @@ private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksh $recursiveCalculator = new self($this->spreadsheet); $recursiveCalculator->getDebugLog()->setWriteDebugLog($this->getDebugLog()->getWriteDebugLog()); $recursiveCalculator->getDebugLog()->setEchoDebugLog($this->getDebugLog()->getEchoDebugLog()); - $result = $recursiveCalculator->_calculateFormulaValue($definedNameValue, $recursiveCalculationCellAddress, $recursiveCalculationCell); + $result = $recursiveCalculator->calculateFormulaValue($definedNameValue, $recursiveCalculationCellAddress, $recursiveCalculationCell); if ($this->getDebugLog()->getWriteDebugLog()) { $this->debugLog->mergeDebugLog(array_slice($recursiveCalculator->getDebugLog()->getLog(), 3)); diff --git a/src/PhpSpreadsheet/Calculation/Category.php b/src/PhpSpreadsheet/Calculation/Category.php index 96bb72ad4c..ff94fc25e2 100644 --- a/src/PhpSpreadsheet/Calculation/Category.php +++ b/src/PhpSpreadsheet/Calculation/Category.php @@ -17,4 +17,6 @@ abstract class Category const CATEGORY_STATISTICAL = 'Statistical'; const CATEGORY_TEXT_AND_DATA = 'Text and Data'; const CATEGORY_WEB = 'Web'; + + const CATEGORY_MICROSOFT_INTERNAL_PSEUDOFUNCTION = 'MS Pseudo'; } diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php deleted file mode 100644 index 6503167475..0000000000 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ /dev/null @@ -1,440 +0,0 @@ -_calculateFormulaValue('=' . $conditions); + $result = Calculation::getInstance()->calculateFormulaValue('=' . $conditions); // If the row failed to meet the criteria, remove it from the database if ($result !== true) { diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php deleted file mode 100644 index 79fa8dc0bb..0000000000 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ /dev/null @@ -1,915 +0,0 @@ -getMessage(); - } - } - - /** - * DATETIMENOW. - * - * Returns the current date and time. - * The NOW function is useful when you need to display the current date and time on a worksheet or - * calculate a value based on the current date and time, and have that value updated each time you - * open the worksheet. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * NOW() - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Current::now() - * Use the now method in the DateTimeExcel\Current class instead - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function DATETIMENOW() - { - return DateTimeExcel\Current::now(); - } - - /** - * DATENOW. - * - * Returns the current date. - * The NOW function is useful when you need to display the current date and time on a worksheet or - * calculate a value based on the current date and time, and have that value updated each time you - * open the worksheet. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * TODAY() - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Current::today() - * Use the today method in the DateTimeExcel\Current class instead - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function DATENOW() - { - return DateTimeExcel\Current::today(); - } - - /** - * DATE. - * - * The DATE function returns a value that represents a particular date. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * - * Excel Function: - * DATE(year,month,day) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Date::fromYMD() - * Use the fromYMD method in the DateTimeExcel\Date class instead - * - * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. - * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, - * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. - * - * @param int $year The value of the year argument can include one to four digits. - * Excel interprets the year argument according to the configured - * date system: 1900 or 1904. - * If year is between 0 (zero) and 1899 (inclusive), Excel adds that - * value to 1900 to calculate the year. For example, DATE(108,1,2) - * returns January 2, 2008 (1900+108). - * If year is between 1900 and 9999 (inclusive), Excel uses that - * value as the year. For example, DATE(2008,1,2) returns January 2, - * 2008. - * If year is less than 0 or is 10000 or greater, Excel returns the - * #NUM! error value. - * @param int $month A positive or negative integer representing the month of the year - * from 1 to 12 (January to December). - * If month is greater than 12, month adds that number of months to - * the first month in the year specified. For example, DATE(2008,14,2) - * returns the serial number representing February 2, 2009. - * If month is less than 1, month subtracts the magnitude of that - * number of months, plus 1, from the first month in the year - * specified. For example, DATE(2008,-3,2) returns the serial number - * representing September 2, 2007. - * @param int $day A positive or negative integer representing the day of the month - * from 1 to 31. - * If day is greater than the number of days in the month specified, - * day adds that number of days to the first day in the month. For - * example, DATE(2008,1,35) returns the serial number representing - * February 4, 2008. - * If day is less than 1, day subtracts the magnitude that number of - * days, plus one, from the first day of the month specified. For - * example, DATE(2008,1,-15) returns the serial number representing - * December 16, 2007. - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function DATE($year = 0, $month = 1, $day = 1) - { - return DateTimeExcel\Date::fromYMD($year, $month, $day); - } - - /** - * TIME. - * - * The TIME function returns a value that represents a particular time. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * TIME(hour,minute,second) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Time::fromHMS() - * Use the fromHMS method in the DateTimeExcel\Time class instead - * - * @param int $hour A number from 0 (zero) to 32767 representing the hour. - * Any value greater than 23 will be divided by 24 and the remainder - * will be treated as the hour value. For example, TIME(27,0,0) = - * TIME(3,0,0) = .125 or 3:00 AM. - * @param int $minute A number from 0 to 32767 representing the minute. - * Any value greater than 59 will be converted to hours and minutes. - * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM. - * @param int $second A number from 0 to 32767 representing the second. - * Any value greater than 59 will be converted to hours, minutes, - * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 - * or 12:33:20 AM - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function TIME($hour = 0, $minute = 0, $second = 0) - { - return DateTimeExcel\Time::fromHMS($hour, $minute, $second); - } - - /** - * DATEVALUE. - * - * Returns a value that represents a particular date. - * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp - * value. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * DATEVALUE(dateValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\DateValue::fromString() - * Use the fromString method in the DateTimeExcel\DateValue class instead - * - * @param string $dateValue Text that represents a date in a Microsoft Excel date format. - * For example, "1/30/2008" or "30-Jan-2008" are text strings within - * quotation marks that represent dates. Using the default date - * system in Excel for Windows, date_text must represent a date from - * January 1, 1900, to December 31, 9999. Using the default date - * system in Excel for the Macintosh, date_text must represent a date - * from January 1, 1904, to December 31, 9999. DATEVALUE returns the - * #VALUE! error value if date_text is out of this range. - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function DATEVALUE($dateValue) - { - return DateTimeExcel\DateValue::fromString($dateValue); - } - - /** - * TIMEVALUE. - * - * Returns a value that represents a particular time. - * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp - * value. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * TIMEVALUE(timeValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\TimeValue::fromString() - * Use the fromString method in the DateTimeExcel\TimeValue class instead - * - * @param string $timeValue A text string that represents a time in any one of the Microsoft - * Excel time formats; for example, "6:45 PM" and "18:45" text strings - * within quotation marks that represent time. - * Date information in time_text is ignored. - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function TIMEVALUE($timeValue) - { - return DateTimeExcel\TimeValue::fromString($timeValue); - } - - /** - * DATEDIF. - * - * Excel Function: - * DATEDIF(startdate, enddate, unit) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Difference::interval() - * Use the interval method in the DateTimeExcel\Difference class instead - * - * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object - * or a standard date string - * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object - * or a standard date string - * @param array|string $unit - * - * @return array|int|string Interval between the dates - */ - public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') - { - return DateTimeExcel\Difference::interval($startDate, $endDate, $unit); - } - - /** - * DAYS. - * - * Returns the number of days between two dates - * - * Excel Function: - * DAYS(endDate, startDate) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Days::between() - * Use the between method in the DateTimeExcel\Days class instead - * - * @param array|DateTimeInterface|float|int|string $endDate Excel date serial value (float), - * PHP date timestamp (integer), PHP DateTime object, or a standard date string - * @param array|DateTimeInterface|float|int|string $startDate Excel date serial value (float), - * PHP date timestamp (integer), PHP DateTime object, or a standard date string - * - * @return array|int|string Number of days between start date and end date or an error - */ - public static function DAYS($endDate = 0, $startDate = 0) - { - return DateTimeExcel\Days::between($endDate, $startDate); - } - - /** - * DAYS360. - * - * Returns the number of days between two dates based on a 360-day year (twelve 30-day months), - * which is used in some accounting calculations. Use this function to help compute payments if - * your accounting system is based on twelve 30-day months. - * - * Excel Function: - * DAYS360(startDate,endDate[,method]) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Days360::between() - * Use the between method in the DateTimeExcel\Days360 class instead - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param array|bool $method US or European Method - * FALSE or omitted: U.S. (NASD) method. If the starting date is - * the last day of a month, it becomes equal to the 30th of the - * same month. If the ending date is the last day of a month and - * the starting date is earlier than the 30th of a month, the - * ending date becomes equal to the 1st of the next month; - * otherwise the ending date becomes equal to the 30th of the - * same month. - * TRUE: European method. Starting dates and ending dates that - * occur on the 31st of a month become equal to the 30th of the - * same month. - * - * @return array|int|string Number of days between start date and end date - */ - public static function DAYS360($startDate = 0, $endDate = 0, $method = false) - { - return DateTimeExcel\Days360::between($startDate, $endDate, $method); - } - - /** - * YEARFRAC. - * - * Calculates the fraction of the year represented by the number of whole days between two dates - * (the start_date and the end_date). - * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or - * obligations to assign to a specific term. - * - * Excel Function: - * YEARFRAC(startDate,endDate[,method]) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\YearFrac::fraction() - * Use the fraction method in the DateTimeExcel\YearFrac class instead - * - * See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html - * for description of algorithm used in Excel - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param array|int $method Method used for the calculation - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 - * - * @return array|float|string fraction of the year, or a string containing an error - */ - public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) - { - return DateTimeExcel\YearFrac::fraction($startDate, $endDate, $method); - } - - /** - * NETWORKDAYS. - * - * Returns the number of whole working days between start_date and end_date. Working days - * exclude weekends and any dates identified in holidays. - * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days - * worked during a specific term. - * - * Excel Function: - * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\NetworkDays::count() - * Use the count method in the DateTimeExcel\NetworkDays class instead - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $dateArgs - * - * @return array|int|string Interval between the dates - */ - public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs) - { - return DateTimeExcel\NetworkDays::count($startDate, $endDate, ...$dateArgs); - } - - /** - * WORKDAY. - * - * Returns the date that is the indicated number of working days before or after a date (the - * starting date). Working days exclude weekends and any dates identified as holidays. - * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected - * delivery times, or the number of days of work performed. - * - * Excel Function: - * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\WorkDay::date() - * Use the date method in the DateTimeExcel\WorkDay class instead - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $endDays The number of nonweekend and nonholiday days before or after - * startDate. A positive value for days yields a future date; a - * negative value yields a past date. - * @param mixed $dateArgs - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function WORKDAY($startDate, $endDays, ...$dateArgs) - { - return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs); - } - - /** - * DAYOFMONTH. - * - * Returns the day of the month, for a specified date. The day is given as an integer - * ranging from 1 to 31. - * - * Excel Function: - * DAY(dateValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\DateParts::day() - * Use the day method in the DateTimeExcel\DateParts class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Day of the month - */ - public static function DAYOFMONTH($dateValue = 1) - { - return DateTimeExcel\DateParts::day($dateValue); - } - - /** - * WEEKDAY. - * - * Returns the day of the week for a specified date. The day is given as an integer - * ranging from 0 to 7 (dependent on the requested style). - * - * Excel Function: - * WEEKDAY(dateValue[,style]) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Week::day() - * Use the day method in the DateTimeExcel\Week class instead - * - * @param float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $style A number that determines the type of return value - * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). - * 2 Numbers 1 (Monday) through 7 (Sunday). - * 3 Numbers 0 (Monday) through 6 (Sunday). - * - * @return array|int|string Day of the week value - */ - public static function WEEKDAY($dateValue = 1, $style = 1) - { - return DateTimeExcel\Week::day($dateValue, $style); - } - - /** - * STARTWEEK_SUNDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_SUNDAY instead - */ - const STARTWEEK_SUNDAY = 1; - - /** - * STARTWEEK_MONDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_MONDAY instead - */ - const STARTWEEK_MONDAY = 2; - - /** - * STARTWEEK_MONDAY_ALT. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_MONDAY_ALT instead - */ - const STARTWEEK_MONDAY_ALT = 11; - - /** - * STARTWEEK_TUESDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_TUESDAY instead - */ - const STARTWEEK_TUESDAY = 12; - - /** - * STARTWEEK_WEDNESDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_WEDNESDAY instead - */ - const STARTWEEK_WEDNESDAY = 13; - - /** - * STARTWEEK_THURSDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_THURSDAY instead - */ - const STARTWEEK_THURSDAY = 14; - - /** - * STARTWEEK_FRIDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_FRIDAY instead - */ - const STARTWEEK_FRIDAY = 15; - - /** - * STARTWEEK_SATURDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_SATURDAY instead - */ - const STARTWEEK_SATURDAY = 16; - - /** - * STARTWEEK_SUNDAY_ALT. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_SUNDAY_ALT instead - */ - const STARTWEEK_SUNDAY_ALT = 17; - - /** - * DOW_SUNDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_SUNDAY instead - */ - const DOW_SUNDAY = 1; - - /** - * DOW_MONDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_MONDAY instead - */ - const DOW_MONDAY = 2; - - /** - * DOW_TUESDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_TUESDAY instead - */ - const DOW_TUESDAY = 3; - - /** - * DOW_WEDNESDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_WEDNESDAY instead - */ - const DOW_WEDNESDAY = 4; - - /** - * DOW_THURSDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_THURSDAY instead - */ - const DOW_THURSDAY = 5; - - /** - * DOW_FRIDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_FRIDAY instead - */ - const DOW_FRIDAY = 6; - - /** - * DOW_SATURDAY. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\DOW_SATURDAY instead - */ - const DOW_SATURDAY = 7; - - /** - * STARTWEEK_MONDAY_ISO. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\STARTWEEK_MONDAY_ISO instead - */ - const STARTWEEK_MONDAY_ISO = 21; - - /** - * METHODARR. - * - * @Deprecated 1.18.0 - * - * @see Use DateTimeExcel\Constants\METHODARR instead - */ - const METHODARR = [ - self::STARTWEEK_SUNDAY => self::DOW_SUNDAY, - self::DOW_MONDAY, - self::STARTWEEK_MONDAY_ALT => self::DOW_MONDAY, - self::DOW_TUESDAY, - self::DOW_WEDNESDAY, - self::DOW_THURSDAY, - self::DOW_FRIDAY, - self::DOW_SATURDAY, - self::DOW_SUNDAY, - self::STARTWEEK_MONDAY_ISO => self::STARTWEEK_MONDAY_ISO, - ]; - - /** - * WEEKNUM. - * - * Returns the week of the year for a specified date. - * The WEEKNUM function considers the week containing January 1 to be the first week of the year. - * However, there is a European standard that defines the first week as the one with the majority - * of days (four or more) falling in the new year. This means that for years in which there are - * three days or less in the first week of January, the WEEKNUM function returns week numbers - * that are incorrect according to the European standard. - * - * Excel Function: - * WEEKNUM(dateValue[,style]) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Week::number(() - * Use the number method in the DateTimeExcel\Week class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $method Week begins on Sunday or Monday - * 1 or omitted Week begins on Sunday. - * 2 Week begins on Monday. - * 11 Week begins on Monday. - * 12 Week begins on Tuesday. - * 13 Week begins on Wednesday. - * 14 Week begins on Thursday. - * 15 Week begins on Friday. - * 16 Week begins on Saturday. - * 17 Week begins on Sunday. - * 21 ISO (Jan. 4 is week 1, begins on Monday). - * - * @return array|int|string Week Number - */ - public static function WEEKNUM($dateValue = 1, $method = self::STARTWEEK_SUNDAY) - { - return DateTimeExcel\Week::number($dateValue, $method); - } - - /** - * ISOWEEKNUM. - * - * Returns the ISO 8601 week number of the year for a specified date. - * - * Excel Function: - * ISOWEEKNUM(dateValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Week::isoWeekNumber() - * Use the isoWeekNumber method in the DateTimeExcel\Week class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Week Number - */ - public static function ISOWEEKNUM($dateValue = 1) - { - return DateTimeExcel\Week::isoWeekNumber($dateValue); - } - - /** - * MONTHOFYEAR. - * - * Returns the month of a date represented by a serial number. - * The month is given as an integer, ranging from 1 (January) to 12 (December). - * - * Excel Function: - * MONTH(dateValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\DateParts::month() - * Use the month method in the DateTimeExcel\DateParts class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Month of the year - */ - public static function MONTHOFYEAR($dateValue = 1) - { - return DateTimeExcel\DateParts::month($dateValue); - } - - /** - * YEAR. - * - * Returns the year corresponding to a date. - * The year is returned as an integer in the range 1900-9999. - * - * Excel Function: - * YEAR(dateValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\DateParts::year() - * Use the ear method in the DateTimeExcel\DateParts class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Year - */ - public static function YEAR($dateValue = 1) - { - return DateTimeExcel\DateParts::year($dateValue); - } - - /** - * HOUROFDAY. - * - * Returns the hour of a time value. - * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). - * - * Excel Function: - * HOUR(timeValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\TimeParts::hour() - * Use the hour method in the DateTimeExcel\TimeParts class instead - * - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard time string - * - * @return array|int|string Hour - */ - public static function HOUROFDAY($timeValue = 0) - { - return DateTimeExcel\TimeParts::hour($timeValue); - } - - /** - * MINUTE. - * - * Returns the minutes of a time value. - * The minute is given as an integer, ranging from 0 to 59. - * - * Excel Function: - * MINUTE(timeValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\TimeParts::minute() - * Use the minute method in the DateTimeExcel\TimeParts class instead - * - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard time string - * - * @return array|int|string Minute - */ - public static function MINUTE($timeValue = 0) - { - return DateTimeExcel\TimeParts::minute($timeValue); - } - - /** - * SECOND. - * - * Returns the seconds of a time value. - * The second is given as an integer in the range 0 (zero) to 59. - * - * Excel Function: - * SECOND(timeValue) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\TimeParts::second() - * Use the second method in the DateTimeExcel\TimeParts class instead - * - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard time string - * - * @return array|int|string Second - */ - public static function SECOND($timeValue = 0) - { - return DateTimeExcel\TimeParts::second($timeValue); - } - - /** - * EDATE. - * - * Returns the serial number that represents the date that is the indicated number of months - * before or after a specified date (the start_date). - * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month - * as the date of issue. - * - * Excel Function: - * EDATE(dateValue,adjustmentMonths) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Month::adjust() - * Use the adjust method in the DateTimeExcel\Edate class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $adjustmentMonths The number of months before or after start_date. - * A positive value for months yields a future date; - * a negative value yields a past date. - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function EDATE($dateValue = 1, $adjustmentMonths = 0) - { - return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths); - } - - /** - * EOMONTH. - * - * Returns the date value for the last day of the month that is the indicated number of months - * before or after start_date. - * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. - * - * Excel Function: - * EOMONTH(dateValue,adjustmentMonths) - * - * @Deprecated 1.18.0 - * - * @See DateTimeExcel\Month::lastDay() - * Use the lastDay method in the DateTimeExcel\EoMonth class instead - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $adjustmentMonths The number of months before or after start_date. - * A positive value for months yields a future date; - * a negative value yields a past date. - * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag - */ - public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) - { - return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths); - } -} diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php deleted file mode 100644 index d70b32d6ab..0000000000 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ /dev/null @@ -1,1446 +0,0 @@ - $complex->getReal(), - 'imaginary' => $complex->getImaginary(), - 'suffix' => $complex->getSuffix(), - ]; - } - - /** - * BESSELI. - * - * Returns the modified Bessel function In(x), which is equivalent to the Bessel function evaluated - * for purely imaginary arguments - * - * Excel Function: - * BESSELI(x,ord) - * - * @Deprecated 1.17.0 - * - * @see Use the BESSELI() method in the Engineering\BesselI class instead - * - * @param float $x The value at which to evaluate the function. - * If x is nonnumeric, BESSELI returns the #VALUE! error value. - * @param int $ord The order of the Bessel function. - * If ord is not an integer, it is truncated. - * If $ord is nonnumeric, BESSELI returns the #VALUE! error value. - * If $ord < 0, BESSELI returns the #NUM! error value. - * - * @return array|float|string Result, or a string containing an error - */ - public static function BESSELI($x, $ord) - { - return Engineering\BesselI::BESSELI($x, $ord); - } - - /** - * BESSELJ. - * - * Returns the Bessel function - * - * Excel Function: - * BESSELJ(x,ord) - * - * @Deprecated 1.17.0 - * - * @see Use the BESSELJ() method in the Engineering\BesselJ class instead - * - * @param float $x The value at which to evaluate the function. - * If x is nonnumeric, BESSELJ returns the #VALUE! error value. - * @param int $ord The order of the Bessel function. If n is not an integer, it is truncated. - * If $ord is nonnumeric, BESSELJ returns the #VALUE! error value. - * If $ord < 0, BESSELJ returns the #NUM! error value. - * - * @return array|float|string Result, or a string containing an error - */ - public static function BESSELJ($x, $ord) - { - return Engineering\BesselJ::BESSELJ($x, $ord); - } - - /** - * BESSELK. - * - * Returns the modified Bessel function Kn(x), which is equivalent to the Bessel functions evaluated - * for purely imaginary arguments. - * - * Excel Function: - * BESSELK(x,ord) - * - * @Deprecated 1.17.0 - * - * @see Use the BESSELK() method in the Engineering\BesselK class instead - * - * @param float $x The value at which to evaluate the function. - * If x is nonnumeric, BESSELK returns the #VALUE! error value. - * @param int $ord The order of the Bessel function. If n is not an integer, it is truncated. - * If $ord is nonnumeric, BESSELK returns the #VALUE! error value. - * If $ord < 0, BESSELK returns the #NUM! error value. - * - * @return array|float|string Result, or a string containing an error - */ - public static function BESSELK($x, $ord) - { - return Engineering\BesselK::BESSELK($x, $ord); - } - - /** - * BESSELY. - * - * Returns the Bessel function, which is also called the Weber function or the Neumann function. - * - * Excel Function: - * BESSELY(x,ord) - * - * @Deprecated 1.17.0 - * - * @see Use the BESSELY() method in the Engineering\BesselY class instead - * - * @param float $x The value at which to evaluate the function. - * If x is nonnumeric, BESSELY returns the #VALUE! error value. - * @param int $ord The order of the Bessel function. If n is not an integer, it is truncated. - * If $ord is nonnumeric, BESSELY returns the #VALUE! error value. - * If $ord < 0, BESSELY returns the #NUM! error value. - * - * @return array|float|string Result, or a string containing an error - */ - public static function BESSELY($x, $ord) - { - return Engineering\BesselY::BESSELY($x, $ord); - } - - /** - * BINTODEC. - * - * Return a binary value as decimal. - * - * Excel Function: - * BIN2DEC(x) - * - * @Deprecated 1.17.0 - * - * @see Use the toDecimal() method in the Engineering\ConvertBinary class instead - * - * @param mixed $x The binary number (as a string) that you want to convert. The number - * cannot contain more than 10 characters (10 bits). The most significant - * bit of number is the sign bit. The remaining 9 bits are magnitude bits. - * Negative numbers are represented using two's-complement notation. - * If number is not a valid binary number, or if number contains more than - * 10 characters (10 bits), BIN2DEC returns the #NUM! error value. - * - * @return array|string - */ - public static function BINTODEC($x) - { - return Engineering\ConvertBinary::toDecimal($x); - } - - /** - * BINTOHEX. - * - * Return a binary value as hex. - * - * Excel Function: - * BIN2HEX(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toHex() method in the Engineering\ConvertBinary class instead - * - * @param mixed $x The binary number (as a string) that you want to convert. The number - * cannot contain more than 10 characters (10 bits). The most significant - * bit of number is the sign bit. The remaining 9 bits are magnitude bits. - * Negative numbers are represented using two's-complement notation. - * If number is not a valid binary number, or if number contains more than - * 10 characters (10 bits), BIN2HEX returns the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, BIN2HEX uses the - * minimum number of characters necessary. Places is useful for padding the - * return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, BIN2HEX returns the #VALUE! error value. - * If places is negative, BIN2HEX returns the #NUM! error value. - * - * @return array|string - */ - public static function BINTOHEX($x, $places = null) - { - return Engineering\ConvertBinary::toHex($x, $places); - } - - /** - * BINTOOCT. - * - * Return a binary value as octal. - * - * Excel Function: - * BIN2OCT(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toOctal() method in the Engineering\ConvertBinary class instead - * - * @param mixed $x The binary number (as a string) that you want to convert. The number - * cannot contain more than 10 characters (10 bits). The most significant - * bit of number is the sign bit. The remaining 9 bits are magnitude bits. - * Negative numbers are represented using two's-complement notation. - * If number is not a valid binary number, or if number contains more than - * 10 characters (10 bits), BIN2OCT returns the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, BIN2OCT uses the - * minimum number of characters necessary. Places is useful for padding the - * return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, BIN2OCT returns the #VALUE! error value. - * If places is negative, BIN2OCT returns the #NUM! error value. - * - * @return array|string - */ - public static function BINTOOCT($x, $places = null) - { - return Engineering\ConvertBinary::toOctal($x, $places); - } - - /** - * DECTOBIN. - * - * Return a decimal value as binary. - * - * Excel Function: - * DEC2BIN(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toBinary() method in the Engineering\ConvertDecimal class instead - * - * @param mixed $x The decimal integer you want to convert. If number is negative, - * valid place values are ignored and DEC2BIN returns a 10-character - * (10-bit) binary number in which the most significant bit is the sign - * bit. The remaining 9 bits are magnitude bits. Negative numbers are - * represented using two's-complement notation. - * If number < -512 or if number > 511, DEC2BIN returns the #NUM! error - * value. - * If number is nonnumeric, DEC2BIN returns the #VALUE! error value. - * If DEC2BIN requires more than places characters, it returns the #NUM! - * error value. - * @param mixed $places The number of characters to use. If places is omitted, DEC2BIN uses - * the minimum number of characters necessary. Places is useful for - * padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, DEC2BIN returns the #VALUE! error value. - * If places is zero or negative, DEC2BIN returns the #NUM! error value. - * - * @return array|string - */ - public static function DECTOBIN($x, $places = null) - { - return Engineering\ConvertDecimal::toBinary($x, $places); - } - - /** - * DECTOHEX. - * - * Return a decimal value as hex. - * - * Excel Function: - * DEC2HEX(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toHex() method in the Engineering\ConvertDecimal class instead - * - * @param mixed $x The decimal integer you want to convert. If number is negative, - * places is ignored and DEC2HEX returns a 10-character (40-bit) - * hexadecimal number in which the most significant bit is the sign - * bit. The remaining 39 bits are magnitude bits. Negative numbers - * are represented using two's-complement notation. - * If number < -549,755,813,888 or if number > 549,755,813,887, - * DEC2HEX returns the #NUM! error value. - * If number is nonnumeric, DEC2HEX returns the #VALUE! error value. - * If DEC2HEX requires more than places characters, it returns the - * #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, DEC2HEX uses - * the minimum number of characters necessary. Places is useful for - * padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, DEC2HEX returns the #VALUE! error value. - * If places is zero or negative, DEC2HEX returns the #NUM! error value. - * - * @return array|string - */ - public static function DECTOHEX($x, $places = null) - { - return Engineering\ConvertDecimal::toHex($x, $places); - } - - /** - * DECTOOCT. - * - * Return an decimal value as octal. - * - * Excel Function: - * DEC2OCT(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toOctal() method in the Engineering\ConvertDecimal class instead - * - * @param mixed $x The decimal integer you want to convert. If number is negative, - * places is ignored and DEC2OCT returns a 10-character (30-bit) - * octal number in which the most significant bit is the sign bit. - * The remaining 29 bits are magnitude bits. Negative numbers are - * represented using two's-complement notation. - * If number < -536,870,912 or if number > 536,870,911, DEC2OCT - * returns the #NUM! error value. - * If number is nonnumeric, DEC2OCT returns the #VALUE! error value. - * If DEC2OCT requires more than places characters, it returns the - * #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, DEC2OCT uses - * the minimum number of characters necessary. Places is useful for - * padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, DEC2OCT returns the #VALUE! error value. - * If places is zero or negative, DEC2OCT returns the #NUM! error value. - * - * @return array|string - */ - public static function DECTOOCT($x, $places = null) - { - return Engineering\ConvertDecimal::toOctal($x, $places); - } - - /** - * HEXTOBIN. - * - * Return a hex value as binary. - * - * Excel Function: - * HEX2BIN(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toBinary() method in the Engineering\ConvertHex class instead - * - * @param mixed $x the hexadecimal number (as a string) that you want to convert. - * Number cannot contain more than 10 characters. - * The most significant bit of number is the sign bit (40th bit from the right). - * The remaining 9 bits are magnitude bits. - * Negative numbers are represented using two's-complement notation. - * If number is negative, HEX2BIN ignores places and returns a 10-character binary number. - * If number is negative, it cannot be less than FFFFFFFE00, - * and if number is positive, it cannot be greater than 1FF. - * If number is not a valid hexadecimal number, HEX2BIN returns the #NUM! error value. - * If HEX2BIN requires more than places characters, it returns the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, - * HEX2BIN uses the minimum number of characters necessary. Places - * is useful for padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, HEX2BIN returns the #VALUE! error value. - * If places is negative, HEX2BIN returns the #NUM! error value. - * - * @return array|string - */ - public static function HEXTOBIN($x, $places = null) - { - return Engineering\ConvertHex::toBinary($x, $places); - } - - /** - * HEXTODEC. - * - * Return a hex value as decimal. - * - * Excel Function: - * HEX2DEC(x) - * - * @Deprecated 1.17.0 - * - * @see Use the toDecimal() method in the Engineering\ConvertHex class instead - * - * @param mixed $x The hexadecimal number (as a string) that you want to convert. This number cannot - * contain more than 10 characters (40 bits). The most significant - * bit of number is the sign bit. The remaining 39 bits are magnitude - * bits. Negative numbers are represented using two's-complement - * notation. - * If number is not a valid hexadecimal number, HEX2DEC returns the - * #NUM! error value. - * - * @return array|string - */ - public static function HEXTODEC($x) - { - return Engineering\ConvertHex::toDecimal($x); - } - - /** - * HEXTOOCT. - * - * Return a hex value as octal. - * - * Excel Function: - * HEX2OCT(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toOctal() method in the Engineering\ConvertHex class instead - * - * @param mixed $x The hexadecimal number (as a string) that you want to convert. Number cannot - * contain more than 10 characters. The most significant bit of - * number is the sign bit. The remaining 39 bits are magnitude - * bits. Negative numbers are represented using two's-complement - * notation. - * If number is negative, HEX2OCT ignores places and returns a - * 10-character octal number. - * If number is negative, it cannot be less than FFE0000000, and - * if number is positive, it cannot be greater than 1FFFFFFF. - * If number is not a valid hexadecimal number, HEX2OCT returns - * the #NUM! error value. - * If HEX2OCT requires more than places characters, it returns - * the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, HEX2OCT - * uses the minimum number of characters necessary. Places is - * useful for padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, HEX2OCT returns the #VALUE! error - * value. - * If places is negative, HEX2OCT returns the #NUM! error value. - * - * @return array|string - */ - public static function HEXTOOCT($x, $places = null) - { - return Engineering\ConvertHex::toOctal($x, $places); - } - - /** - * OCTTOBIN. - * - * Return an octal value as binary. - * - * Excel Function: - * OCT2BIN(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toBinary() method in the Engineering\ConvertOctal class instead - * - * @param mixed $x The octal number you want to convert. Number may not - * contain more than 10 characters. The most significant - * bit of number is the sign bit. The remaining 29 bits - * are magnitude bits. Negative numbers are represented - * using two's-complement notation. - * If number is negative, OCT2BIN ignores places and returns - * a 10-character binary number. - * If number is negative, it cannot be less than 7777777000, - * and if number is positive, it cannot be greater than 777. - * If number is not a valid octal number, OCT2BIN returns - * the #NUM! error value. - * If OCT2BIN requires more than places characters, it - * returns the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, - * OCT2BIN uses the minimum number of characters necessary. - * Places is useful for padding the return value with - * leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, OCT2BIN returns the #VALUE! - * error value. - * If places is negative, OCT2BIN returns the #NUM! error - * value. - * - * @return array|string - */ - public static function OCTTOBIN($x, $places = null) - { - return Engineering\ConvertOctal::toBinary($x, $places); - } - - /** - * OCTTODEC. - * - * Return an octal value as decimal. - * - * Excel Function: - * OCT2DEC(x) - * - * @Deprecated 1.17.0 - * - * @see Use the toDecimal() method in the Engineering\ConvertOctal class instead - * - * @param mixed $x The octal number you want to convert. Number may not contain - * more than 10 octal characters (30 bits). The most significant - * bit of number is the sign bit. The remaining 29 bits are - * magnitude bits. Negative numbers are represented using - * two's-complement notation. - * If number is not a valid octal number, OCT2DEC returns the - * #NUM! error value. - * - * @return array|string - */ - public static function OCTTODEC($x) - { - return Engineering\ConvertOctal::toDecimal($x); - } - - /** - * OCTTOHEX. - * - * Return an octal value as hex. - * - * Excel Function: - * OCT2HEX(x[,places]) - * - * @Deprecated 1.17.0 - * - * @see Use the toHex() method in the Engineering\ConvertOctal class instead - * - * @param mixed $x The octal number you want to convert. Number may not contain - * more than 10 octal characters (30 bits). The most significant - * bit of number is the sign bit. The remaining 29 bits are - * magnitude bits. Negative numbers are represented using - * two's-complement notation. - * If number is negative, OCT2HEX ignores places and returns a - * 10-character hexadecimal number. - * If number is not a valid octal number, OCT2HEX returns the - * #NUM! error value. - * If OCT2HEX requires more than places characters, it returns - * the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, OCT2HEX - * uses the minimum number of characters necessary. Places is useful - * for padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, OCT2HEX returns the #VALUE! error value. - * If places is negative, OCT2HEX returns the #NUM! error value. - * - * @return array|string - */ - public static function OCTTOHEX($x, $places = null) - { - return Engineering\ConvertOctal::toHex($x, $places); - } - - /** - * COMPLEX. - * - * Converts real and imaginary coefficients into a complex number of the form x +/- yi or x +/- yj. - * - * Excel Function: - * COMPLEX(realNumber,imaginary[,suffix]) - * - * @Deprecated 1.18.0 - * - * @see Use the COMPLEX() method in the Engineering\Complex class instead - * - * @param array|float $realNumber the real coefficient of the complex number - * @param array|float $imaginary the imaginary coefficient of the complex number - * @param array|string $suffix The suffix for the imaginary component of the complex number. - * If omitted, the suffix is assumed to be "i". - * - * @return array|string - */ - public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') - { - return Engineering\Complex::COMPLEX($realNumber, $imaginary, $suffix); - } - - /** - * IMAGINARY. - * - * Returns the imaginary coefficient of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMAGINARY(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMAGINARY() method in the Engineering\Complex class instead - * - * @param string $complexNumber the complex number for which you want the imaginary - * coefficient - * - * @return array|float|string - */ - public static function IMAGINARY($complexNumber) - { - return Engineering\Complex::IMAGINARY($complexNumber); - } - - /** - * IMREAL. - * - * Returns the real coefficient of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMREAL(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMREAL() method in the Engineering\Complex class instead - * - * @param string $complexNumber the complex number for which you want the real coefficient - * - * @return array|float|string - */ - public static function IMREAL($complexNumber) - { - return Engineering\Complex::IMREAL($complexNumber); - } - - /** - * IMABS. - * - * Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMABS(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMABS() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the absolute value - * - * @return array|float|string - */ - public static function IMABS($complexNumber) - { - return ComplexFunctions::IMABS($complexNumber); - } - - /** - * IMARGUMENT. - * - * Returns the argument theta of a complex number, i.e. the angle in radians from the real - * axis to the representation of the number in polar coordinates. - * - * Excel Function: - * IMARGUMENT(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMARGUMENT() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the argument theta - * - * @return array|float|string - */ - public static function IMARGUMENT($complexNumber) - { - return ComplexFunctions::IMARGUMENT($complexNumber); - } - - /** - * IMCONJUGATE. - * - * Returns the complex conjugate of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCONJUGATE(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMARGUMENT() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the conjugate - * - * @return array|string - */ - public static function IMCONJUGATE($complexNumber) - { - return ComplexFunctions::IMCONJUGATE($complexNumber); - } - - /** - * IMCOS. - * - * Returns the cosine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCOS(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMCOS() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the cosine - * - * @return array|float|string - */ - public static function IMCOS($complexNumber) - { - return ComplexFunctions::IMCOS($complexNumber); - } - - /** - * IMCOSH. - * - * Returns the hyperbolic cosine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCOSH(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMCOSH() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the hyperbolic cosine - * - * @return array|float|string - */ - public static function IMCOSH($complexNumber) - { - return ComplexFunctions::IMCOSH($complexNumber); - } - - /** - * IMCOT. - * - * Returns the cotangent of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCOT(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMCOT() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the cotangent - * - * @return array|float|string - */ - public static function IMCOT($complexNumber) - { - return ComplexFunctions::IMCOT($complexNumber); - } - - /** - * IMCSC. - * - * Returns the cosecant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCSC(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMCSC() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the cosecant - * - * @return array|float|string - */ - public static function IMCSC($complexNumber) - { - return ComplexFunctions::IMCSC($complexNumber); - } - - /** - * IMCSCH. - * - * Returns the hyperbolic cosecant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCSCH(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMCSCH() method in the Engineering\ComplexFunctions class instead - * - * @param array|string $complexNumber the complex number for which you want the hyperbolic cosecant - * - * @return array|float|string - */ - public static function IMCSCH($complexNumber) - { - return ComplexFunctions::IMCSCH($complexNumber); - } - - /** - * IMSIN. - * - * Returns the sine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSIN(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSIN() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the sine - * - * @return array|float|string - */ - public static function IMSIN($complexNumber) - { - return ComplexFunctions::IMSIN($complexNumber); - } - - /** - * IMSINH. - * - * Returns the hyperbolic sine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSINH(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSINH() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the hyperbolic sine - * - * @return array|float|string - */ - public static function IMSINH($complexNumber) - { - return ComplexFunctions::IMSINH($complexNumber); - } - - /** - * IMSEC. - * - * Returns the secant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSEC(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSEC() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the secant - * - * @return array|float|string - */ - public static function IMSEC($complexNumber) - { - return ComplexFunctions::IMSEC($complexNumber); - } - - /** - * IMSECH. - * - * Returns the hyperbolic secant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSECH(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSECH() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the hyperbolic secant - * - * @return array|float|string - */ - public static function IMSECH($complexNumber) - { - return ComplexFunctions::IMSECH($complexNumber); - } - - /** - * IMTAN. - * - * Returns the tangent of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMTAN(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMTAN() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the tangent - * - * @return array|float|string - */ - public static function IMTAN($complexNumber) - { - return ComplexFunctions::IMTAN($complexNumber); - } - - /** - * IMSQRT. - * - * Returns the square root of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSQRT(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSQRT() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the square root - * - * @return array|string - */ - public static function IMSQRT($complexNumber) - { - return ComplexFunctions::IMSQRT($complexNumber); - } - - /** - * IMLN. - * - * Returns the natural logarithm of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMLN(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMLN() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the natural logarithm - * - * @return array|string - */ - public static function IMLN($complexNumber) - { - return ComplexFunctions::IMLN($complexNumber); - } - - /** - * IMLOG10. - * - * Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMLOG10(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMLOG10() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the common logarithm - * - * @return array|string - */ - public static function IMLOG10($complexNumber) - { - return ComplexFunctions::IMLOG10($complexNumber); - } - - /** - * IMLOG2. - * - * Returns the base-2 logarithm of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMLOG2(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMLOG2() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the base-2 logarithm - * - * @return array|string - */ - public static function IMLOG2($complexNumber) - { - return ComplexFunctions::IMLOG2($complexNumber); - } - - /** - * IMEXP. - * - * Returns the exponential of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMEXP(complexNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMEXP() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number for which you want the exponential - * - * @return array|string - */ - public static function IMEXP($complexNumber) - { - return ComplexFunctions::IMEXP($complexNumber); - } - - /** - * IMPOWER. - * - * Returns a complex number in x + yi or x + yj text format raised to a power. - * - * Excel Function: - * IMPOWER(complexNumber,realNumber) - * - * @Deprecated 1.18.0 - * - * @see Use the IMPOWER() method in the Engineering\ComplexFunctions class instead - * - * @param string $complexNumber the complex number you want to raise to a power - * @param float $realNumber the power to which you want to raise the complex number - * - * @return array|string - */ - public static function IMPOWER($complexNumber, $realNumber) - { - return ComplexFunctions::IMPOWER($complexNumber, $realNumber); - } - - /** - * IMDIV. - * - * Returns the quotient of two complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMDIV(complexDividend,complexDivisor) - * - * @Deprecated 1.18.0 - * - * @see Use the IMDIV() method in the Engineering\ComplexOperations class instead - * - * @param string $complexDividend the complex numerator or dividend - * @param string $complexDivisor the complex denominator or divisor - * - * @return array|string - */ - public static function IMDIV($complexDividend, $complexDivisor) - { - return ComplexOperations::IMDIV($complexDividend, $complexDivisor); - } - - /** - * IMSUB. - * - * Returns the difference of two complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMSUB(complexNumber1,complexNumber2) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSUB() method in the Engineering\ComplexOperations class instead - * - * @param string $complexNumber1 the complex number from which to subtract complexNumber2 - * @param string $complexNumber2 the complex number to subtract from complexNumber1 - * - * @return array|string - */ - public static function IMSUB($complexNumber1, $complexNumber2) - { - return ComplexOperations::IMSUB($complexNumber1, $complexNumber2); - } - - /** - * IMSUM. - * - * Returns the sum of two or more complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMSUM(complexNumber[,complexNumber[,...]]) - * - * @Deprecated 1.18.0 - * - * @see Use the IMSUM() method in the Engineering\ComplexOperations class instead - * - * @param string ...$complexNumbers Series of complex numbers to add - * - * @return string - */ - public static function IMSUM(...$complexNumbers) - { - return ComplexOperations::IMSUM(...$complexNumbers); - } - - /** - * IMPRODUCT. - * - * Returns the product of two or more complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMPRODUCT(complexNumber[,complexNumber[,...]]) - * - * @Deprecated 1.18.0 - * - * @see Use the IMPRODUCT() method in the Engineering\ComplexOperations class instead - * - * @param string ...$complexNumbers Series of complex numbers to multiply - * - * @return string - */ - public static function IMPRODUCT(...$complexNumbers) - { - return ComplexOperations::IMPRODUCT(...$complexNumbers); - } - - /** - * DELTA. - * - * Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise. - * Use this function to filter a set of values. For example, by summing several DELTA - * functions you calculate the count of equal pairs. This function is also known as the - * Kronecker Delta function. - * - * Excel Function: - * DELTA(a[,b]) - * - * @Deprecated 1.17.0 - * - * @see Use the DELTA() method in the Engineering\Compare class instead - * - * @param float $a the first number - * @param float $b The second number. If omitted, b is assumed to be zero. - * - * @return array|int|string (string in the event of an error) - */ - public static function DELTA($a, $b = 0) - { - return Engineering\Compare::DELTA($a, $b); - } - - /** - * GESTEP. - * - * Excel Function: - * GESTEP(number[,step]) - * - * Returns 1 if number >= step; returns 0 (zero) otherwise - * Use this function to filter a set of values. For example, by summing several GESTEP - * functions you calculate the count of values that exceed a threshold. - * - * @Deprecated 1.17.0 - * - * @see Use the GESTEP() method in the Engineering\Compare class instead - * - * @param float $number the value to test against step - * @param float $step The threshold value. If you omit a value for step, GESTEP uses zero. - * - * @return array|int|string (string in the event of an error) - */ - public static function GESTEP($number, $step = 0) - { - return Engineering\Compare::GESTEP($number, $step); - } - - /** - * BITAND. - * - * Returns the bitwise AND of two integer values. - * - * Excel Function: - * BITAND(number1, number2) - * - * @Deprecated 1.17.0 - * - * @see Use the BITAND() method in the Engineering\BitWise class instead - * - * @param int $number1 - * @param int $number2 - * - * @return array|int|string - */ - public static function BITAND($number1, $number2) - { - return Engineering\BitWise::BITAND($number1, $number2); - } - - /** - * BITOR. - * - * Returns the bitwise OR of two integer values. - * - * Excel Function: - * BITOR(number1, number2) - * - * @Deprecated 1.17.0 - * - * @see Use the BITOR() method in the Engineering\BitWise class instead - * - * @param int $number1 - * @param int $number2 - * - * @return array|int|string - */ - public static function BITOR($number1, $number2) - { - return Engineering\BitWise::BITOR($number1, $number2); - } - - /** - * BITXOR. - * - * Returns the bitwise XOR of two integer values. - * - * Excel Function: - * BITXOR(number1, number2) - * - * @Deprecated 1.17.0 - * - * @see Use the BITXOR() method in the Engineering\BitWise class instead - * - * @param int $number1 - * @param int $number2 - * - * @return array|int|string - */ - public static function BITXOR($number1, $number2) - { - return Engineering\BitWise::BITXOR($number1, $number2); - } - - /** - * BITLSHIFT. - * - * Returns the number value shifted left by shift_amount bits. - * - * Excel Function: - * BITLSHIFT(number, shift_amount) - * - * @Deprecated 1.17.0 - * - * @see Use the BITLSHIFT() method in the Engineering\BitWise class instead - * - * @param int $number - * @param int $shiftAmount - * - * @return array|float|int|string - */ - public static function BITLSHIFT($number, $shiftAmount) - { - return Engineering\BitWise::BITLSHIFT($number, $shiftAmount); - } - - /** - * BITRSHIFT. - * - * Returns the number value shifted right by shift_amount bits. - * - * Excel Function: - * BITRSHIFT(number, shift_amount) - * - * @Deprecated 1.17.0 - * - * @see Use the BITRSHIFT() method in the Engineering\BitWise class instead - * - * @param int $number - * @param int $shiftAmount - * - * @return array|float|int|string - */ - public static function BITRSHIFT($number, $shiftAmount) - { - return Engineering\BitWise::BITRSHIFT($number, $shiftAmount); - } - - /** - * ERF. - * - * Returns the error function integrated between the lower and upper bound arguments. - * - * Note: In Excel 2007 or earlier, if you input a negative value for the upper or lower bound arguments, - * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was - * improved, so that it can now calculate the function for both positive and negative ranges. - * PhpSpreadsheet follows Excel 2010 behaviour, and accepts negative arguments. - * - * Excel Function: - * ERF(lower[,upper]) - * - * @Deprecated 1.17.0 - * - * @see Use the ERF() method in the Engineering\Erf class instead - * - * @param float $lower lower bound for integrating ERF - * @param float $upper upper bound for integrating ERF. - * If omitted, ERF integrates between zero and lower_limit - * - * @return array|float|string - */ - public static function ERF($lower, $upper = null) - { - return Engineering\Erf::ERF($lower, $upper); - } - - /** - * ERFPRECISE. - * - * Returns the error function integrated between the lower and upper bound arguments. - * - * Excel Function: - * ERF.PRECISE(limit) - * - * @Deprecated 1.17.0 - * - * @see Use the ERFPRECISE() method in the Engineering\Erf class instead - * - * @param float $limit bound for integrating ERF - * - * @return array|float|string - */ - public static function ERFPRECISE($limit) - { - return Engineering\Erf::ERFPRECISE($limit); - } - - /** - * ERFC. - * - * Returns the complementary ERF function integrated between x and infinity - * - * Note: In Excel 2007 or earlier, if you input a negative value for the lower bound argument, - * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was - * improved, so that it can now calculate the function for both positive and negative x values. - * PhpSpreadsheet follows Excel 2010 behaviour, and accepts nagative arguments. - * - * Excel Function: - * ERFC(x) - * - * @Deprecated 1.17.0 - * - * @see Use the ERFC() method in the Engineering\ErfC class instead - * - * @param float $x The lower bound for integrating ERFC - * - * @return array|float|string - */ - public static function ERFC($x) - { - return Engineering\ErfC::ERFC($x); - } - - /** - * getConversionGroups - * Returns a list of the different conversion groups for UOM conversions. - * - * @Deprecated 1.16.0 - * - * @see Use the getConversionCategories() method in the Engineering\ConvertUOM class instead - * - * @return array - */ - public static function getConversionGroups() - { - return Engineering\ConvertUOM::getConversionCategories(); - } - - /** - * getConversionGroupUnits - * Returns an array of units of measure, for a specified conversion group, or for all groups. - * - * @Deprecated 1.16.0 - * - * @see Use the getConversionCategoryUnits() method in the ConvertUOM class instead - * - * @param null|mixed $category - * - * @return array - */ - public static function getConversionGroupUnits($category = null) - { - return Engineering\ConvertUOM::getConversionCategoryUnits($category); - } - - /** - * getConversionGroupUnitDetails. - * - * @Deprecated 1.16.0 - * - * @see Use the getConversionCategoryUnitDetails() method in the ConvertUOM class instead - * - * @param null|mixed $category - * - * @return array - */ - public static function getConversionGroupUnitDetails($category = null) - { - return Engineering\ConvertUOM::getConversionCategoryUnitDetails($category); - } - - /** - * getConversionMultipliers - * Returns an array of the Multiplier prefixes that can be used with Units of Measure in CONVERTUOM(). - * - * @Deprecated 1.16.0 - * - * @see Use the getConversionMultipliers() method in the ConvertUOM class instead - * - * @return mixed[] - */ - public static function getConversionMultipliers() - { - return Engineering\ConvertUOM::getConversionMultipliers(); - } - - /** - * getBinaryConversionMultipliers. - * - * Returns an array of the additional Multiplier prefixes that can be used with Information Units of Measure - * in CONVERTUOM(). - * - * @Deprecated 1.16.0 - * - * @see Use the getBinaryConversionMultipliers() method in the ConvertUOM class instead - * - * @return mixed[] - */ - public static function getBinaryConversionMultipliers() - { - return Engineering\ConvertUOM::getBinaryConversionMultipliers(); - } - - /** - * CONVERTUOM. - * - * Converts a number from one measurement system to another. - * For example, CONVERT can translate a table of distances in miles to a table of distances - * in kilometers. - * - * Excel Function: - * CONVERT(value,fromUOM,toUOM) - * - * @Deprecated 1.16.0 - * - * @see Use the CONVERT() method in the ConvertUOM class instead - * - * @param float|int $value the value in fromUOM to convert - * @param string $fromUOM the units for value - * @param string $toUOM the units for the result - * - * @return array|float|string - */ - public static function CONVERTUOM($value, $fromUOM, $toUOM) - { - return Engineering\ConvertUOM::CONVERT($value, $fromUOM, $toUOM); - } -} diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php index 2afb52bdb9..9b55957e06 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php @@ -35,7 +35,7 @@ class BesselI * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BESSELI($x, $ord) + public static function besselI($x, $ord) { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php index e23b0157d1..28d012a4fe 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php @@ -34,7 +34,7 @@ class BesselJ * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BESSELJ($x, $ord) + public static function besselJ($x, $ord) { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php index 2d21e7529a..6a0add4595 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php @@ -33,7 +33,7 @@ class BesselK * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BESSELK($x, $ord) + public static function besselK($x, $ord) { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); @@ -75,7 +75,7 @@ private static function calculate(float $x, int $ord): float */ private static function callBesselI(float $x, int $ord): float { - $rslt = BesselI::BESSELI($x, $ord); + $rslt = BesselI::besselI($x, $ord); if (!is_float($rslt)) { throw new Exception('Unexpected array or string'); } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php index 31d9694a70..263a06e1ac 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php @@ -31,7 +31,7 @@ class BesselY * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BESSELY($x, $ord) + public static function besselY($x, $ord) { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); @@ -73,7 +73,7 @@ private static function calculate(float $x, int $ord): float */ private static function callBesselJ(float $x, int $ord): float { - $rslt = BesselJ::BESSELJ($x, $ord); + $rslt = BesselJ::besselJ($x, $ord); if (!is_float($rslt)) { throw new Exception('Unexpected array or string'); } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php index adeb1b5535..27346bfbb6 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php @@ -40,7 +40,7 @@ private static function splitNumber($number): array * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BITAND($number1, $number2) + public static function and($number1, $number2) { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -75,7 +75,7 @@ public static function BITAND($number1, $number2) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BITOR($number1, $number2) + public static function or($number1, $number2) { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -111,7 +111,7 @@ public static function BITOR($number1, $number2) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BITXOR($number1, $number2) + public static function xor($number1, $number2) { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -147,7 +147,7 @@ public static function BITXOR($number1, $number2) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BITLSHIFT($number, $shiftAmount) + public static function leftShift($number, $shiftAmount) { if (is_array($number) || is_array($shiftAmount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $shiftAmount); @@ -185,7 +185,7 @@ public static function BITLSHIFT($number, $shiftAmount) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function BITRSHIFT($number, $shiftAmount) + public static function rightShift($number, $shiftAmount) { if (is_array($number) || is_array($shiftAmount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $shiftAmount); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php index 6aaf1faa5b..0fd6d3f3bd 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php @@ -29,7 +29,7 @@ class Compare * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function DELTA($a, $b = 0.0) + public static function delta($a, $b = 0.0) { if (is_array($a) || is_array($b)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $a, $b); @@ -64,7 +64,7 @@ public static function DELTA($a, $b = 0.0) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function GESTEP($number, $step = 0.0) + public static function geStep($number, $step = 0.0) { if (is_array($number) || is_array($step)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $step); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Complex.php b/src/PhpSpreadsheet/Calculation/Engineering/Complex.php index 691de8b704..d823d79334 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Complex.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Complex.php @@ -32,7 +32,7 @@ class Complex * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') + public static function complex($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') { if (is_array($realNumber) || is_array($imaginary) || is_array($suffix)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $realNumber, $imaginary, $suffix); @@ -74,7 +74,7 @@ public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMAGINARY($complexNumber) + public static function imaginary($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -104,7 +104,7 @@ public static function IMAGINARY($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMREAL($complexNumber) + public static function real($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php b/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php index 28a27a0317..2d5c610155 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php @@ -26,7 +26,7 @@ class ComplexFunctions * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMABS($complexNumber) + public static function absolute($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -57,7 +57,7 @@ public static function IMABS($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMARGUMENT($complexNumber) + public static function argument($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -91,7 +91,7 @@ public static function IMARGUMENT($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMCONJUGATE($complexNumber) + public static function conjugate($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -121,7 +121,7 @@ public static function IMCONJUGATE($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMCOS($complexNumber) + public static function cos($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -151,7 +151,7 @@ public static function IMCOS($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMCOSH($complexNumber) + public static function cosh($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -181,7 +181,7 @@ public static function IMCOSH($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMCOT($complexNumber) + public static function cot($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -211,7 +211,7 @@ public static function IMCOT($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMCSC($complexNumber) + public static function csc($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -241,7 +241,7 @@ public static function IMCSC($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMCSCH($complexNumber) + public static function csch($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -271,7 +271,7 @@ public static function IMCSCH($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMSIN($complexNumber) + public static function sin($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -301,7 +301,7 @@ public static function IMSIN($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMSINH($complexNumber) + public static function sinh($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -331,7 +331,7 @@ public static function IMSINH($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMSEC($complexNumber) + public static function sec($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -361,7 +361,7 @@ public static function IMSEC($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMSECH($complexNumber) + public static function sech($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -391,7 +391,7 @@ public static function IMSECH($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMTAN($complexNumber) + public static function tan($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -421,7 +421,7 @@ public static function IMTAN($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMSQRT($complexNumber) + public static function sqrt($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -433,7 +433,7 @@ public static function IMSQRT($complexNumber) return ExcelError::NAN(); } - $theta = self::IMARGUMENT($complexNumber); + $theta = self::argument($complexNumber); if ($theta === ExcelError::DIV0()) { return '0'; } @@ -456,7 +456,7 @@ public static function IMSQRT($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMLN($complexNumber) + public static function ln($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -490,7 +490,7 @@ public static function IMLN($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMLOG10($complexNumber) + public static function log10($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -524,7 +524,7 @@ public static function IMLOG10($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMLOG2($complexNumber) + public static function log2($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -558,7 +558,7 @@ public static function IMLOG2($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMEXP($complexNumber) + public static function exp($complexNumber) { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -590,7 +590,7 @@ public static function IMEXP($complexNumber) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMPOWER($complexNumber, $realNumber) + public static function power($complexNumber, $realNumber) { if (is_array($complexNumber) || is_array($realNumber)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexNumber, $realNumber); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php b/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php index e525b4b9aa..2edcc7ffd9 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php @@ -29,7 +29,7 @@ class ComplexOperations * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMDIV($complexDividend, $complexDivisor) + public static function div($complexDividend, $complexDivisor) { if (is_array($complexDividend) || is_array($complexDivisor)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexDividend, $complexDivisor); @@ -59,7 +59,7 @@ public static function IMDIV($complexDividend, $complexDivisor) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function IMSUB($complexNumber1, $complexNumber2) + public static function sub($complexNumber1, $complexNumber2) { if (is_array($complexNumber1) || is_array($complexNumber2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexNumber1, $complexNumber2); @@ -84,7 +84,7 @@ public static function IMSUB($complexNumber1, $complexNumber2) * * @return string */ - public static function IMSUM(...$complexNumbers) + public static function sum(...$complexNumbers) { // Return value $returnValue = new ComplexObject(0.0); @@ -114,7 +114,7 @@ public static function IMSUM(...$complexNumbers) * * @return string */ - public static function IMPRODUCT(...$complexNumbers) + public static function product(...$complexNumbers) { // Return value $returnValue = new ComplexObject(1.0); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index b7c298dbc3..af23a46b69 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -533,7 +533,7 @@ public static function getBinaryConversionMultipliers() * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function CONVERT($value, $fromUOM, $toUOM) + public static function convert($value, $fromUOM, $toUOM) { if (is_array($value) || is_array($fromUOM) || is_array($toUOM)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $fromUOM, $toUOM); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php index 6254d4776c..2b92c3b967 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php @@ -35,7 +35,7 @@ class Erf * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function ERF($lower, $upper = null) + public static function erf($lower, $upper = null) { if (is_array($lower) || is_array($upper)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $lower, $upper); @@ -68,13 +68,13 @@ public static function ERF($lower, $upper = null) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function ERFPRECISE($limit) + public static function precise($limit) { if (is_array($limit)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $limit); } - return self::ERF($limit); + return self::erf($limit); } // @@ -83,7 +83,7 @@ public static function ERFPRECISE($limit) public static function erfValue($value) { if (abs($value) > 2.2) { - return 1 - ErfC::ERFC($value); + return 1 - ErfC::complementary($value); } $sum = $term = $value; $xsqr = ($value * $value); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php index 7b023bee59..d326249d29 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php @@ -30,7 +30,7 @@ class ErfC * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function ERFC($value) + public static function complementary($value) { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php deleted file mode 100644 index 4215a5163d..0000000000 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ /dev/null @@ -1,1430 +0,0 @@ -getMessage(); } - $dsc = Coupons::COUPDAYSNC($settlement, $maturity, $frequency, $basis); - $e = Coupons::COUPDAYS($settlement, $maturity, $frequency, $basis); - $n = Coupons::COUPNUM($settlement, $maturity, $frequency, $basis); - $a = Coupons::COUPDAYBS($settlement, $maturity, $frequency, $basis); + $dsc = Coupons::daysToNextCoupon($settlement, $maturity, $frequency, $basis); + $e = Coupons::days($settlement, $maturity, $frequency, $basis); + $n = Coupons::numberPayable($settlement, $maturity, $frequency, $basis); + $a = Coupons::daysBeforeSettlement($settlement, $maturity, $frequency, $basis); $baseYF = 1.0 + ($yield / $frequency); $rfp = 100 * ($rate / $frequency); diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 172f202222..482ffba556 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -125,7 +125,7 @@ public static function getReturnDateType() * * @return string #Not Yet Implemented */ - public static function DUMMY() + public static function dummy() { return '#Not Yet Implemented'; } @@ -201,365 +201,6 @@ private static function operandSpecialHandling($operand) return $operand; } - /** - * NULL. - * - * Returns the error value #NULL! - * - * @Deprecated 1.23.0 - * - * @return string #NULL! - * - *@see Information\ExcelError::null() - * Use the null() method in the Information\Error class instead - */ - public static function null() - { - return Information\ExcelError::null(); - } - - /** - * NaN. - * - * Returns the error value #NUM! - * - * @Deprecated 1.23.0 - * - * @return string #NUM! - * - * @see Information\ExcelError::NAN() - * Use the NAN() method in the Information\Error class instead - */ - public static function NAN() - { - return Information\ExcelError::NAN(); - } - - /** - * REF. - * - * Returns the error value #REF! - * - * @Deprecated 1.23.0 - * - * @return string #REF! - * - * @see Information\ExcelError::REF() - * Use the REF() method in the Information\Error class instead - */ - public static function REF() - { - return Information\ExcelError::REF(); - } - - /** - * NA. - * - * Excel Function: - * =NA() - * - * Returns the error value #N/A - * #N/A is the error value that means "no value is available." - * - * @Deprecated 1.23.0 - * - * @return string #N/A! - * - * @see Information\ExcelError::NA() - * Use the NA() method in the Information\Error class instead - */ - public static function NA() - { - return Information\ExcelError::NA(); - } - - /** - * VALUE. - * - * Returns the error value #VALUE! - * - * @Deprecated 1.23.0 - * - * @return string #VALUE! - * - * @see Information\ExcelError::VALUE() - * Use the VALUE() method in the Information\Error class instead - */ - public static function VALUE() - { - return Information\ExcelError::VALUE(); - } - - /** - * NAME. - * - * Returns the error value #NAME? - * - * @Deprecated 1.23.0 - * - * @return string #NAME? - * - * @see Information\ExcelError::NAME() - * Use the NAME() method in the Information\Error class instead - */ - public static function NAME() - { - return Information\ExcelError::NAME(); - } - - /** - * DIV0. - * - * @Deprecated 1.23.0 - * - * @return string #Not Yet Implemented - * - *@see Information\ExcelError::DIV0() - * Use the DIV0() method in the Information\Error class instead - */ - public static function DIV0() - { - return Information\ExcelError::DIV0(); - } - - /** - * ERROR_TYPE. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @return array|int|string - * - * @see Information\ExcelError::type() - * Use the type() method in the Information\Error class instead - */ - public static function errorType($value = '') - { - return Information\ExcelError::type($value); - } - - /** - * IS_BLANK. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isBlank() - * Use the isBlank() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isBlank($value = null) - { - return Information\Value::isBlank($value); - } - - /** - * IS_ERR. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isErr() - * Use the isErr() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isErr($value = '') - { - return Information\ErrorValue::isErr($value); - } - - /** - * IS_ERROR. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isError() - * Use the isError() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isError($value = '') - { - return Information\ErrorValue::isError($value); - } - - /** - * IS_NA. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isNa() - * Use the isNa() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isNa($value = '') - { - return Information\ErrorValue::isNa($value); - } - - /** - * IS_EVEN. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isEven() - * Use the isEven() method in the Information\Value class instead - * - * @return array|bool|string - */ - public static function isEven($value = null) - { - return Information\Value::isEven($value); - } - - /** - * IS_ODD. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isOdd() - * Use the isOdd() method in the Information\Value class instead - * - * @return array|bool|string - */ - public static function isOdd($value = null) - { - return Information\Value::isOdd($value); - } - - /** - * IS_NUMBER. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isNumber() - * Use the isNumber() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isNumber($value = null) - { - return Information\Value::isNumber($value); - } - - /** - * IS_LOGICAL. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isLogical() - * Use the isLogical() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isLogical($value = null) - { - return Information\Value::isLogical($value); - } - - /** - * IS_TEXT. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isText() - * Use the isText() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isText($value = null) - { - return Information\Value::isText($value); - } - - /** - * IS_NONTEXT. - * - * @param mixed $value Value to check - * - * @Deprecated 1.23.0 - * - * @see Information\Value::isNonText() - * Use the isNonText() method in the Information\Value class instead - * - * @return array|bool - */ - public static function isNonText($value = null) - { - return Information\Value::isNonText($value); - } - - /** - * N. - * - * Returns a value converted to a number - * - * @Deprecated 1.23.0 - * - * @see Information\Value::asNumber() - * Use the asNumber() method in the Information\Value class instead - * - * @param null|mixed $value The value you want converted - * - * @return number|string N converts values listed in the following table - * If value is or refers to N returns - * A number That number - * A date The serial number of that date - * TRUE 1 - * FALSE 0 - * An error value The error value - * Anything else 0 - */ - public static function n($value = null) - { - return Information\Value::asNumber($value); - } - - /** - * TYPE. - * - * Returns a number that identifies the type of a value - * - * @Deprecated 1.23.0 - * - * @see Information\Value::type() - * Use the type() method in the Information\Value class instead - * - * @param null|mixed $value The value you want tested - * - * @return number N converts values listed in the following table - * If value is or refers to N returns - * A number 1 - * Text 2 - * Logical Value 4 - * An error value 16 - * Array or Matrix 64 - */ - public static function TYPE($value = null) - { - return Information\Value::type($value); - } - /** * Convert a multi-dimensional array to a simple 1-dimensional array. * @@ -656,6 +297,51 @@ public static function flattenSingleValue($value = '') return $value; } + protected static function resizeMatrixColumns(array $matrix, int $columns): array + { + $matrix = array_map( + function ($row) use ($columns) { + if (count($row) > $columns) { + // remove extra columns + $row = array_slice($row, 0, $columns); + } elseif (count($row) < $columns) { + // add new empty columns + $row = array_merge($row, array_fill(0, $columns - count($row), null)); + } + + return $row; + }, + $matrix + ); + + return $matrix; + } + + protected static function resizeMatrixRows(array $matrix, int $columns, int $rows): array + { + if (count($matrix) > $rows) { + // remove extra rows + return array_slice($matrix, 0, $rows); + } + + if (count($matrix) < $rows) { + // add new empty rows + for ($row = count($matrix); $row < $rows; ++$row) { + $matrix[] = array_fill(0, $columns - 1, null); + } + } + + return $matrix; + } + + public static function resizeMatrix(array $matrix, int $columns, int $rows): array + { + $matrix = self::resizeMatrixRows($matrix, $columns, $rows); + $matrix = self::resizeMatrixColumns($matrix, $columns); + + return $matrix; + } + /** * ISFORMULA. * diff --git a/src/PhpSpreadsheet/Calculation/Internal/ExcelArrayPseudoFunctions.php b/src/PhpSpreadsheet/Calculation/Internal/ExcelArrayPseudoFunctions.php new file mode 100644 index 0000000000..be77cf1671 --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Internal/ExcelArrayPseudoFunctions.php @@ -0,0 +1,91 @@ +getWorksheet(); + + [$referenceWorksheetName, $referenceCellCoordinate] = Worksheet::extractSheetTitle($cellReference, true); + $referenceCell = ($referenceWorksheetName === '') + ? $worksheet->getCell($referenceCellCoordinate) + : $worksheet->getParent() + ->getSheetByName($referenceWorksheetName) + ->getCell($referenceCellCoordinate); + + $result = $referenceCell->getCalculatedValue(); + + return [[$result]]; + } + + public static function anchorArray(string $cellReference, Cell $cell): array + { + $coordinate = $cell->getCoordinate(); + $worksheet = $cell->getWorksheet(); +// $value = $cell->getValue(); + + [$referenceWorksheetName, $referenceCellCoordinate] = Worksheet::extractSheetTitle($cellReference, true); + $referenceCell = ($referenceWorksheetName === '') + ? $worksheet->getCell($referenceCellCoordinate) + : $worksheet->getParent() + ->getSheetByName($referenceWorksheetName) + ->getCell($referenceCellCoordinate); + + // We should always use the sizing for the array formula range from the referenced cell formula + $referenceRange = null; + if ($referenceCell->isFormula() && $referenceCell->isArrayFormula()) { + $referenceRange = $referenceCell->arrayFormulaRange(); + } + + $calcEngine = Calculation::getInstance($worksheet->getParent()); + $result = $calcEngine->calculateCellValue($referenceCell, true, false); + if (!is_array($result)) { + $result = [[$result]]; + } + + // Ensure that our array result dimensions match the specified array formula range dimensions, + // from the referenced cell, expanding or shrinking it as necessary. + $result = Functions::resizeMatrix( + $result, + ...Coordinate::rangeDimension($referenceRange ?? $coordinate) + ); + + // Set the result for our target cell (with spillage) + // But if we do write it, we get problems with #SPILL! Errors if the spreadsheet is saved + // TODO How are we going to identify and handle a #SPILL! or a #CALC! error? +// IOFactory::setLoading(true); +// $worksheet->fromArray( +// $result, +// null, +// $coordinate, +// true +// ); +// IOFactory::setLoading(true); + + // Calculate the array formula range that we should set for our target, based on our target cell coordinate +// [$col, $row] = Coordinate::indexesFromString($coordinate); +// $row += count($result) - 1; +// $col = Coordinate::stringFromColumnIndex($col + count($result[0]) - 1); +// $arrayFormulaRange = "{$coordinate}:{$col}{$row}"; +// $formulaAttributes = ['t' => 'array', 'ref' => $arrayFormulaRange]; + + // Using fromArray() would reset the value for this cell with the calculation result + // as well as updating the spillage cells, + // so we need to restore this cell to its formula value, attributes, and datatype +// $cell = $worksheet->getCell($coordinate); +// $cell->setValueExplicit($value, DataType::TYPE_FORMULA, true, $arrayFormulaRange); +// $cell->setFormulaAttributes($formulaAttributes); + +// $cell->updateInCollection(); + + return $result; + } +} diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php deleted file mode 100644 index d5d993ae3a..0000000000 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ /dev/null @@ -1,314 +0,0 @@ -getWorksheet()->getParent()->getSheetByName($worksheetName) : $cell->getWorksheet(); - if ( - $worksheet === null || - !$worksheet->cellExists($cellReference) || - !$worksheet->getCell($cellReference)->isFormula() - ) { + if ($worksheet === null || $worksheet->cellExists($cellReference) === false) { + return ExcelError::NA(); + } + + $arrayFormulaRange = $worksheet->getCell($cellReference)->arrayFormulaRange(); + if ($arrayFormulaRange !== null) { + return self::arrayFormula($worksheet, $arrayFormulaRange); + } + + if ($worksheet->getCell($cellReference)->isFormula() === false) { return ExcelError::NA(); } return $worksheet->getCell($cellReference)->getValue(); } + + private static function arrayFormula(Worksheet $worksheet, string $arrayFormulaRange): string + { + [$arrayFormulaRange] = Coordinate::splitRange($arrayFormulaRange); + [$arrayFormulaCell] = $arrayFormulaRange; + + $arrayFormula = $worksheet->getCell($arrayFormulaCell)->getValue(); + + return "{{$arrayFormula}}"; + } } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php index 91a14491e0..0a88ae0b5b 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php @@ -62,7 +62,7 @@ private static function validateAddress($cellAddress): string * * @return array|string An array containing a cell or range of cells, or a string on error */ - public static function INDIRECT($cellAddress, $a1fmt, Cell $cell) + public static function indirect($cellAddress, $a1fmt, Cell $cell) { [$baseCol, $baseRow] = Coordinate::indexesFromString($cell->getCoordinate()); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php index 02a255812f..41d9e2f6d3 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php @@ -41,7 +41,7 @@ class Offset * * @return array|int|string An array containing a cell or range of cells, or a string on error */ - public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $cell = null) + public static function offset($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $cell = null) { $rows = Functions::flattenSingleValue($rows); $columns = Functions::flattenSingleValue($columns); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php b/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php index 8bce07e908..97a696487b 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php @@ -42,7 +42,7 @@ private static function cellColumn(?Cell $cell): int * * @return int|int[] */ - public static function COLUMN($cellAddress = null, ?Cell $cell = null) + public static function column($cellAddress = null, ?Cell $cell = null) { if (self::cellAddressNullOrWhitespace($cellAddress)) { return self::cellColumn($cell); @@ -93,7 +93,7 @@ public static function COLUMN($cellAddress = null, ?Cell $cell = null) * * @return int|string The number of columns in cellAddress, or a string if arguments are invalid */ - public static function COLUMNS($cellAddress = null) + public static function columns($cellAddress = null) { if (self::cellAddressNullOrWhitespace($cellAddress)) { return 1; @@ -135,7 +135,7 @@ private static function cellRow(?Cell $cell): int * * @return int|mixed[]|string */ - public static function ROW($cellAddress = null, ?Cell $cell = null) + public static function row($cellAddress = null, ?Cell $cell = null) { if (self::cellAddressNullOrWhitespace($cellAddress)) { return self::cellRow($cell); @@ -187,7 +187,7 @@ function ($value) { * * @return int|string The number of rows in cellAddress, or a string if arguments are invalid */ - public static function ROWS($cellAddress = null) + public static function rows($cellAddress = null) { if (self::cellAddressNullOrWhitespace($cellAddress)) { return 1; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php deleted file mode 100644 index 993154c33c..0000000000 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ /dev/null @@ -1,1520 +0,0 @@ - [Statistical\Averages::class, 'average'], // 1 and 101 - [Statistical\Counts::class, 'COUNT'], // 2 and 102 - [Statistical\Counts::class, 'COUNTA'], // 3 and 103 + [Statistical\Counts::class, 'count'], // 2 and 102 + [Statistical\Counts::class, 'countA'], // 3 and 103 [Statistical\Maximum::class, 'max'], // 4 and 104 [Statistical\Minimum::class, 'min'], // 5 and 105 [Operations::class, 'product'], // 6 and 106 - [Statistical\StandardDeviations::class, 'STDEV'], // 7 and 107 - [Statistical\StandardDeviations::class, 'STDEVP'], // 8 and 108 + [Statistical\StandardDeviations::class, 'stdev'], // 7 and 107 + [Statistical\StandardDeviations::class, 'stdevP'], // 8 and 108 [Sum::class, 'sumIgnoringStrings'], // 9 and 109 - [Statistical\Variances::class, 'VAR'], // 10 and 110 - [Statistical\Variances::class, 'VARP'], // 111 and 111 + [Statistical\Variances::class, 'variance'], // 10 and 110 + [Statistical\Variances::class, 'varianceP'], // 111 and 111 ]; /** diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php deleted file mode 100644 index 497c929749..0000000000 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ /dev/null @@ -1,1820 +0,0 @@ - 0)) { - $aCount = Counts::COUNT($aArgs); + $aCount = Counts::count($aArgs); if (Minimum::min($aArgs) > 0) { return $aMean ** (1 / $aCount); } @@ -116,7 +116,7 @@ public static function trim(...$args) } } - $discard = floor(Counts::COUNT($mArgs) * $percent / 2); + $discard = floor(Counts::count($mArgs) * $percent / 2); sort($mArgs); for ($i = 0; $i < $discard; ++$i) { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php index 51e6b00430..ae447f0f52 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php @@ -29,7 +29,7 @@ class Conditional * * @return null|float|string */ - public static function AVERAGEIF($range, $condition, $averageRange = []) + public static function averageIf($range, $condition, $averageRange = []) { $database = self::databaseFromRangeAndValue($range, $averageRange); $condition = [[self::CONDITION_COLUMN_NAME, self::VALUE_COLUMN_NAME], [$condition, null]]; @@ -49,12 +49,12 @@ public static function AVERAGEIF($range, $condition, $averageRange = []) * * @return null|float|string */ - public static function AVERAGEIFS(...$args) + public static function averageIfSeries(...$args) { if (empty($args)) { return 0.0; } elseif (count($args) === 3) { - return self::AVERAGEIF($args[1], $args[2], $args[0]); + return self::averageIf($args[1], $args[2], $args[0]); } $conditions = self::buildConditionSetForValueRange(...$args); @@ -76,7 +76,7 @@ public static function AVERAGEIFS(...$args) * * @return int */ - public static function COUNTIF($range, $condition) + public static function countIf($range, $condition) { // Filter out any empty values that shouldn't be included in a COUNT $range = array_filter( @@ -104,12 +104,12 @@ function ($value) { * * @return int */ - public static function COUNTIFS(...$args) + public static function countIfSeries(...$args) { if (empty($args)) { return 0; } elseif (count($args) === 2) { - return self::COUNTIF(...$args); + return self::countIf(...$args); } $database = self::buildDatabase(...$args); @@ -130,7 +130,7 @@ public static function COUNTIFS(...$args) * * @return null|float|string */ - public static function MAXIFS(...$args) + public static function maxIfSeries(...$args) { if (empty($args)) { return 0.0; @@ -154,7 +154,7 @@ public static function MAXIFS(...$args) * * @return null|float|string */ - public static function MINIFS(...$args) + public static function minIfSeries(...$args) { if (empty($args)) { return 0.0; @@ -180,7 +180,7 @@ public static function MINIFS(...$args) * * @return float|string */ - public static function SUMIF($range, $condition, $sumRange = []) + public static function sumIf($range, $condition, $sumRange = []) { $database = self::databaseFromRangeAndValue($range, $sumRange); $condition = [[self::CONDITION_COLUMN_NAME, self::VALUE_COLUMN_NAME], [$condition, null]]; @@ -200,12 +200,12 @@ public static function SUMIF($range, $condition, $sumRange = []) * * @return null|float|string */ - public static function SUMIFS(...$args) + public static function sumIfSeries(...$args) { if (empty($args)) { return 0.0; } elseif (count($args) === 3) { - return self::SUMIF($args[1], $args[2], $args[0]); + return self::sumIf($args[1], $args[2], $args[0]); } $conditions = self::buildConditionSetForValueRange(...$args); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php b/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php index ec2ce34ee1..d051fdebfe 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php @@ -27,7 +27,7 @@ class Confidence * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function CONFIDENCE($alpha, $stdDev, $size) + public static function confidence($alpha, $stdDev, $size) { if (is_array($alpha) || is_array($stdDev) || is_array($size)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $alpha, $stdDev, $size); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Counts.php b/src/PhpSpreadsheet/Calculation/Statistical/Counts.php index 13e7af7991..5c06a76b96 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Counts.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Counts.php @@ -18,7 +18,7 @@ class Counts extends AggregateBase * * @return int */ - public static function COUNT(...$args) + public static function count(...$args) { $returnValue = 0; @@ -49,7 +49,7 @@ public static function COUNT(...$args) * * @return int */ - public static function COUNTA(...$args) + public static function countA(...$args) { $returnValue = 0; @@ -77,7 +77,7 @@ public static function COUNTA(...$args) * * @return int */ - public static function COUNTBLANK(...$args) + public static function blank(...$args) { $returnValue = 0; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php b/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php index 6b1db3a43b..99c6ec3fa3 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php @@ -68,7 +68,7 @@ public static function kurtosis(...$args) if (!is_numeric($mean)) { return ExcelError::DIV0(); } - $stdDev = StandardDeviations::STDEV($aArgs); + $stdDev = StandardDeviations::stdev($aArgs); if ($stdDev > 0) { $count = $summer = 0; @@ -113,7 +113,7 @@ public static function skew(...$args) if (!is_numeric($mean)) { return ExcelError::DIV0(); } - $stdDev = StandardDeviations::STDEV($aArgs); + $stdDev = StandardDeviations::stdev($aArgs); if ($stdDev === 0.0 || is_string($stdDev)) { return ExcelError::DIV0(); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php index a655fa745f..dfd376935b 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php @@ -142,7 +142,7 @@ public static function zTest($dataSet, $m0, $sigma = null) if ($sigma === null) { /** @var float */ - $sigma = StandardDeviations::STDEV($dataSet); + $sigma = StandardDeviations::stdev($dataSet); } $n = count($dataSet); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php b/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php index 99738232e1..670585a624 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php @@ -24,7 +24,7 @@ class Percentiles * * @return float|string The result, or a string containing an error */ - public static function PERCENTILE(...$args) + public static function percentile(...$args) { $aArgs = Functions::flattenArray($args); @@ -45,7 +45,7 @@ public static function PERCENTILE(...$args) $mValueCount = count($mArgs); if ($mValueCount > 0) { sort($mArgs); - $count = Counts::COUNT($mArgs); + $count = Counts::count($mArgs); $index = $entry * ($count - 1); $iBase = floor($index); if ($index == $iBase) { @@ -74,7 +74,7 @@ public static function PERCENTILE(...$args) * * @return float|string (string if result is an error) */ - public static function PERCENTRANK($valueSet, $value, $significance = 3) + public static function percentRank($valueSet, $value, $significance = 3) { $valueSet = Functions::flattenArray($valueSet); $value = Functions::flattenSingleValue($value); @@ -125,7 +125,7 @@ public static function PERCENTRANK($valueSet, $value, $significance = 3) * * @return float|string The result, or a string containing an error */ - public static function QUARTILE(...$args) + public static function quartile(...$args) { $aArgs = Functions::flattenArray($args); $entry = array_pop($aArgs); @@ -142,7 +142,7 @@ public static function QUARTILE(...$args) return ExcelError::NAN(); } - return self::PERCENTILE($aArgs, $entry); + return self::percentile($aArgs, $entry); } /** @@ -156,7 +156,7 @@ public static function QUARTILE(...$args) * * @return float|string The result, or a string containing an error (0 = Descending, 1 = Ascending) */ - public static function RANK($value, $valueSet, $order = self::RANK_SORT_DESCENDING) + public static function rank($value, $valueSet, $order = self::RANK_SORT_DESCENDING) { $value = Functions::flattenSingleValue($value); $valueSet = Functions::flattenArray($valueSet); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Permutations.php b/src/PhpSpreadsheet/Calculation/Statistical/Permutations.php index 5d9d304837..280220b9eb 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Permutations.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Permutations.php @@ -30,7 +30,7 @@ class Permutations * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function PERMUT($numObjs, $numInSet) + public static function permut($numObjs, $numInSet) { if (is_array($numObjs) || is_array($numInSet)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $numObjs, $numInSet); @@ -66,7 +66,7 @@ public static function PERMUT($numObjs, $numInSet) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function PERMUTATIONA($numObjs, $numInSet) + public static function permutationA($numObjs, $numInSet) { if (is_array($numObjs) || is_array($numInSet)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $numObjs, $numInSet); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Size.php b/src/PhpSpreadsheet/Calculation/Statistical/Size.php index 2eef5fc7fb..82675e1a61 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Size.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Size.php @@ -29,7 +29,7 @@ public static function large(...$args) $entry = (int) floor($entry); $mArgs = self::filter($aArgs); - $count = Counts::COUNT($mArgs); + $count = Counts::count($mArgs); --$entry; if ($count === 0 || $entry < 0 || $entry >= $count) { return ExcelError::NAN(); @@ -65,7 +65,7 @@ public static function small(...$args) $entry = (int) floor($entry); $mArgs = self::filter($aArgs); - $count = Counts::COUNT($mArgs); + $count = Counts::count($mArgs); --$entry; if ($count === 0 || $entry < 0 || $entry >= $count) { return ExcelError::NAN(); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php b/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php index af2712053f..d7cac87f24 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php @@ -17,9 +17,9 @@ class StandardDeviations * * @return float|string The result, or a string containing an error */ - public static function STDEV(...$args) + public static function stdev(...$args) { - $result = Variances::VAR(...$args); + $result = Variances::variance(...$args); if (!is_numeric($result)) { return $result; } @@ -39,9 +39,9 @@ public static function STDEV(...$args) * * @return float|string */ - public static function STDEVA(...$args) + public static function stdevA(...$args) { - $result = Variances::VARA(...$args); + $result = Variances::varianceA(...$args); if (!is_numeric($result)) { return $result; } @@ -61,9 +61,9 @@ public static function STDEVA(...$args) * * @return float|string */ - public static function STDEVP(...$args) + public static function stdevP(...$args) { - $result = Variances::VARP(...$args); + $result = Variances::varianceP(...$args); if (!is_numeric($result)) { return $result; } @@ -83,9 +83,9 @@ public static function STDEVP(...$args) * * @return float|string */ - public static function STDEVPA(...$args) + public static function stdevPA(...$args) { - $result = Variances::VARPA(...$args); + $result = Variances::variancePA(...$args); if (!is_numeric($result)) { return $result; } diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php index af73519ef1..07ce487b08 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -63,7 +63,7 @@ protected static function validateTrendArrays(array $yValues, array $xValues): v * * @return float|string */ - public static function CORREL($yValues, $xValues = null) + public static function correlation($yValues, $xValues = null) { if (($xValues === null) || (!is_array($yValues)) || (!is_array($xValues))) { return ExcelError::VALUE(); @@ -91,7 +91,7 @@ public static function CORREL($yValues, $xValues = null) * * @return float|string */ - public static function COVAR($yValues, $xValues) + public static function covariance($yValues, $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -120,7 +120,7 @@ public static function COVAR($yValues, $xValues) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function FORECAST($xValue, $yValues, $xValues) + public static function forecast($xValue, $yValues, $xValues) { if (is_array($xValue)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 1, $xValue, $yValues, $xValues); @@ -151,7 +151,7 @@ public static function FORECAST($xValue, $yValues, $xValues) * * @return float[] */ - public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true) + public static function growth($yValues, $xValues = [], $newValues = [], $const = true) { $yValues = Functions::flattenArray($yValues); $xValues = Functions::flattenArray($xValues); @@ -181,7 +181,7 @@ public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = * * @return float|string */ - public static function INTERCEPT($yValues, $xValues) + public static function intercept($yValues, $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -208,7 +208,7 @@ public static function INTERCEPT($yValues, $xValues) * * @return array|int|string The result, or a string containing an error */ - public static function LINEST($yValues, $xValues = null, $const = true, $stats = false) + public static function lineEstimate($yValues, $xValues = null, $const = true, $stats = false) { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -269,7 +269,7 @@ public static function LINEST($yValues, $xValues = null, $const = true, $stats = * * @return array|int|string The result, or a string containing an error */ - public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false) + public static function logEstimate($yValues, $xValues = null, $const = true, $stats = false) { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -334,7 +334,7 @@ public static function LOGEST($yValues, $xValues = null, $const = true, $stats = * * @return float|string The result, or a string containing an error */ - public static function RSQ($yValues, $xValues) + public static function pearsonSquares($yValues, $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -358,7 +358,7 @@ public static function RSQ($yValues, $xValues) * * @return float|string The result, or a string containing an error */ - public static function SLOPE($yValues, $xValues) + public static function slope($yValues, $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -382,7 +382,7 @@ public static function SLOPE($yValues, $xValues) * * @return float|string */ - public static function STEYX($yValues, $xValues) + public static function standardError($yValues, $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -408,7 +408,7 @@ public static function STEYX($yValues, $xValues) * * @return float[] */ - public static function TREND($yValues, $xValues = [], $newValues = [], $const = true) + public static function trend($yValues, $xValues = [], $newValues = [], $const = true) { $yValues = Functions::flattenArray($yValues); $xValues = Functions::flattenArray($xValues); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Variances.php b/src/PhpSpreadsheet/Calculation/Statistical/Variances.php index 35d01d1c57..55685c1df2 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Variances.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Variances.php @@ -19,7 +19,7 @@ class Variances extends VarianceBase * * @return float|string (string if result is an error) */ - public static function VAR(...$args) + public static function variance(...$args) { $returnValue = ExcelError::DIV0(); @@ -61,7 +61,7 @@ public static function VAR(...$args) * * @return float|string (string if result is an error) */ - public static function VARA(...$args) + public static function varianceA(...$args) { $returnValue = ExcelError::DIV0(); @@ -107,7 +107,7 @@ public static function VARA(...$args) * * @return float|string (string if result is an error) */ - public static function VARP(...$args) + public static function varianceP(...$args) { // Return value $returnValue = ExcelError::DIV0(); @@ -150,7 +150,7 @@ public static function VARP(...$args) * * @return float|string (string if result is an error) */ - public static function VARPA(...$args) + public static function variancePA(...$args) { $returnValue = ExcelError::DIV0(); diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php deleted file mode 100644 index 6757a8d87c..0000000000 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ /dev/null @@ -1,448 +0,0 @@ -getWorksheet()->getParent()->getExcelCalendar()); + + $formattedValue = (string) NumberFormat::toFormattedString( $this->getCalculatedValue(), $this->getStyle() ->getNumberFormat()->getFormatCode() ); + + SharedDate::setExcelCalendar($currentCalendar); + + return $formattedValue; } /** @@ -182,20 +198,81 @@ public function getFormattedValue(): string * Sets the value for a cell, automatically determining the datatype using the value binder * * @param mixed $value Value - * - * @return $this */ - public function setValue($value): self + public function setValue($value, bool $isArrayFormula = false, ?string $arrayFormulaRange = null): self { - if (!self::getValueBinder()->bindValue($this, $value)) { + if (!self::getValueBinder()->bindValue($this, $value, $isArrayFormula, $arrayFormulaRange)) { throw new Exception('Value could not be bound to cell.'); } return $this; } + protected function formulaAttributes(bool $isArrayFormula, ?string $arrayFormulaRange): array + { + if ($isArrayFormula === true) { + return [ + 't' => 'array', + 'ref' => $arrayFormulaRange === null ? $this->getCoordinate() : $arrayFormulaRange, + ]; + } + + return []; + } + + private function arrayFormulaRangeCheck(?string $arrayFormulaRange = null): bool + { + if ($arrayFormulaRange !== null) { + if ($this->isInRange($arrayFormulaRange) && $this->isTopLeftRangeCell($arrayFormulaRange) === false) { + if (IOFactory::isLoading() === false) { + throw new Exception(sprintf( + 'Cell %s is within the spillage range of a formula, and cannot be changed', + $this->getCoordinate() + )); + } + } + + return $this->isTopLeftRangeCell($arrayFormulaRange); + } + + return false; + } + + private function clearSpillageRange(string $arrayFormulaRange): void + { + $thisCell = $this->getCoordinate(); + $worksheet = $this->getWorksheet(); + + foreach (Coordinate::extractAllCellReferencesInRange($arrayFormulaRange) as $cellAddress) { + if ($worksheet->cellExists($cellAddress)) { + $cell = $worksheet->getCell($cellAddress); + $cell->value = null; + $cell->dataType = DataType::TYPE_NULL; + $cell->arrayFormulaRange = null; + $cell->updateInCollection(); + } + } + + $worksheet->getCell($thisCell); + } + + private function setSpillageRange(string $arrayFormulaRange): void + { + $thisCell = $this->getCoordinate(); + $worksheet = $this->getWorksheet(); + + foreach (Coordinate::extractAllCellReferencesInRange($arrayFormulaRange) as $cellAddress) { + $cell = $worksheet->getCell($cellAddress); + $cell->arrayFormulaRange = $arrayFormulaRange; + $cell->updateInCollection(); + } + + $worksheet->getCell($thisCell); + } + /** - * Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder). + * Set the value for a cell, + * with the explicit data type passed to the method (bypassing any use of the value binders). * * @param mixed $value Value * @param string $dataType Explicit data type, see DataType::TYPE_* @@ -207,8 +284,16 @@ public function setValue($value): self * * @return Cell */ - public function setValueExplicit($value, $dataType) + public function setValueExplicit($value, $dataType, bool $isArrayFormula = false, ?string $arrayFormulaRange = null) { + if ($this->arrayFormulaRangeCheck($this->arrayFormulaRange)) { + $this->clearSpillageRange((string) $this->arrayFormulaRange); + } + + if ($this->arrayFormulaRangeCheck($arrayFormulaRange)) { + $this->setSpillageRange((string) $arrayFormulaRange); + } + // set the value according to data type switch ($dataType) { case DataType::TYPE_NULL: @@ -233,7 +318,17 @@ public function setValueExplicit($value, $dataType) break; case DataType::TYPE_FORMULA: - $this->value = (string) $value; + if (is_string($value) !== true || strpos($value, '=') !== 0) { + $dataType = DataType::TYPE_STRING; + if (in_array($value, Calculation::$excelConstants, true)) { + $value = array_search($value, Calculation::$excelConstants, true); + } + $value = (string) $value; + $this->formulaAttributes = []; + } else { + $this->formulaAttributes = $this->formulaAttributes($isArrayFormula, $arrayFormulaRange); + } + $this->value = $value; break; case DataType::TYPE_BOOL: @@ -251,8 +346,6 @@ public function setValueExplicit($value, $dataType) break; default: throw new Exception('Invalid datatype: ' . $dataType); - - break; } // set the datatype @@ -261,6 +354,46 @@ public function setValueExplicit($value, $dataType) return $this->updateInCollection(); } + private function processArrayResult( + Worksheet $worksheet, + string $coordinate, + array $result, + string $value, + ?array $formulaAttributes + ): array { + // We'll need to do a check here for the Singular Operator (@) at some point + // and not populate the spillage cells if it's there + if ($this->isArrayFormula()) { + // Here is where we should set all cellRange values from the result (but within the range limit) + // Ensure that our array result dimensions match the specified array formula range dimensions, + // expanding or shrinking it as necessary. + $result = Functions::resizeMatrix( + $result, + ...Coordinate::rangeDimension($this->formulaAttributes['ref'] ?? $coordinate) + ); + // But if we do write it, we get problems with #SPILL! Errors if the spreadsheet is saved + // TODO How are we going to identify and handle a #SPILL! or a #CALC! error? + IOFactory::setLoading(true); + $worksheet->fromArray( + $result, + null, + $coordinate, + true + ); + IOFactory::setLoading(false); + // Using fromArray() would reset the value for this cell with the calculation result + // as well as updating the spillage cells, + // so we need to restore this cell to its formula value, attributes, and datatype + $worksheet->getCell($coordinate); + $this->value = $value; + $this->dataType = DataType::TYPE_FORMULA; + $this->formulaAttributes = $formulaAttributes; + $this->updateInCollection(); + } + + return $result; + } + /** * Get calculated cell value. * @@ -268,24 +401,41 @@ public function setValueExplicit($value, $dataType) * * @return mixed */ - public function getCalculatedValue(bool $resetLog = true) + public function getCalculatedValue(bool $asArray = false, bool $resetLog = true) { if ($this->dataType === DataType::TYPE_FORMULA) { + $currentCalendar = SharedDate::getExcelCalendar(); + SharedDate::setExcelCalendar($this->getWorksheet()->getParent()->getExcelCalendar()); + try { + $coordinate = $this->getCoordinate(); + $worksheet = $this->getWorksheet(); + $value = $this->value; + $formulaAttributes = $this->formulaAttributes; $index = $this->getWorksheet()->getParent()->getActiveSheetIndex(); $selected = $this->getWorksheet()->getSelectedCells(); + $result = Calculation::getInstance( $this->getWorksheet()->getParent() - )->calculateCellValue($this, $resetLog); - $this->getWorksheet()->setSelectedCells($selected); - $this->getWorksheet()->getParent()->setActiveSheetIndex($index); - // We don't yet handle array returns + )->calculateCellValue($this, $asArray, $resetLog); + + $worksheet->getCell($coordinate); + if (is_array($result)) { - while (is_array($result)) { - $result = array_shift($result); + $result = $this->processArrayResult($worksheet, $coordinate, $result, $value, $formulaAttributes); + + // Now we just extract the top-left value from the array to get the result for this specific cell + if ($asArray === false) { + while (is_array($result)) { + $result = array_shift($result); + } } } + + $this->getWorksheet()->setSelectedCells($selected); + $this->getWorksheet()->getParent()->setActiveSheetIndex($index); } catch (Exception $ex) { + SharedDate::setExcelCalendar($currentCalendar); if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->calculatedValue !== null)) { return $this->calculatedValue; // Fallback for calculations referencing external files. } elseif (preg_match('/[Uu]ndefined (name|offset: 2|array key 2)/', $ex->getMessage()) === 1) { @@ -297,6 +447,7 @@ public function getCalculatedValue(bool $resetLog = true) ); } + SharedDate::setExcelCalendar($currentCalendar); if ($result === '#Not Yet Implemented') { return $this->calculatedValue; // Fallback if calculation engine does not support the formula. } @@ -369,6 +520,31 @@ public function isFormula(): bool return $this->dataType === DataType::TYPE_FORMULA && $this->getStyle()->getQuotePrefix() === false; } + /** + * Identify if the cell contains an array formula. + */ + public function isArrayFormula(): bool + { + if ($this->dataType === DataType::TYPE_FORMULA) { + $formulaAttributes = $this->getFormulaAttributes(); + + return isset($formulaAttributes['t']) && $formulaAttributes['t'] === 'array'; + } + + return false; + } + + public function arrayFormulaRange(): ?string + { + if ($this->isFormula() && $this->isArrayFormula()) { + $formulaAttributes = $this->getFormulaAttributes(); + + return $formulaAttributes['ref'] ?? null; + } + + return $this->arrayFormulaRange; + } + /** * Does this cell contain Data validation rules? */ @@ -457,10 +633,8 @@ public function setHyperlink(?Hyperlink $hyperlink = null): self /** * Get cell collection. - * - * @return Cells */ - public function getParent() + public function getParent(): Cells { return $this->parent; } @@ -475,7 +649,6 @@ public function getWorksheet(): Worksheet } catch (Throwable $e) { $worksheet = null; } - if ($worksheet === null) { throw new Exception('Worksheet no longer exists'); } @@ -491,19 +664,33 @@ public function isInMergeRange(): bool return (bool) $this->getMergeRange(); } + /** + * Is this cell in an array formula spillage range. + */ + public function isInSpillageRange(): bool + { + return $this->arrayFormulaRange !== null; + } + + private function isTopLeftRangeCell(string $cellRange): bool + { + $mergeRange = Coordinate::splitRange($cellRange); + [$startCell] = $mergeRange[0]; + + return $this->getCoordinate() === $startCell; + } + /** * Is this cell the master (top left cell) in a merge range (that holds the actual data value). */ public function isMergeRangeValueCell(): bool { - if ($mergeRange = $this->getMergeRange()) { - $mergeRange = Coordinate::splitRange($mergeRange); - [$startCell] = $mergeRange[0]; - - return $this->getCoordinate() === $startCell; + $mergeRange = $this->getMergeRange(); + if ($mergeRange === false) { + return false; } - return false; + return $this->isTopLeftRangeCell($mergeRange); } /** @@ -653,11 +840,11 @@ public function setXfIndex(int $indexValue): self /** * Set the formula attributes. * - * @param mixed $attributes + * @param mixed[] $attributes * * @return $this */ - public function setFormulaAttributes($attributes): self + public function setFormulaAttributes(array $attributes): self { $this->formulaAttributes = $attributes; @@ -667,7 +854,7 @@ public function setFormulaAttributes($attributes): self /** * Get the formula attributes. */ - public function getFormulaAttributes() + public function getFormulaAttributes(): ?array { return $this->formulaAttributes; } diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index 4f2cdf7879..19f64bd983 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -13,10 +13,8 @@ class DefaultValueBinder implements IValueBinder * * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell - * - * @return bool */ - public function bindValue(Cell $cell, $value) + public function bindValue(Cell $cell, $value, bool $isArrayFormula = false, ?string $arrayFormulaRange = null): bool { // sanitize UTF-8 strings if (is_string($value)) { @@ -32,7 +30,7 @@ public function bindValue(Cell $cell, $value) } // Set value explicit - $cell->setValueExplicit($value, static::dataTypeForValue($value)); + $cell->setValueExplicit($value, static::dataTypeForValue($value), $isArrayFormula, $arrayFormulaRange); // Done! return true; diff --git a/src/PhpSpreadsheet/Cell/IValueBinder.php b/src/PhpSpreadsheet/Cell/IValueBinder.php index 5af9f5f60e..d1607a806a 100644 --- a/src/PhpSpreadsheet/Cell/IValueBinder.php +++ b/src/PhpSpreadsheet/Cell/IValueBinder.php @@ -12,5 +12,5 @@ interface IValueBinder * * @return bool */ - public function bindValue(Cell $cell, $value); + public function bindValue(Cell $cell, $value, bool $isArrayFormula = false, ?string $arrayFormulaRange = null); } diff --git a/src/PhpSpreadsheet/Cell/StringValueBinder.php b/src/PhpSpreadsheet/Cell/StringValueBinder.php index d525faffff..204dae1907 100644 --- a/src/PhpSpreadsheet/Cell/StringValueBinder.php +++ b/src/PhpSpreadsheet/Cell/StringValueBinder.php @@ -77,7 +77,7 @@ public function setConversionForAllValueTypes(bool $suppressConversion = false): * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell */ - public function bindValue(Cell $cell, $value) + public function bindValue(Cell $cell, $value, bool $isArrayFormula = false, ?string $arrayFormulaRange = null): bool { if (is_object($value)) { return $this->bindObjectValue($cell, $value); @@ -95,7 +95,7 @@ public function bindValue(Cell $cell, $value) } elseif ((is_int($value) || is_float($value)) && $this->convertNumeric === false) { $cell->setValueExplicit($value, DataType::TYPE_NUMERIC); } elseif (is_string($value) && strlen($value) > 1 && $value[0] === '=' && $this->convertFormula === false) { - $cell->setValueExplicit($value, DataType::TYPE_FORMULA); + $cell->setValueExplicit($value, DataType::TYPE_FORMULA, $isArrayFormula, $arrayFormulaRange); } else { if (is_string($value) && strlen($value) > 1 && $value[0] === '=') { $cell->getStyle()->setQuotePrefix(true); diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index cd166b23b5..dd29192206 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -476,7 +476,7 @@ public function refresh(Worksheet $worksheet, bool $flatten = true): void if ($this->dataSource !== null) { $calcEngine = Calculation::getInstance($worksheet->getParent()); $newDataValues = Calculation::unwrapResult( - $calcEngine->_calculateFormulaValue( + $calcEngine->calculateFormulaValue( '=' . $this->dataSource, null, $worksheet->getCell('A1') diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index e437a22065..c9c0866e12 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -52,6 +52,21 @@ abstract class IOFactory 'Mpdf' => Writer\Pdf\Mpdf::class, ]; + /** + * @var bool + */ + protected static $loading = false; + + public static function setLoading(bool $loading): void + { + self::$loading = $loading; + } + + public static function isLoading(): bool + { + return self::$loading; + } + /** * Create Writer\IWriter. */ diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index a137e78cbf..552995fd31 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\Shared\File; @@ -40,7 +41,7 @@ abstract class BaseReader implements IReader * Restrict which sheets should be loaded? * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded. * - * @var null|string[] + * @var ?string[] */ protected $loadSheetsOnly; @@ -63,38 +64,38 @@ public function __construct() $this->readFilter = new DefaultReadFilter(); } - public function getReadDataOnly() + public function getReadDataOnly(): bool { return $this->readDataOnly; } - public function setReadDataOnly($readCellValuesOnly) + public function setReadDataOnly(bool $readDataOnly): IReader { - $this->readDataOnly = (bool) $readCellValuesOnly; + $this->readDataOnly = (bool) $readDataOnly; return $this; } - public function getReadEmptyCells() + public function getReadEmptyCells(): bool { return $this->readEmptyCells; } - public function setReadEmptyCells($readEmptyCells) + public function setReadEmptyCells(bool $readEmptyCells): IReader { - $this->readEmptyCells = (bool) $readEmptyCells; + $this->readEmptyCells = $readEmptyCells; return $this; } - public function getIncludeCharts() + public function getIncludeCharts(): bool { return $this->includeCharts; } - public function setIncludeCharts($includeCharts) + public function setIncludeCharts(bool $includeCharts): IReader { - $this->includeCharts = (bool) $includeCharts; + $this->includeCharts = $includeCharts; return $this; } @@ -104,7 +105,7 @@ public function getLoadSheetsOnly() return $this->loadSheetsOnly; } - public function setLoadSheetsOnly($sheetList) + public function setLoadSheetsOnly($sheetList): IReader { if ($sheetList === null) { return $this->setLoadAllSheets(); @@ -115,19 +116,19 @@ public function setLoadSheetsOnly($sheetList) return $this; } - public function setLoadAllSheets() + public function setLoadAllSheets(): IReader { $this->loadSheetsOnly = null; return $this; } - public function getReadFilter() + public function getReadFilter(): IReadFilter { return $this->readFilter; } - public function setReadFilter(IReadFilter $readFilter) + public function setReadFilter(IReadFilter $readFilter): IReader { $this->readFilter = $readFilter; @@ -139,8 +140,14 @@ public function getSecurityScanner() return $this->securityScanner; } - protected function processFlags(int $flags): void + public function setFlags(int $flags): void { + if (((bool) ($flags & self::IGNORE_EMPTY_CELLS)) === true) { + $this->setReadEmptyCells(false); + } + if (((bool) ($flags & self::READ_DATA_ONLY)) === true) { + $this->setReadDataOnly(true); + } if (((bool) ($flags & self::LOAD_WITH_CHARTS)) === true) { $this->setIncludeCharts(true); } @@ -154,18 +161,26 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet /** * Loads Spreadsheet from file. * - * @param int $flags the optional second parameter flags may be used to identify specific elements + * @param ?int $flags the optional second parameter flags may be used to identify specific elements * that should be loaded, but which won't be loaded by default, using these values: + * IReader::IGNORE_EMPTY_CELLS - Don't create empty cells (those containing a null or an empty string) + * IReader::READ_DATA_ONLY - Only read data from the file, not structure or styling * IReader::LOAD_WITH_CHARTS - Include any charts that are defined in the loaded file */ - public function load(string $filename, int $flags = 0): Spreadsheet + public function load(string $filename, ?int $flags = null): Spreadsheet { - $this->processFlags($flags); + if ($flags !== null) { + $this->setFlags($flags); + } + + IOFactory::setLoading(true); try { return $this->loadSpreadsheetFromFile($filename); } catch (ReaderException $e) { throw $e; + } finally { + IOFactory::setLoading(false); } } @@ -182,7 +197,7 @@ protected function openFile(string $filename): void $fileHandle = fopen($filename, 'rb'); } if ($fileHandle === false) { - throw new ReaderException('Could not open file ' . $filename . ' for reading.'); + throw new ReaderException("Could not open file {$filename} for reading."); } $this->fileHandle = $fileHandle; diff --git a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php index 8fdb162b4c..0c4b87b61a 100644 --- a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php +++ b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php @@ -10,10 +10,8 @@ class DefaultReadFilter implements IReadFilter * @param string $columnAddress Column address (as a string value like "A", or "IV") * @param int $row Row number * @param string $worksheetName Optional worksheet name - * - * @return bool */ - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return true; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 1dcb0a125a..5432e7fc3d 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -546,15 +546,24 @@ private function loadCell( ): void { $ValueType = $cellAttributes->ValueType; $ExprID = (string) $cellAttributes->ExprID; + + $rows = (int) ($cellAttributes->Rows ?? 0); + $cols = (int) ($cellAttributes->Cols ?? 0); + $type = DataType::TYPE_FORMULA; + $isArrayFormula = ($rows > 0 || $cols > 0); + $arrayFormulaRange = $isArrayFormula ? $this->getArrayFormulaRange($column, $row, $cols, $rows) : null; + if ($ExprID > '') { if (((string) $cell) > '') { + // Formula $this->expressions[$ExprID] = [ 'column' => $cellAttributes->Col, 'row' => $cellAttributes->Row, 'formula' => (string) $cell, ]; } else { + // "Shared" Formula $expression = $this->expressions[$ExprID]; $cell = $this->referenceHelper->updateFormulaReferences( @@ -565,22 +574,37 @@ private function loadCell( $worksheetName ); } - $type = DataType::TYPE_FORMULA; - } else { + } elseif ($isArrayFormula === false) { $vtype = (string) $ValueType; if (array_key_exists($vtype, self::$mappings['dataType'])) { $type = self::$mappings['dataType'][$vtype]; } - if ($vtype === '20') { // Boolean + if ($vtype === '20') { // Boolean $cell = $cell == 'TRUE'; } } - $this->spreadsheet->getActiveSheet()->getCell($column . $row)->setValueExplicit((string) $cell, $type); + $this->spreadsheet->getActiveSheet() + ->getCell($column . $row) + ->setValueExplicit((string) $cell, $type, $isArrayFormula, $arrayFormulaRange); + if (isset($cellAttributes->ValueFormat)) { $this->spreadsheet->getActiveSheet()->getCell($column . $row) ->getStyle()->getNumberFormat() ->setFormatCode((string) $cellAttributes->ValueFormat); } } + + private function getArrayFormulaRange(string $column, int $row, int $cols, int $rows): string + { + $arrayFormulaRange = $column . $row; + $arrayFormulaRange .= ':' . + Coordinate::stringFromColumnIndex( + Coordinate::columnIndexFromString($column) + + $cols - 1 + ) . + (string) ($row + $rows - 1); + + return $arrayFormulaRange; + } } diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 76f128e025..fc2eb37368 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -26,13 +26,6 @@ class Html extends BaseReader */ const TEST_SAMPLE_SIZE = 2048; - /** - * Input encoding. - * - * @var string - */ - protected $inputEncoding = 'ANSI'; - /** * Sheet index to read. * @@ -210,38 +203,6 @@ public function loadSpreadsheetFromFile(string $filename): Spreadsheet return $this->loadIntoExisting($filename, $spreadsheet); } - /** - * Set input encoding. - * - * @param string $inputEncoding Input encoding, eg: 'ANSI' - * - * @return $this - * - * @codeCoverageIgnore - * - * @deprecated no use is made of this property - */ - public function setInputEncoding($inputEncoding) - { - $this->inputEncoding = $inputEncoding; - - return $this; - } - - /** - * Get input encoding. - * - * @return string - * - * @codeCoverageIgnore - * - * @deprecated no use is made of this property - */ - public function getInputEncoding() - { - return $this->inputEncoding; - } - // Data Array used for testing only, should write to Spreadsheet object on completion of tests /** @var array */ @@ -255,7 +216,7 @@ public function getInputEncoding() protected function setTableStartColumn(string $column): string { - if ($this->tableLevel == 0) { + if ($this->tableLevel === 0) { $column = 'A'; } ++$this->tableLevel; diff --git a/src/PhpSpreadsheet/Reader/IReadFilter.php b/src/PhpSpreadsheet/Reader/IReadFilter.php index 9f68a7f360..1fd12e56f7 100644 --- a/src/PhpSpreadsheet/Reader/IReadFilter.php +++ b/src/PhpSpreadsheet/Reader/IReadFilter.php @@ -10,8 +10,6 @@ interface IReadFilter * @param string $columnAddress Column address (as a string value like "A", or "IV") * @param int $row Row number * @param string $worksheetName Optional worksheet name - * - * @return bool */ - public function readCell($columnAddress, $row, $worksheetName = ''); + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool; } diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index d73662b426..cf2de47bba 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -2,14 +2,13 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + interface IReader { - public const LOAD_WITH_CHARTS = 1; - - /** - * IReader constructor. - */ - public function __construct(); + public const IGNORE_EMPTY_CELLS = 1; + public const READ_DATA_ONLY = 2; + public const LOAD_WITH_CHARTS = 4; /** * Can the current IReader read the file? @@ -20,110 +19,82 @@ public function canRead(string $filename): bool; * Read data only? * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. * If false (the default) it will read data and formatting. - * - * @return bool */ - public function getReadDataOnly(); + public function getReadDataOnly(): bool; /** * Set read data only * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param bool $readDataOnly - * - * @return IReader */ - public function setReadDataOnly($readDataOnly); + public function setReadDataOnly(bool $readDataOnly): self; /** * Read empty cells? * If this is true (the default), then the Reader will read data values for all cells, irrespective of value. * If false it will not read data for cells containing a null value or an empty string. - * - * @return bool */ - public function getReadEmptyCells(); + public function getReadEmptyCells(): bool; /** * Set read empty cells * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. * Set to false to advise the Reader to ignore cells containing a null value or an empty string. - * - * @param bool $readEmptyCells - * - * @return IReader */ - public function setReadEmptyCells($readEmptyCells); + public function setReadEmptyCells(bool $readEmptyCells): self; /** * Read charts in workbook? * If this is true, then the Reader will include any charts that exist in the workbook. * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. * If false (the default) it will ignore any charts defined in the workbook file. - * - * @return bool */ - public function getIncludeCharts(); + public function getIncludeCharts(): bool; /** * Set read charts in workbook * Set to true, to advise the Reader to include any charts that exist in the workbook. * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. * Set to false (the default) to discard charts. - * - * @param bool $includeCharts - * - * @return IReader */ - public function setIncludeCharts($includeCharts); + public function setIncludeCharts(bool $includeCharts): self; /** * Get which sheets to load * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null * indicating that all worksheets in the workbook should be loaded. * - * @return mixed + * @return ?string[] */ public function getLoadSheetsOnly(); /** * Set which sheets to load. * - * @param mixed $value + * @param null|string|string[] $sheetList * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return IReader */ - public function setLoadSheetsOnly($value); + public function setLoadSheetsOnly($sheetList): self; /** * Set all sheets to load * Tells the Reader to load all worksheets from the workbook. - * - * @return IReader */ - public function setLoadAllSheets(); + public function setLoadAllSheets(): self; /** * Read filter. - * - * @return IReadFilter */ - public function getReadFilter(); + public function getReadFilter(): IReadFilter; /** * Set read filter. - * - * @return IReader */ - public function setReadFilter(IReadFilter $readFilter); + public function setReadFilter(IReadFilter $readFilter): self; /** * Loads PhpSpreadsheet from file. - * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet */ - public function load(string $filename, int $flags = 0); + public function load(string $filename, int $flags = 0): Spreadsheet; } diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index e3de473174..8250a15c46 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -229,7 +229,7 @@ private static function getXmlName(XMLReader $xml): string /** * Loads PhpSpreadsheet from file. */ - protected function loadSpreadsheetFromFile(string $filename): Spreadsheet + public function loadSpreadsheetFromFile(string $filename): Spreadsheet { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); @@ -385,9 +385,12 @@ public function loadIntoExisting($filename, Spreadsheet $spreadsheet) $hasCalculatedValue = false; $cellDataFormula = ''; + $arrayAttributeRows = $arrayAttributeColumns = null; if ($cellData->hasAttributeNS($tableNs, 'formula')) { $cellDataFormula = $cellData->getAttributeNS($tableNs, 'formula'); $hasCalculatedValue = true; + $arrayAttributeRows = $cellData->getAttributeNS($tableNs, 'number-matrix-rows-spanned'); + $arrayAttributeColumns = $cellData->getAttributeNS($tableNs, 'number-matrix-columns-spanned'); } // Annotations @@ -548,7 +551,23 @@ public function loadIntoExisting($filename, Spreadsheet $spreadsheet) // Set value if ($hasCalculatedValue) { - $cell->setValueExplicit($cellDataFormula, $type); + $arrayFormulaRange = null; + $isArrayFormula = (!empty($arrayAttributeRows) && !empty($arrayAttributeColumns)); + if ($isArrayFormula === true) { + $arrayFormulaRange = $columnID . $rID; + $arrayAttributeRows = (int) $arrayAttributeRows; + $arrayAttributeColumns = (int) $arrayAttributeColumns; + if ($arrayAttributeRows > 1 || $arrayAttributeColumns > 1) { + $arrayFormulaRange .= ':' . + Coordinate::stringFromColumnIndex( + Coordinate::columnIndexFromString($columnID) + + $arrayAttributeColumns - 1 + ) . + (string) ($rID + $arrayAttributeRows - 1); + } + } + + $cell->setValueExplicit($cellDataFormula, $type, $isArrayFormula, $arrayFormulaRange); } else { $cell->setValueExplicit($dataValue, $type); } @@ -558,17 +577,10 @@ public function loadIntoExisting($filename, Spreadsheet $spreadsheet) } // Set other properties - if ($formatting !== null) { - $spreadsheet->getActiveSheet() - ->getStyle($columnID . $rID) - ->getNumberFormat() - ->setFormatCode($formatting); - } else { - $spreadsheet->getActiveSheet() - ->getStyle($columnID . $rID) - ->getNumberFormat() - ->setFormatCode(NumberFormat::FORMAT_GENERAL); - } + $spreadsheet->getActiveSheet() + ->getStyle($columnID . $rID) + ->getNumberFormat() + ->setFormatCode($formatting ?? NumberFormat::FORMAT_GENERAL); if ($hyperlink !== null) { $cell->getHyperlink() @@ -620,11 +632,13 @@ private function processSettings(ZipArchive $zip, Spreadsheet $spreadsheet): voi $officeNs = $dom->lookupNamespaceUri('office'); $settings = $dom->getElementsByTagNameNS($officeNs, 'settings') ->item(0); - $this->lookForActiveSheet($settings, $spreadsheet, $configNs); - $this->lookForSelectedCells($settings, $spreadsheet, $configNs); + if ($settings !== null) { + $this->activeSheet($settings, $spreadsheet, $configNs); + $this->selectedCells($settings, $spreadsheet, $configNs); + } } - private function lookForActiveSheet(DOMElement $settings, Spreadsheet $spreadsheet, string $configNs): void + private function activeSheet(DOMElement $settings, Spreadsheet $spreadsheet, string $configNs): void { /** @var DOMElement $t */ foreach ($settings->getElementsByTagNameNS($configNs, 'config-item') as $t) { @@ -640,7 +654,7 @@ private function lookForActiveSheet(DOMElement $settings, Spreadsheet $spreadshe } } - private function lookForSelectedCells(DOMElement $settings, Spreadsheet $spreadsheet, string $configNs): void + private function selectedCells(DOMElement $settings, Spreadsheet $spreadsheet, string $configNs): void { /** @var DOMElement $t */ foreach ($settings->getElementsByTagNameNS($configNs, 'config-item-map-named') as $t) { diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 9de4013ad9..f557e0bfe5 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -12,13 +12,6 @@ class Slk extends BaseReader { - /** - * Input encoding. - * - * @var string - */ - private $inputEncoding = 'ANSI'; - /** * Sheet index to read. * @@ -97,38 +90,6 @@ private function canReadOrBust(string $filename): void $this->openFile($filename); } - /** - * Set input encoding. - * - * @deprecated no use is made of this property - * - * @param string $inputEncoding Input encoding, eg: 'ANSI' - * - * @return $this - * - * @codeCoverageIgnore - */ - public function setInputEncoding($inputEncoding) - { - $this->inputEncoding = $inputEncoding; - - return $this; - } - - /** - * Get input encoding. - * - * @deprecated no use is made of this property - * - * @return string - * - * @codeCoverageIgnore - */ - public function getInputEncoding() - { - return $this->inputEncoding; - } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). * diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index a8de522823..c0da4cc063 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1235,7 +1235,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet // Bar!$A$1:$IV$2 $explodes = Worksheet::extractSheetTitle($range, true); $sheetName = trim($explodes[0], "'"); - if (count($explodes) == 2) { + if (count($explodes) === 2) { if (strpos($explodes[1], ':') === false) { $explodes[1] = $explodes[1] . ':' . $explodes[1]; } @@ -2026,9 +2026,9 @@ private function readDateMode(): void $this->pos += 4 + $length; // offset: 0; size: 2; 0 = base 1900, 1 = base 1904 - Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); + $this->spreadsheet->setExcelCalendar(Date::CALENDAR_WINDOWS_1900); if (ord($recordData[0]) == 1) { - Date::setExcelCalendar(Date::CALENDAR_MAC_1904); + $this->spreadsheet->setExcelCalendar(Date::CALENDAR_MAC_1904); } } diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index e2fae121b5..36310578bd 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -320,31 +320,39 @@ private static function castToString(?SimpleXMLElement $c): ?string * @param mixed $value * @param mixed $calculatedValue */ - private function castToFormula(?SimpleXMLElement $c, string $r, string &$cellDataType, &$value, &$calculatedValue, array &$sharedFormulas, string $castBaseType): void + private function castToFormula(Worksheet $docSheet, ?SimpleXMLElement $c, string $r, string &$cellDataType, &$value, &$calculatedValue, array &$sharedFormulas, string $castBaseType): void { if ($c === null) { return; } - $attr = $c->f->attributes(); + + $formulaAttributes = $c->f->attributes(); $cellDataType = 'f'; $value = "={$c->f}"; $calculatedValue = self::$castBaseType($c); - // Shared formula? - if (isset($attr['t']) && strtolower((string) $attr['t']) == 'shared') { - $instance = (string) $attr['si']; + if (isset($formulaAttributes['t'])) { + if (strtolower((string) $formulaAttributes['t']) === 'shared') { + // Shared formula + $instance = (string) $formulaAttributes['si']; - if (!isset($sharedFormulas[(string) $attr['si']])) { - $sharedFormulas[$instance] = ['master' => $r, 'formula' => $value]; - } else { - $master = Coordinate::indexesFromString($sharedFormulas[$instance]['master']); - $current = Coordinate::indexesFromString($r); + if (!isset($sharedFormulas[(string) $formulaAttributes['si']])) { + $sharedFormulas[$instance] = ['master' => $r, 'formula' => $value]; + } else { + $master = Coordinate::indexesFromString($sharedFormulas[$instance]['master']); + $current = Coordinate::indexesFromString($r); - $difference = [0, 0]; - $difference[0] = $current[0] - $master[0]; - $difference[1] = $current[1] - $master[1]; + $difference = [0, 0]; + $difference[0] = $current[0] - $master[0]; + $difference[1] = $current[1] - $master[1]; - $value = $this->referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]); + $value = $this->referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]); + } + } elseif (strtolower((string) $formulaAttributes['t']) === 'array') { + // Array formula + $formulaType = (string) $formulaAttributes['t']; + $formulaRange = $formulaAttributes['ref'] ? (string) $formulaAttributes['ref'] : null; + $docSheet->getCell($r)->setFormulaAttributes(['t' => $formulaType, 'ref' => $formulaRange]); } } } @@ -682,11 +690,11 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet // Set base date if ($xmlWorkbookNS->workbookPr) { - Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); + $excel->setExcelCalendar(Date::CALENDAR_WINDOWS_1900); $attrs1904 = self::getAttributes($xmlWorkbookNS->workbookPr); if (isset($attrs1904['date1904'])) { if (self::boolean((string) $attrs1904['date1904'])) { - Date::setExcelCalendar(Date::CALENDAR_MAC_1904); + $excel->setExcelCalendar(Date::CALENDAR_MAC_1904); } } } @@ -785,7 +793,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet if (!$this->getReadFilter()->readCell($coordinates[0], (int) $coordinates[1], $docSheet->getTitle())) { if (isset($cAttr->f)) { - $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); + $this->castToFormula($docSheet, $c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); } ++$rowIndex; @@ -817,17 +825,13 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet } } else { // Formula - $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToBoolean'); - if (isset($c->f['t'])) { - $att = $c->f; - $docSheet->getCell($r)->setFormulaAttributes($att); - } + $this->castToFormula($docSheet, $c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToBoolean'); } break; case 'inlineStr': if (isset($c->f)) { - $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); + $this->castToFormula($docSheet, $c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); } else { $value = $this->parseRichText($c->is); } @@ -838,7 +842,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $value = self::castToError($c); } else { // Formula - $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); + $this->castToFormula($docSheet, $c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError'); } break; @@ -847,11 +851,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $value = self::castToString($c); } else { // Formula - $this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToString'); - if (isset($c->f['t'])) { - $attributes = $c->f['t']; - $docSheet->getCell($r)->setFormulaAttributes(['t' => (string) $attributes]); - } + $this->castToFormula($docSheet, $c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToString'); } break; @@ -865,6 +865,9 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet } $cell = $docSheet->getCell($r); + $formulaAttributes = $cell->getFormulaAttributes(); + $isArrayFormula = isset($formulaAttributes['t']) && $formulaAttributes['t'] === 'array'; + $arrayFormulaRange = $formulaAttributes['ref'] ?? null; // Assign value if ($cellDataType != '') { // it is possible, that datatype is numeric but with an empty string, which result in an error @@ -872,10 +875,10 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $cellDataType = DataType::TYPE_NULL; } if ($cellDataType !== DataType::TYPE_NULL) { - $cell->setValueExplicit($value, $cellDataType); + $cell->setValueExplicit($value, $cellDataType, $isArrayFormula, $arrayFormulaRange); } } else { - $cell->setValue($value); + $cell->setValue($value, $isArrayFormula, $arrayFormulaRange); } if ($calculatedValue !== null) { $cell->setCalculatedValue($calculatedValue); @@ -1613,7 +1616,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet if (strpos((string) $definedName, '!') !== false) { $range[0] = str_replace("''", "'", $range[0]); $range[0] = str_replace("'", '', $range[0]); - if ($worksheet = $excel->getSheetByName($range[0])) { // @phpstan-ignore-line + if ($worksheet = $excel->getSheetByName($range[0])) { $excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $worksheet, $extractedRange, true, $scope)); } else { $excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $scope, $extractedRange, true, $scope)); diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 3f53ed1d41..2efd1766ca 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -441,6 +441,16 @@ function ($coordinate) use ($cellCollection) { // Formula should be adjusted $worksheet->getCell($newCoordinate) ->setValue($this->updateFormulaReferences($cell->getValue(), $beforeCellAddress, $numberOfColumns, $numberOfRows, $worksheet->getTitle())); + if ($cell->arrayFormulaRange() !== null) { + $newArrayFormulaRange = $this->updateFormulaReferences( + $cell->arrayFormulaRange(), + $beforeCellAddress, + $numberOfColumns, + $numberOfRows, + $worksheet->getTitle() + ); + $worksheet->getCell($newCoordinate)->setFormulaAttributes(['t' => 'array', 'ref' => $newArrayFormulaRange]); + } } else { // Formula should not be adjusted $worksheet->getCell($newCoordinate)->setValueExplicit($cell->getValue(), $cell->getDataType()); diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 872780737f..547e875ca7 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -5,11 +5,11 @@ use DateTime; use DateTimeInterface; use DateTimeZone; +use Exception; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Cell\Cell; -use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDate; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; @@ -67,7 +67,7 @@ class Date protected static $defaultTimeZone; /** - * Set the Excel calendar (Windows 1900 or Mac 1904). + * Set the Excel Date Calendar (Windows 1900 or Mac 1904) used for calculations and formatting. * * @param int $baseYear Excel base date (1900 or 1904) * @@ -75,10 +75,7 @@ class Date */ public static function setExcelCalendar($baseYear) { - if ( - ($baseYear == self::CALENDAR_WINDOWS_1900) || - ($baseYear == self::CALENDAR_MAC_1904) - ) { + if (($baseYear == self::CALENDAR_WINDOWS_1900) || ($baseYear == self::CALENDAR_MAC_1904)) { self::$excelCalendar = $baseYear; return true; @@ -88,7 +85,8 @@ public static function setExcelCalendar($baseYear) } /** - * Return the Excel calendar (Windows 1900 or Mac 1904). + * Return the Excel Date Calendar (Windows 1900 or Mac 1904) + * to be used for current calculations and formatting. * * @return int Excel base date (1900 or 1904) */ @@ -168,19 +166,23 @@ private static function validateTimeZone($timeZone) public static function convertIsoDate($value) { if (!is_string($value)) { - throw new Exception('Non-string value supplied for Iso Date conversion'); + throw new PhpSpreadsheetException('Non-string value supplied for Iso Date conversion'); } - $date = new DateTime($value); + try { + $date = new DateTime($value); + } catch (Exception $e) { + throw new PhpSpreadsheetException("Invalid string $value supplied for datatype Date"); + } $dateErrors = DateTime::getLastErrors(); if (is_array($dateErrors) && ($dateErrors['warning_count'] > 0 || $dateErrors['error_count'] > 0)) { - throw new Exception("Invalid string $value supplied for datatype Date"); + throw new PhpSpreadsheetException("Invalid string $value supplied for datatype Date"); } $newValue = SharedDate::PHPToExcel($date); if ($newValue === false) { - throw new Exception("Invalid string $value supplied for datatype Date"); + throw new PhpSpreadsheetException("Invalid string $value supplied for datatype Date"); } if (preg_match('/^\\d\\d:\\d\\d:\\d\\d/', $value) == 1) { @@ -194,9 +196,9 @@ public static function convertIsoDate($value) * Convert a MS serialized datetime value from Excel to a PHP Date/Time object. * * @param float|int $excelTimestamp MS Excel serialized date/time value - * @param null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp, - * if you don't want to treat it as a UTC value - * Use the default (UTC) unless you absolutely need a conversion + * @param null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp + * if you don't want to treat it as a UTC value + * Use the default (UTC) unless you absolutely need a conversion * * @return DateTime PHP date/time object */ @@ -211,7 +213,9 @@ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) // MS Excel calendar base dates if (self::$excelCalendar == self::CALENDAR_WINDOWS_1900) { // Allow adjustment for 1900 Leap Year in MS Excel - $baseDate = ($excelTimestamp < 60) ? new DateTime('1899-12-31', $timeZone) : new DateTime('1899-12-30', $timeZone); + $baseDate = ($excelTimestamp < 60) + ? new DateTime('1899-12-31', $timeZone) + : new DateTime('1899-12-30', $timeZone); } else { $baseDate = new DateTime('1904-01-01', $timeZone); } @@ -243,9 +247,9 @@ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) * They are not Y2038-safe on a 32-bit system, and have no timezone info. * * @param float|int $excelTimestamp MS Excel serialized date/time value - * @param null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp, - * if you don't want to treat it as a UTC value - * Use the default (UTC) unless you absolutely need a conversion + * @param null|DateTimeZone|string $timeZone The timezone to assume for the Excel timestamp + * if you don't want to treat it as a UTC value + * Use the default (UTC) unless you absolutely need a conversion * * @return int Unix timetamp for this date/time */ @@ -527,7 +531,8 @@ public static function monthStringToNumber($monthName) * * @param string $day Day number with an ordinal * - * @return int|string The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric + * @return int|string The integer value with any ordinal stripped, + * or the original string argument if it isn't a valid numeric */ public static function dayStringToNumber($day) { diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index 16026c3ca0..9153b8efa5 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -550,7 +550,7 @@ public static function convertToNumberIfFraction(string &$operand): bool $sign = ($match[1] == '-') ? '-' : '+'; $wholePart = ($match[3] === '') ? '' : ($sign . $match[3]); $fractionFormula = '=' . $wholePart . $sign . $match[4]; - $operand = Calculation::getInstance()->_calculateFormulaValue($fractionFormula); + $operand = Calculation::getInstance()->calculateFormulaValue($fractionFormula); return true; } diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 364700e253..da021851e8 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\Style; @@ -13,7 +14,7 @@ class Spreadsheet { - // Allowable values for workbook window visilbity + // Allowable values for workbook window visibility const VISIBILITY_VISIBLE = 'visible'; const VISIBILITY_HIDDEN = 'hidden'; const VISIBILITY_VERY_HIDDEN = 'veryHidden'; @@ -55,6 +56,14 @@ class Spreadsheet */ private $workSheetCollection = []; + /** + * Base calendar year to use for calculations + * Value is either CALENDAR_WINDOWS_1900 (1900) or CALENDAR_MAC_1904 (1904). + * + * @var int + */ + protected $excelCalendar = Date::CALENDAR_WINDOWS_1900; + /** * Calculation Engine. * @@ -202,6 +211,34 @@ class Spreadsheet */ private $tabRatio = 600; + /** + * Set the Excel Calendar (Windows 1900 or Mac 1904). + * + * @param int $baseYear Excel base date (1900 or 1904) + * + * @return bool Success or failure + */ + public function setExcelCalendar(int $baseYear): bool + { + if (($baseYear == Date::CALENDAR_WINDOWS_1900) || ($baseYear == Date::CALENDAR_MAC_1904)) { + $this->excelCalendar = $baseYear; + + return true; + } + + return false; + } + + /** + * Return the Excel Calendar (Windows 1900 or Mac 1904). + * + * @return int Excel base date (1900 or 1904) + */ + public function getExcelCalendar(): int + { + return $this->excelCalendar; + } + /** * The workbook has macros ? * diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 8235ccf140..7797ec886f 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -872,7 +872,7 @@ public function getTitle() * * @return $this */ - public function setTitle($title, $updateFormulaCellReferences = true, $validate = true) + public function setTitle(string $title, bool $updateFormulaCellReferences = true, bool $validate = true) { // Is this a 'rename' or not? if ($this->getTitle() == $title) { @@ -1073,7 +1073,7 @@ public function setProtection(Protection $protection) * * @return string Highest column name */ - public function getHighestColumn($row = null) + public function getHighestColumn($row = null): string { if ($row === null) { return Coordinate::stringFromColumnIndex($this->cachedHighestColumn); @@ -1090,7 +1090,7 @@ public function getHighestColumn($row = null) * * @return string Highest column name that contains data */ - public function getHighestDataColumn($row = null) + public function getHighestDataColumn($row = null): string { return $this->cellCollection->getHighestColumn($row); } @@ -1103,7 +1103,7 @@ public function getHighestDataColumn($row = null) * * @return int Highest row number */ - public function getHighestRow($column = null) + public function getHighestRow(?string $column = null): int { if ($column === null) { return $this->cachedHighestRow; @@ -1120,19 +1120,31 @@ public function getHighestRow($column = null) * * @return int Highest row number that contains data */ - public function getHighestDataRow($column = null) + public function getHighestDataRow(?string $column = null): int { return $this->cellCollection->getHighestRow($column); } + /** + * Get highest worksheet column and highest row. + * + * @return string Highest column name and highest row number + */ + public function getHighestRowAndColumn(): string + { + return $this->getHighestColumn() . $this->getHighestRow(); + } + /** * Get highest worksheet column and highest row that have cell records. * - * @return array Highest column name and highest row number + * @return string Highest column name and highest row number */ - public function getHighestRowAndColumn() + public function getHighestDataRowAndColumn(): string { - return $this->cellCollection->getHighestRowAndColumn(); + $highestRowAndColumn = $this->cellCollection->getHighestRowAndColumn(); + + return $highestRowAndColumn['column'] . $highestRowAndColumn['row']; } /** @@ -1144,10 +1156,10 @@ public function getHighestRowAndColumn() * * @return $this */ - public function setCellValue($coordinate, $value) + public function setCellValue($coordinate, $value, bool $isArrayFormula = false, ?string $arrayFormulaRange = null) { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); - $this->getCell($cellAddress)->setValue($value); + $this->getCell($cellAddress)->setValue($value, $isArrayFormula, $arrayFormulaRange); return $this; } @@ -1165,9 +1177,15 @@ public function setCellValue($coordinate, $value) * * @return $this */ - public function setCellValueByColumnAndRow($columnIndex, $row, $value) - { - $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValue($value); + public function setCellValueByColumnAndRow( + $columnIndex, + $row, + $value, + bool $isArrayFormula = false, + ?string $arrayFormulaRange = null + ) { + $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row) + ->setValue($value, $isArrayFormula, $arrayFormulaRange); return $this; } @@ -1187,10 +1205,15 @@ public function setCellValueByColumnAndRow($columnIndex, $row, $value) * * @return $this */ - public function setCellValueExplicit($coordinate, $value, $dataType) - { + public function setCellValueExplicit( + $coordinate, + $value, + $dataType, + bool $isArrayFormula = false, + ?string $arrayFormulaRange = null + ) { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); - $this->getCell($cellAddress)->setValueExplicit($value, $dataType); + $this->getCell($cellAddress)->setValueExplicit($value, $dataType, $isArrayFormula, $arrayFormulaRange); return $this; } @@ -1214,9 +1237,15 @@ public function setCellValueExplicit($coordinate, $value, $dataType) * * @return $this */ - public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $dataType) - { - $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValueExplicit($value, $dataType); + public function setCellValueExplicitByColumnAndRow( + $columnIndex, + $row, + $value, + $dataType, + bool $isArrayFormula = false, + ?string $arrayFormulaRange = null + ) { + $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValueExplicit($value, $dataType, $isArrayFormula, $arrayFormulaRange); return $this; } @@ -2822,6 +2851,8 @@ public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $ $source = [$source]; } + $currentCellAddress = $this->cellCollection->getCurrentCoordinate(); + // start coordinate [$startColumn, $startRow] = Coordinate::coordinateFromString($startCell); @@ -2829,15 +2860,16 @@ public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $ foreach ($source as $rowData) { $currentColumn = $startColumn; foreach ($rowData as $cellValue) { + $cell = $this->getCell($currentColumn . $startRow); if ($strictNullComparison) { if ($cellValue !== $nullValue) { // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); + $cell->setValue($cellValue, $cell->isArrayFormula(), $cell->arrayFormulaRange()); } } else { if ($cellValue != $nullValue) { // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); + $cell->setValue($cellValue, $cell->isArrayFormula(), $cell->arrayFormulaRange()); } } ++$currentColumn; @@ -2845,6 +2877,10 @@ public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $ ++$startRow; } + if ($currentCellAddress !== null) { + $this->getCell($currentCellAddress); + } + return $this; } @@ -2862,6 +2898,8 @@ public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $ */ public function rangeToArray($range, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { + $currentCellAddress = $this->cellCollection->getCurrentCoordinate(); + // Returnvalue $returnValue = []; // Identify the range that we need to extract from the worksheet @@ -2914,6 +2952,10 @@ public function rangeToArray($range, $nullValue = null, $calculateFormulas = tru } } + if ($currentCellAddress !== null) { + $this->getCell($currentCellAddress); + } + // Return return $returnValue; } @@ -2986,15 +3028,20 @@ public function namedRangeToArray(string $definedName, $nullValue = null, $calcu */ public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { + $currentCellAddress = $this->cellCollection->getCurrentCoordinate(); + // Garbage collect... $this->garbageCollect(); // Identify the range that we need to extract from the worksheet - $maxCol = $this->getHighestColumn(); - $maxRow = $this->getHighestRow(); + $maxCell = $this->getHighestDataRowAndColumn(); + + if ($currentCellAddress !== null) { + $this->getCell($currentCellAddress); + } // Return - return $this->rangeToArray('A1:' . $maxCol . $maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef); + return $this->rangeToArray('A1:' . $maxCell, $nullValue, $calculateFormulas, $formatData, $returnCellRef); } /** @@ -3088,7 +3135,7 @@ public function getHashCode() * @param string $range Range to extract title from * @param bool $returnRange Return range? (see example) * - * @return mixed + * @return string|string[] */ public static function extractSheetTitle($range, $returnRange = false) { @@ -3097,7 +3144,8 @@ public static function extractSheetTitle($range, $returnRange = false) } // Sheet title included? - if (($sep = strrpos($range, '!')) === false) { + $sep = strrpos($range, '!'); + if ($sep === false) { return $returnRange ? ['', $range] : ''; } diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 0fef0f6071..b7796d0272 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -64,13 +64,6 @@ class Html extends BaseWriter */ private $useInlineCss = false; - /** - * Use embedded CSS? - * - * @var bool - */ - private $useEmbeddedCSS = true; - /** * Array of CSS styles. * @@ -1596,38 +1589,6 @@ public function setUseInlineCss($useInlineCss) return $this; } - /** - * Get use embedded CSS? - * - * @return bool - * - * @codeCoverageIgnore - * - * @deprecated no longer used - */ - public function getUseEmbeddedCSS() - { - return $this->useEmbeddedCSS; - } - - /** - * Set use embedded CSS? - * - * @param bool $useEmbeddedCSS - * - * @return $this - * - * @codeCoverageIgnore - * - * @deprecated no longer used - */ - public function setUseEmbeddedCSS($useEmbeddedCSS) - { - $this->useEmbeddedCSS = $useEmbeddedCSS; - - return $this; - } - /** * Add color to formatted string as inline style. * diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index 00ab0643d9..b6f5f1de94 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -221,6 +221,11 @@ private function writeCells(XMLWriter $objWriter, RowCellIterator $cells): void // don't do anything } } + if ($cell->isArrayFormula()) { + [$columnSpan, $rowSpan] = Coordinate::rangeDimension((string) $cell->arrayFormulaRange()); + $objWriter->writeAttribute('table:number-matrix-rows-spanned', $rowSpan); + $objWriter->writeAttribute('table:number-matrix-columns-spanned', $columnSpan); + } $objWriter->writeAttribute('table:formula', $this->formulaConvertor->convertFormula($cell->getValue())); if (is_numeric($formulaValue)) { $objWriter->writeAttribute('office:value-type', 'float'); diff --git a/src/PhpSpreadsheet/Writer/Ods/Formula.php b/src/PhpSpreadsheet/Writer/Ods/Formula.php index db766fb42e..6743f08987 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Formula.php +++ b/src/PhpSpreadsheet/Writer/Ods/Formula.php @@ -23,6 +23,7 @@ public function convertFormula(string $formula, string $worksheetName = ''): str { $formula = $this->convertCellReferences($formula, $worksheetName); $formula = $this->convertDefinedNames($formula); + $formula = $this->convertFunctionNames($formula); if (substr($formula, 0, 1) !== '=') { $formula = '=' . $formula; @@ -31,6 +32,11 @@ public function convertFormula(string $formula, string $worksheetName = ''): str return 'of:' . $formula; } + private function convertFunctionNames(string $formula): string + { + return (string) preg_replace('/_xlfn\./ui', 'COM.MICROSOFT.', $formula); + } + private function convertDefinedNames(string $formula): string { $splitCount = preg_match_all( diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index ccffa181b6..876f2bded0 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -960,9 +960,9 @@ private function writeDateMode(): void $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow - $f1904 = (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) - ? 1 - : 0; // Flag for 1904 date system + $f1904 = ($this->spreadsheet->getExcelCalendar() === Date::CALENDAR_MAC_1904) + ? 1 // Flag for 1904 date system + : 0; // Flag for 1900 date system $header = pack('vv', $record, $length); $data = pack('v', $f1904); diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index c9446e7077..c7a44b46cc 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -20,6 +20,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes; use PhpOffice\PhpSpreadsheet\Writer\Xlsx\DocProps; use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Metadata; use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels; use PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsRibbon; use PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsVBA; @@ -158,6 +159,11 @@ class Xlsx extends BaseWriter */ private $writerPartStringTable; + /** + * @var Metadata + */ + private $writerPartMetadata; + /** * @var Style */ @@ -199,6 +205,7 @@ public function __construct(Spreadsheet $spreadsheet) $this->writerPartRels = new Rels($this); $this->writerPartRelsRibbon = new RelsRibbon($this); $this->writerPartRelsVBA = new RelsVBA($this); + $this->writerPartMetadata = new Metadata($this); $this->writerPartStringTable = new StringTable($this); $this->writerPartStyle = new Style($this); $this->writerPartTheme = new Theme($this); @@ -263,6 +270,11 @@ public function getWriterPartRelsVBA(): RelsVBA return $this->writerPartRelsVBA; } + public function getWriterPartMetadata(): Metadata + { + return $this->writerPartMetadata; + } + public function getWriterPartStringTable(): StringTable { return $this->writerPartStringTable; @@ -379,6 +391,9 @@ public function save($filename, int $flags = 0): void // Add theme to ZIP file $zipContent['xl/theme/theme1.xml'] = $this->getWriterPartTheme()->writeTheme($this->spreadSheet); + // Add metadata to ZIP file + $zipContent['xl/metadata.xml'] = $this->getWriterPartMetadata()->writeMetadata(); + // Add string table to ZIP file $zipContent['xl/sharedStrings.xml'] = $this->getWriterPartStringTable()->writeStringTable($this->stringTable); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index acb85b5788..7fd1d5c47e 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -82,6 +82,9 @@ public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = fal $this->writeOverrideContentType($objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'); } + // Shared strings + $this->writeOverrideContentType($objWriter, '/xl/metadata.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml'); + // Shared strings $this->writeOverrideContentType($objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Metadata.php b/src/PhpSpreadsheet/Writer/Xlsx/Metadata.php new file mode 100644 index 0000000000..72959100dc --- /dev/null +++ b/src/PhpSpreadsheet/Writer/Xlsx/Metadata.php @@ -0,0 +1,181 @@ + '1', + 'coerce' => '1', + 'assign' => '1', + 'clearComments' => '1', + 'clearFormats' => '1', + 'rowColShift' => '1', + 'splitFirst' => '1', + 'merge' => '1', + 'pasteValues' => '1', + 'pasteAll' => '1', + 'copy' => '1', + 'minSupportedVersion' => '120000', + 'name' => 'XLDAPR', + ], + [ + 'coerce' => '1', + 'assign' => '1', + 'clearComments' => '1', + 'clearFormats' => '1', + 'rowColShift' => '1', + 'splitFirst' => '1', + 'merge' => '1', + 'pasteValues' => '1', + 'pasteAll' => '1', + 'copy' => '1', + 'minSupportedVersion' => '120000', + 'name' => 'XLRICHVALUE', + ], + ]; + + protected const FUTURE_METADATA = [ + 'XLDAPR' => [ + [ + 'uri' => '{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}', + 'xda:dynamicArrayProperties' => [ + 'fCollapsed' => '0', + 'fDynamic' => '1', + ], + ], + ], + 'XLRICHVALUE' => [ + [ + 'uri' => '{3e2802c4-a4d2-4d8b-9148-e3be6c30e623}', + 'xlrd:rvb' => [ + 'i' => '0', + ], + ], + ], + ]; + + protected const EXTRA_METADATA = [ + 'cellMetadata' => [ + [ + 'v' => '0', + 't' => '1', + ], + ], + 'valueMetadata' => [ + [ + 'v' => '0', + 't' => '2', + ], + ], + ]; + + /** + * Write metadata to XML format. + * + * @return string XML Output + */ + public function writeMetadata() + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + $objWriter->startElement('metadata'); + $objWriter->writeAttribute('xmlns:xda', 'http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray'); + $objWriter->writeAttribute('xmlns:xlrd', 'http://schemas.microsoft.com/office/spreadsheetml/2017/richdata'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + + $this->writeMetadataTypes($objWriter); + $this->writeFutureMetadata($objWriter); + $this->writeExtraMetadata($objWriter); + + $objWriter->endElement(); // metadata + + return $objWriter->getData(); + } + + private function writeMetadataTypes(XMLWriter $objWriter): void + { + $objWriter->startElement('metadataTypes'); + $objWriter->writeAttribute('count', (string) count(self::METADATA_TYPES)); + + foreach (self::METADATA_TYPES as $metadataType) { + $objWriter->startElement('metadataType'); + + foreach ($metadataType as $metadataTypeKey => $metadataTypeValue) { + $objWriter->writeAttribute($metadataTypeKey, $metadataTypeValue); + } + + $objWriter->endElement(); //metadataType + } + + $objWriter->endElement(); //metadataTypes + } + + private function writeFutureMetadata(XMLWriter $objWriter): void + { + foreach (self::FUTURE_METADATA as $name => $futureMetadata) { + $objWriter->startElement('futureMetadata'); + $objWriter->writeAttribute('count', (string) count($futureMetadata)); + $objWriter->writeAttribute('name', $name); + + foreach ($futureMetadata as $futureMetadatum) { + $objWriter->startElement('bk'); + $objWriter->startElement('extLst'); + + $ext = array_shift($futureMetadatum); + $objWriter->startElement('ext'); + $objWriter->writeAttribute('uri', $ext); + + foreach ($futureMetadatum as $extElementName => $extElementProperties) { + $objWriter->startElement($extElementName); + + foreach ($extElementProperties as $extElementPropertyName => $extElementPropertyValue) { + $objWriter->writeAttribute($extElementPropertyName, $extElementPropertyValue); + } + + $objWriter->endElement(); // ext + } + + $objWriter->endElement(); // ext + $objWriter->endElement(); // extLst + $objWriter->endElement(); // bk + } + + $objWriter->endElement(); // futureMetadata + } + } + + private function writeExtraMetadata(XMLWriter $objWriter): void + { + foreach (self::EXTRA_METADATA as $name => $metadata) { + $objWriter->startElement($name); + $objWriter->writeAttribute('count', (string) count($metadata)); + + foreach ($metadata as $metadatum) { + $objWriter->startElement('bk'); + $objWriter->startElement('rc'); + + foreach ($metadatum as $attributeName => $attrbuteValue) { + $objWriter->writeAttribute($attributeName, $attrbuteValue); + } + + $objWriter->endElement(); // rc + $objWriter->endElement(); // bk + } + + $objWriter->endElement(); + } + } +} diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 99fa2d34aa..38a0ca66f4 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -138,6 +138,17 @@ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) 'worksheets/sheet' . ($i + 1) . '.xml' ); } + + // Relationship sharedStrings.xml + // id : just after the last sheet + $this->writeRelationship( + $objWriter, + ($i + 1 + 3), + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata', + 'metadata.xml' + ); + ++$i; //increment i if needed for an another relation + // Relationships for vbaProject if needed // id : just after the last sheet if ($spreadsheet->hasMacros()) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index 7d08388daa..a5f0650610 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -39,7 +39,7 @@ public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false) $this->writeFileVersion($objWriter); // workbookPr - $this->writeWorkbookPr($objWriter); + $this->writeWorkbookPr($objWriter, $spreadsheet); // workbookProtection $this->writeWorkbookProtection($objWriter, $spreadsheet); @@ -80,11 +80,11 @@ private function writeFileVersion(XMLWriter $objWriter): void /** * Write WorkbookPr. */ - private function writeWorkbookPr(XMLWriter $objWriter): void + private function writeWorkbookPr(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { $objWriter->startElement('workbookPr'); - if (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) { + if ($spreadsheet->getExcelCalendar() === Date::CALENDAR_MAC_1904) { $objWriter->writeAttribute('date1904', '1'); } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 1aa4f1ca3c..b62c557daa 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -1279,9 +1279,21 @@ private function writeCellError(XMLWriter $objWriter, string $mappedType, string $objWriter->writeElement('v', $cellIsFormula ? $formulaerr : $cellValue); } + private const CM_SPILLAGE_ARRAY_FUNCTIONS = '/\b(' . + 'anchorarray|' . + 'filter|' . + 'randarray|' . + 'sequence|' . + 'sort|' . + 'sortby|' . + 'unique' . + ')\(/ui'; + private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell $cell): void { - $calculatedValue = $this->getParentWriter()->getPreCalculateFormulas() ? $cell->getCalculatedValue() : $cellValue; + $calculatedValue = $this->getParentWriter()->getPreCalculateFormulas() + ? $cell->getCalculatedValue() : $cellValue; + if (is_string($calculatedValue)) { if (ErrorValue::isError($calculatedValue)) { $this->writeCellError($objWriter, 'e', $cellValue, $calculatedValue); @@ -1297,23 +1309,28 @@ private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell $attributes = $cell->getFormulaAttributes(); if (($attributes['t'] ?? null) === 'array') { + if (preg_match(self::CM_SPILLAGE_ARRAY_FUNCTIONS, $cellValue) === 1) { + $objWriter->writeAttribute('cm', '1'); + } + $objWriter->startElement('f'); $objWriter->writeAttribute('t', 'array'); - $objWriter->writeAttribute('ref', $cell->getCoordinate()); - $objWriter->writeAttribute('aca', '1'); - $objWriter->writeAttribute('ca', '1'); - $objWriter->text(substr($cellValue, 1)); + $objWriter->writeAttribute('ref', $attributes['ref'] ?? $cell->getCoordinate()); + $objWriter->writeAttribute('aca', '1'); // Always calculate array, true + $objWriter->writeAttribute('ca', '1'); // Calculate cell, true + $objWriter->text(Xlfn::addXlfnStripEquals($cellValue)); $objWriter->endElement(); } else { $objWriter->writeElement('f', Xlfn::addXlfnStripEquals($cellValue)); - self::writeElementIf( - $objWriter, - $this->getParentWriter()->getOffice2003Compatibility() === false, - 'v', - ($this->getParentWriter()->getPreCalculateFormulas() && !is_array($calculatedValue) && substr($calculatedValue ?? '', 0, 1) !== '#') - ? StringHelper::formatNumber($calculatedValue) : '0' - ); } + + self::writeElementIf( + $objWriter, + $this->getParentWriter()->getOffice2003Compatibility() === false, + 'v', + ($this->getParentWriter()->getPreCalculateFormulas() && !is_array($calculatedValue) && substr($calculatedValue ?? '', 0, 1) !== '#') + ? StringHelper::formatNumber($calculatedValue) : '0' + ); } /** diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php b/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php index a1bdf96a5d..ca78ebe668 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php @@ -132,8 +132,10 @@ class Xlfn . '|sumifs' . '|textjoin' // functions added with Excel 365 + . '|anchorarray' // Pseudo-function used by the Spill Operator: =A1# => =ANCHORARRAY(A1) . '|filter' . '|randarray' + . '|single' // Pseudo-function used by the Single Operator: =@A1 => =SINGLE(A1) . '|sequence' . '|sort' . '|sortby' diff --git a/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php index ef8c398248..f962aa7926 100644 --- a/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php @@ -40,7 +40,7 @@ protected function tearDown(): void */ public function testArrayFormula(string $formula, $expectedResult): void { - $result = Calculation::getInstance()->_calculateFormulaValue($formula); + $result = Calculation::getInstance()->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } @@ -71,6 +71,306 @@ public function providerArrayFormulae(): array '=IFS(FALSE, {1,2,3}, TRUE, {4,5,6})', [[4, 5, 6]], ], + [ + '=UNIQUE( + {"Grant";"Barbara";"Frances";"Alicia";"Alicia";"Lynn";"Barbara";"Anthony";"Anthony";"Frances"} + &" "& + {"Fife";"Pruitt";"Horn";"Barrett";"Barrett";"Larson";"Pruitt";"Snook";"Snook";"Horn"} + )', + [['Grant Fife'], ['Barbara Pruitt'], ['Frances Horn'], ['Alicia Barrett'], ['Lynn Larson'], ['Anthony Snook']], + ], + [ + '=UNIQUE( + {"Grant";"Barbara";"Frances";"Alicia";"Alicia";"Lynn";"Barbara";"Anthony";"Anthony";"Frances"} + &" "& + {"Fife";"Pruitt";"Horn";"Barrett";"Barrett";"Larson";"Pruitt";"Snook";"Snook";"Horn"}, + false, + true + )', + [['Grant Fife'], ['Lynn Larson']], + ], + ]; + } + + /** + * @dataProvider providerArrayArithmetic + * + * @param mixed $expectedResult + */ + public function testArrayArithmetic(string $formula, $expectedResult): void + { + $result = Calculation::getInstance()->calculateFormulaValue($formula); + self::assertEquals($expectedResult, $result); + } + + public function providerArrayArithmetic(): array + { + return [ + // Addition + 'Addition: row vector 2 + column vector 2' => [ + '={2,3} + {4;5}', + [[6, 7], [7, 8]], + ], + 'Addition: square matrix 2x2 + scalar' => [ + '={1,2;3,4} + 1', + [[2, 3], [4, 5]], + ], + 'Addition: square matrix 2x2 + 2x2' => [ + '={1,2;3,4} + {-2,4;-6,8}', + [[-1, 6], [-3, 12]], + ], + 'Addition: row vector + row vector' => [ + '={1,2,3} + {4,5,6}', + [[5, 7, 9]], + ], + 'Addition: column vector + column vector' => [ + '={1;2;3} + {4;5;6}', + [[5], [7], [9]], + ], + 'Addition: row vector + column vector' => [ + '={1,2,3} + {4;5;6}', + [[5, 6, 7], [6, 7, 8], [7, 8, 9]], + ], + 'Addition: column vector + row vector' => [ + '={1;2;3} + {4,5,6}', + [[5, 6, 7], [6, 7, 8], [7, 8, 9]], + ], + 'Addition: matrix 3x2 + 3x2' => [ + '={1,2,3;4,5,6} + {7,8,9;10,11,12}', + [[8, 10, 12], [14, 16, 18]], + ], + 'Addition: matrix 2x3 + 2x3' => [ + '={1,4;2,5;3,6} + {7,10;8,11;9,12}', + [[8, 14], [10, 16], [12, 18]], + ], + 'Addition: matrix 3x2 + 2x3' => [ + '={1,2,3;4,5,6} + {7,10;8,11;9,12}', + [[8, 12], [12, 16]], + ], + 'Addition: matrix 2x3 + 3x2' => [ + '={7,10;8,11;9,12} + {1,2,3;4,5,6}', + [[8, 12], [12, 16]], + ], + // Subtraction + 'Subtraction: row vector 2 - column vector 2' => [ + '={2,3} - {4;5}', + [[-2, -1], [-3, -2]], + ], + 'Subtraction: square matrix 2x2 - scalar' => [ + '={1,2;3,4} - 1', + [[0, 1], [2, 3]], + ], + 'Subtraction: square matrix 2x2 - 2x2' => [ + '={1,2;3,4} - {-2,4;-6,8}', + [[3, -2], [9, -4]], + ], + 'Subtraction: row vector - row vector' => [ + '={1,2,3} - {4,5,6}', + [[-3, -3, -3]], + ], + 'Subtraction: column vector - column vector' => [ + '={1;2;3} - {4;5;6}', + [[-3], [-3], [-3]], + ], + 'Subtraction: row vector - column vector' => [ + '={1,2,3} - {4;5;6}', + [[-3, -2, -1], [-4, -3, -2], [-5, -4, -3]], + ], + 'Subtraction: column vector - row vector' => [ + '={1;2;3} - {4,5,6}', + [[-3, -4, -5], [-2, -3, -4], [-1, -2, -3]], + ], + 'Subtraction: matrix 3x2 - 3x2' => [ + '={1,2,3;4,5,6} - {7,8,9;10,11,12}', + [[-6, -6, -6], [-6, -6, -6]], + ], + 'Subtraction: matrix 2x3 - 2x3' => [ + '={1,4;2,5;3,6} - {7,10;8,11;9,12}', + [[-6, -6], [-6, -6], [-6, -6]], + ], + 'Subtraction: matrix 3x2 - 2x3' => [ + '={1,2,3;4,5,6} - {7,10;8,11;9,12}', + [[-6, -8], [-4, -6]], + ], + 'Subtraction: matrix 2x3 - 3x2' => [ + '={7,10;8,11;9,12} - {1,2,3;4,5,6}', + [[6, 8], [4, 6]], + ], + // Multiplication + 'Multiplication: square matrix 2x2 * 2x2' => [ + '={1,2;3,4} * {-2,4;-6,8}', + [[-2, 8], [-18, 32]], + ], + 'Multiplication: square matrix 2x2 * scalar' => [ + '={1,2;3,4} * 2', + [[2, 4], [6, 8]], + ], + 'Multiplication: row vector * row vector' => [ + '={1,2,3} * {4,5,6}', + [[4, 10, 18]], + ], + 'Multiplication: column vector * column vector' => [ + '={1;2;3} * {4;5;6}', + [[4], [10], [18]], + ], + 'Multiplication: row vector * column vector' => [ + '={1,2,3} * {4;5;6}', + [[4, 8, 12], [5, 10, 15], [6, 12, 18]], + ], + 'Multiplication: column vector * row vector' => [ + '={1;2;3} * {4,5,6}', + [[4, 5, 6], [8, 10, 12], [12, 15, 18]], + ], + 'Multiplication: matrix 3x2 * 3x2' => [ + '={1,2,3;4,5,6} * {7,8,9;10,11,12}', + [[7, 16, 27], [40, 55, 72]], + ], + 'Multiplication: matrix 2x3 * 2x3' => [ + '={1,4;2,5;3,6} * {7,10;8,11;9,12}', + [[7, 40], [16, 55], [27, 72]], + ], + 'Multiplication: row vector 2 * column vector 2' => [ + '={2,3} * {4;5}', + [[8, 12], [10, 15]], + ], + 'Multiplication: matrix 3x2 * 2x3' => [ + '={1,2,3;4,5,6} * {7,10;8,11;9,12}', + [[7, 20], [32, 55]], + ], + 'Multiplication: matrix 2x3 * 3x2' => [ + '={7,10;8,11;9,12} * {1,2,3;4,5,6}', + [[7, 20], [32, 55]], + ], + // Division + 'Division: square matrix 2x2 / 2x2' => [ + '={1,2;3,4} / {-2,4;-6,8}', + [[-0.5, 0.5], [-0.5, 0.5]], + ], + 'Division: square matrix 2x2 / scalar' => [ + '={1,2;3,4} / 0.5', + [[2, 4], [6, 8]], + ], + 'Division: row vector / row vector' => [ + '={1,2,3} / {4,5,6}', + [[0.25, 0.4, 0.5]], + ], + 'Division: column vector / column vector' => [ + '={1;2;3} / {4;5;6}', + [[0.25], [0.4], [0.5]], + ], + 'Division: row vector / column vector' => [ + '={1,2,3} / {4;5;6}', + [[0.25, 0.5, 0.75], [0.2, 0.4, 0.6], [0.16666666666666667, 0.3333333333333333, 0.5]], + ], + 'Division: column vector / row vector' => [ + '={1;2;3} / {4,5,6}', + [[0.25, 0.2, 0.16666666666666667], [0.5, 0.4, 0.3333333333333333], [0.75, 0.6, 0.5]], + ], + 'Division: matrix 3x2 / 3x2' => [ + '={1,2,3;4,5,6} / {7,8,9;10,11,12}', + [[0.14285714285714285, 0.25, 0.3333333333333333], [0.4, 0.45454545454545453, 0.5]], + ], + 'Division: matrix 2x3 / 2x3' => [ + '={1,4;2,5;3,6} / {7,10;8,11;9,12}', + [[0.14285714285714285, 0.4], [0.25, 0.45454545454545453], [0.3333333333333333, 0.5]], + ], + 'Division: row vector 2 / column vector 2' => [ + '={2,3} / {4;5}', + [[0.5, 0.75], [0.4, 0.6]], + ], + 'Division: matrix 3x2 / 2x3' => [ + '={1,2,3;4,5,6} / {7,10;8,11;9,12}', + [[0.14285714285714285, 0.2], [0.5, 0.45454545454545453]], + ], + 'Division: matrix 2x3 / 3x2' => [ + '={7,10;8,11;9,12} / {1,2,3;4,5,6}', + [[7, 5], [2, 2.2]], + ], + // Power + 'Power: square matrix 2x2 ^ 2x2' => [ + '={1,2;3,4} ^ {-2,4;-6,8}', + [[1, 16], [0.0013717421124828531, 65536]], + ], + 'Power: square matrix 2x2 ^ scalar' => [ + '={1,2;3,4} ^ 2', + [[1, 4], [9, 16]], + ], + 'Power: row vector ^ row vector' => [ + '={1,2,3} ^ {4,5,6}', + [[1, 32, 729]], + ], + 'Power: column vector / column vector' => [ + '={1;2;3} ^ {4;5;6}', + [[1], [32], [729]], + ], + 'Power: row vector ^ column vector' => [ + '={1,2,3} ^ {4;5;6}', + [[1, 16, 81], [1, 32, 243], [1, 64, 729]], + ], + 'Power: column vector ^ row vector' => [ + '={1;2;3} ^ {4,5,6}', + [[1, 1, 1], [16, 32, 64], [81, 243, 729]], + ], + 'Power: matrix 3x2 ^ 3x2' => [ + '={1,2,3;4,5,6} ^ {7,8,9;10,11,12}', + [[1, 256, 19683], [1048576, 48828125, 2176782336]], + ], + 'Power: matrix 2x3 ^ 2x3' => [ + '={1,4;2,5;3,6} ^ {7,10;8,11;9,12}', + [[1, 1048576], [256, 48828125], [19683, 2176782336]], + ], + 'Power: row vector 2 ^ column vector 2' => [ + '={2,3} ^ {4;5}', + [[16, 81], [32, 243]], + ], + 'Power: matrix 3x2 ^ 2x3' => [ + '={1,2,3;4,5,6} ^ {7,10;8,11;9,12}', + [[1, 1024], [65536, 48828125]], + ], + 'Power: matrix 2x3 ^ 3x2' => [ + '={7,10;8,11;9,12} ^ {1,2,3;4,5,6}', + [[7, 100], [4096, 161051]], + ], + // Concatenation + 'Concatenation: row vector 2 & column vector 2' => [ + '={"A",",B"} & {"C";";D"}', + [['AC', ',BC'], ['A;D', ',B;D']], + ], + 'Concatenation: matrix 3x2 & 3x2' => [ + '={"A","B","C";"D","E","F"} & {"G","H","I";"J","K","L"}', + [['AG', 'BH', 'CI'], ['DJ', 'EK', 'FL']], + ], + 'Concatenation: matrix 2x3 & 2x3' => [ + '={"A","B";"C","D";"E","F"} & {"G","H";"I","J";"K","L"}', + [['AG', 'BH'], ['CI', 'DJ'], ['EK', 'FL']], + ], + 'Concatenation: 2x2 matrix & scalar' => [ + '={"A","B";"C","D"} & "E"', + [['AE', 'BE'], ['CE', 'DE']], + ], + 'Concatenation: scalar & 2x2 matrix' => [ + '="E" & {"A","B";"C","D"}', + [['EA', 'EB'], ['EC', 'ED']], + ], + 'Concatenation: 2x2 & 2x1 vector' => [ + '={"A","B";"C","D"} & {"E","F"}', + [['AE', 'BF'], ['CE', 'DF']], + ], + 'Concatenation: 2x2 & 1x2 vector' => [ + '={"A","B";"C","D"} & {"E";"F"}', + [['AE', 'BE'], ['CF', 'DF']], + ], + + // Unary Negation + 'Unary Negation: square matrix - 2x2' => [ + '= - {-2,4;-6,8}', + [[2, -4], [6, -8]], + ], + // Percentage + 'Percentage: square matrix % 2x2' => [ + '={-2,4;-6,8} %', + [[-0.02, 0.04], [-0.06, 0.08]], + ], ]; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationErrorTest.php index 23ee5ba86b..a883cec290 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationErrorTest.php @@ -14,7 +14,7 @@ public function testCalculationException(): void $this->expectException(CalcException::class); $this->expectExceptionMessage('Formula Error:'); $calculation = Calculation::getInstance(); - $result = $calculation->_calculateFormulaValue('=SUM('); + $result = $calculation->calculateFormulaValue('=SUM('); self::assertFalse($result); } @@ -25,7 +25,7 @@ public function testCalculationError(): void $error = false; try { - $calculation->_calculateFormulaValue('=SUM('); + $calculation->calculateFormulaValue('=SUM('); } catch (Throwable $e) { self::assertSame("Formula Error: Expecting ')'", $e->getMessage()); self::assertSame('PHPUnit\\Framework\\Error\\Error', get_class($e)); @@ -47,7 +47,7 @@ public function testCalculationErrorTrulySuppressed(): void $calculation = Calculation::getInstance(); $calculation->suppressFormulaErrors = true; set_error_handler([self::class, 'errhandler2']); - $result = $calculation->_calculateFormulaValue('=SUM('); + $result = $calculation->calculateFormulaValue('=SUM('); restore_error_handler(); self::assertFalse($result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php index e95c32677d..23f591aeaf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php @@ -54,10 +54,10 @@ public function providerGetFunctions(): array public function testIsImplemented(): void { $calculation = Calculation::getInstance(); - self::assertFalse($calculation->isImplemented('non-existing-function')); - self::assertFalse($calculation->isImplemented('AREAS')); - self::assertTrue($calculation->isImplemented('coUNt')); - self::assertTrue($calculation->isImplemented('abs')); + self::assertFalse($calculation->isImplemented('non-existing-function'), 'Non-existent Function'); + self::assertFalse($calculation->isImplemented('AREAS'), 'AREAS()'); + self::assertTrue($calculation->isImplemented('coUNt'), 'COUNT()'); + self::assertTrue($calculation->isImplemented('abs'), 'ABS()'); } public function testUnknownFunction(): void diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index 6a03fa1d1e..d097144aa1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -45,11 +45,11 @@ protected function tearDown(): void public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - $resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula); + $resultExcel = Calculation::getInstance()->calculateFormulaValue($formula); self::assertEquals($expectedResultExcel, $resultExcel, 'should be Excel compatible'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $resultOpenOffice = Calculation::getInstance()->_calculateFormulaValue($formula); + $resultOpenOffice = Calculation::getInstance()->calculateFormulaValue($formula); self::assertEquals($expectedResultOpenOffice, $resultOpenOffice, 'should be OpenOffice compatible'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index caa7f3962e..b717a83ce3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Engine; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PHPUnit\Framework\TestCase; @@ -49,7 +49,7 @@ public function providerRangeEvaluation(): array 'Count with INTERSECTION #1' => ['=COUNT(A1:B3 A1:C2)', 4], 'Sum with UNION #2' => ['=SUM(A1:A3,C1:C3)', 48], 'Count with UNION #2' => ['=COUNT(A1:A3,C1:C3)', 6], - 'Sum with INTERSECTION #2 - No Intersect' => ['=SUM(A1:A3 C1:C3)', Functions::null()], + 'Sum with INTERSECTION #2 - No Intersect' => ['=SUM(A1:A3 C1:C3)', ExcelError::null()], 'Count with INTERSECTION #2 - No Intersect' => ['=COUNT(A1:A3 C1:C3)', 0], 'Sum with UNION #3' => ['=SUM(A1:B2,B2:C3)', 64], 'Count with UNION #3' => ['=COUNT(A1:B2,B2:C3)', 8], diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DAverageTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DAverageTest.php index 8be895ebd7..245636a38d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DAverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DAverageTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DAverage; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDAverage($expectedResult, $database, $field, $criteria): void { - $result = Database::DAVERAGE($database, $field, $criteria); + $result = DAverage::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php index c7d704268a..d140f44a03 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DCountA; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDCountA($expectedResult, $database, $field, $criteria): void { - $result = Database::DCOUNTA($database, $field, $criteria); + $result = DCountA::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php index f1df35ae7c..3c2e820bea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DCount; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDCount($expectedResult, $database, $field, $criteria): void { - $result = Database::DCOUNT($database, $field, $criteria); + $result = DCount::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php index 6df9c1bd71..4237b392a5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DGet; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PHPUnit\Framework\TestCase; @@ -24,7 +24,7 @@ protected function setUp(): void */ public function testDGet($expectedResult, $database, $field, $criteria): void { - $result = Database::DGET($database, $field, $criteria); + $result = DGet::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php index 25f957dafa..97f8668bf8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DMax; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDMax($expectedResult, $database, $field, $criteria): void { - $result = Database::DMAX($database, $field, $criteria); + $result = DMax::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php index ca32d2879f..702c2571a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DMin; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDMin($expectedResult, $database, $field, $criteria): void { - $result = Database::DMIN($database, $field, $criteria); + $result = DMin::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php index 7567b44f23..c4804b9be4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php @@ -2,8 +2,8 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; -use PhpOffice\PhpSpreadsheet\Calculation\DateTime; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DProduct; +use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Helpers as DateTimeHelper; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -24,7 +24,7 @@ protected function setUp(): void */ public function testDProduct($expectedResult, $database, $field, $criteria): void { - $result = Database::DPRODUCT($database, $field, $criteria); + $result = DProduct::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } @@ -45,18 +45,18 @@ private function database2(): array { return [ ['Name', 'Date', 'Test', 'Score'], - ['Gary', DateTime::getDateValue('01-Jan-2017'), 'Test1', 4], - ['Gary', DateTime::getDateValue('01-Jan-2017'), 'Test2', 4], - ['Gary', DateTime::getDateValue('01-Jan-2017'), 'Test3', 3], - ['Gary', DateTime::getDateValue('05-Jan-2017'), 'Test1', 3], - ['Gary', DateTime::getDateValue('05-Jan-2017'), 'Test2', 4], - ['Gary', DateTime::getDateValue('05-Jan-2017'), 'Test3', 3], - ['Kev', DateTime::getDateValue('02-Jan-2017'), 'Test1', 2], - ['Kev', DateTime::getDateValue('02-Jan-2017'), 'Test2', 3], - ['Kev', DateTime::getDateValue('02-Jan-2017'), 'Test3', 5], - ['Kev', DateTime::getDateValue('05-Jan-2017'), 'Test1', 3], - ['Kev', DateTime::getDateValue('05-Jan-2017'), 'Test2', 2], - ['Kev', DateTime::getDateValue('05-Jan-2017'), 'Test3', 5], + ['Gary', DateTimeHelper::getDateValue('01-Jan-2017'), 'Test1', 4], + ['Gary', DateTimeHelper::getDateValue('01-Jan-2017'), 'Test2', 4], + ['Gary', DateTimeHelper::getDateValue('01-Jan-2017'), 'Test3', 3], + ['Gary', DateTimeHelper::getDateValue('05-Jan-2017'), 'Test1', 3], + ['Gary', DateTimeHelper::getDateValue('05-Jan-2017'), 'Test2', 4], + ['Gary', DateTimeHelper::getDateValue('05-Jan-2017'), 'Test3', 3], + ['Kev', DateTimeHelper::getDateValue('02-Jan-2017'), 'Test1', 2], + ['Kev', DateTimeHelper::getDateValue('02-Jan-2017'), 'Test2', 3], + ['Kev', DateTimeHelper::getDateValue('02-Jan-2017'), 'Test3', 5], + ['Kev', DateTimeHelper::getDateValue('05-Jan-2017'), 'Test1', 3], + ['Kev', DateTimeHelper::getDateValue('05-Jan-2017'), 'Test2', 2], + ['Kev', DateTimeHelper::getDateValue('05-Jan-2017'), 'Test3', 5], ]; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php index e62602e324..829f29f4c1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DStDevP; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDStDevP($expectedResult, $database, $field, $criteria): void { - $result = Database::DSTDEVP($database, $field, $criteria); + $result = DStDevP::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php index f0837e8134..10f3ace58b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DStDev; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDStDev($expectedResult, $database, $field, $criteria): void { - $result = Database::DSTDEV($database, $field, $criteria); + $result = DStDev::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php index 0cce63d811..b4b41b5e3c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DSum; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDSum($expectedResult, $database, $field, $criteria): void { - $result = Database::DSUM($database, $field, $criteria); + $result = DSum::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php index 1e9a8e276c..946dfa1257 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DVarP; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDVarP($expectedResult, $database, $field, $criteria): void { - $result = Database::DVARP($database, $field, $criteria); + $result = DVarP::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php index c62f13b48d..1a2f880e55 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Database; -use PhpOffice\PhpSpreadsheet\Calculation\Database; +use PhpOffice\PhpSpreadsheet\Calculation\Database\DVar; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDVar($expectedResult, $database, $field, $criteria): void { - $result = Database::DVAR($database, $field, $criteria); + $result = DVar::evaluate($database, $field, $criteria); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/AllSetupTeardown.php index 9fb5dfa58b..0cb3b62bd2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/AllSetupTeardown.php @@ -55,9 +55,13 @@ protected function tearDown(): void } } - protected static function setMac1904(): void + protected static function setMac1904(?Worksheet $worksheet = null): void { - Date::setExcelCalendar(Date::CALENDAR_MAC_1904); + if ($worksheet === null) { + Date::setExcelCalendar(Date::CALENDAR_MAC_1904); + } else { + $worksheet->getParent()->setExcelCalendar(Date::CALENDAR_MAC_1904); + } } protected static function setUnixReturn(): void diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index 77af98ee49..55c5d723e2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -37,7 +37,7 @@ public function testDateDifArray(array $expectedResult, string $startDate, strin } else { $formula = "=DATEDIF({$startDate}, {$endDate}, {$methods})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index 952664094c..d7d27980e7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -67,7 +67,7 @@ public function testDateArray(array $expectedResult, string $year, string $month $calculation = Calculation::getInstance(); $formula = "=DATE({$year}, {$month}, {$day})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } @@ -136,7 +136,7 @@ public function testDateArrayException(string $year, string $month, string $day) $this->expectExceptionMessage('Formulae with more than two array arguments are not supported'); $formula = "=DATE({$year}, {$month}, {$day})"; - $calculation->_calculateFormulaValue($formula); + $calculation->calculateFormulaValue($formula); } public function providerDateArrayException(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 1a3790e872..7a4b53eb97 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -82,7 +82,7 @@ public function testDateValueArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=DATEVALUE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index 8f5e947b2f..03245b2605 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -52,7 +52,7 @@ public function testDayArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=DAY({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php index 554d51530d..9fee06cfb7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -38,7 +38,7 @@ public function testDays360Array(array $expectedResult, string $startDate, strin } else { $formula = "=DAYS360({$startDate}, {$endDate}, {$methods})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 236b5178d7..ec48e39b60 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -52,7 +52,7 @@ public function testDaysArray(array $expectedResult, string $startDate, string $ $calculation = Calculation::getInstance(); $formula = "=DAYS({$startDate}, {$endDate})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php index 5b8479cb04..cb3db69a27 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -56,7 +56,7 @@ public function testEDateArray(array $expectedResult, string $dateValues, string $calculation = Calculation::getInstance(); $formula = "=EDATE({$dateValues}, {$methods})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php index 935b3cbc2f..8bb9df5277 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -55,7 +55,7 @@ public function testEoMonthArray(array $expectedResult, string $dateValues, stri $calculation = Calculation::getInstance(); $formula = "=EOMONTH({$dateValues}, {$methods})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php index c94451164e..d1fda4f2e0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -33,7 +33,7 @@ public function testHourArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=HOUR({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php index 1704bd6dd1..86b1389ba4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -35,8 +35,8 @@ public function providerISOWEEKNUM(): array public function testISOWEEKNUM1904($expectedResult, $dateValue): void { $this->mightHaveException($expectedResult); - self::setMac1904(); $sheet = $this->getSheet(); + self::setMac1904($sheet); $sheet->getCell('A1')->setValue("=ISOWEEKNUM($dateValue)"); $sheet->getCell('B1')->setValue('1954-11-23'); self::assertSame($expectedResult, $sheet->getCell('A1')->getCalculatedValue()); @@ -55,7 +55,7 @@ public function testIsoWeekNumArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ISOWEEKNUM({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php index bebc79ed29..b20ca78f91 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -33,7 +33,7 @@ public function testMinuteArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=MINUTE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php index 904492864c..ae7133c8da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -33,7 +33,7 @@ public function testMonthArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=MONTH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php deleted file mode 100644 index d14f7d7d24..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php +++ /dev/null @@ -1,63 +0,0 @@ -format('s'); - $nowResult = DateTime::DATETIMENOW(); - $todayResult = DateTime::DATENOW(); - $dtEnd = new DateTimeImmutable(); - $endSecond = $dtEnd->format('s'); - } while ($startSecond !== $endSecond); - self::assertSame(DateTime::DAYOFMONTH($nowResult), DateTime::DAYOFMONTH($todayResult)); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php index d5378b3527..562fb29abb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -64,7 +64,7 @@ public function testNetWorkDaysArray(array $expectedResult, string $startDate, s } else { $formula = "=NETWORKDAYS({$startDate}, {$endDays}, {$holidays})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php index c5b808f234..a2c2b850b1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -33,7 +33,7 @@ public function testSecondArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SECOND({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index 88271fea3b..4fc3a0d893 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -71,7 +71,7 @@ public function testTimeArray(array $expectedResult, string $hour, string $minut $calculation = Calculation::getInstance(); $formula = "=TIME({$hour}, {$minute}, {$second})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } @@ -140,7 +140,7 @@ public function testTimeArrayException(string $hour, string $minute, string $sec $this->expectExceptionMessage('Formulae with more than two array arguments are not supported'); $formula = "=TIME({$hour}, {$minute}, {$second})"; - $calculation->_calculateFormulaValue($formula); + $calculation->calculateFormulaValue($formula); } public function providerTimeArrayException(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index 0eb235f7cc..3f2f379e5c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -58,7 +58,7 @@ public function testTimeValueArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=TIMEVALUE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index e8d90f5f6a..0fc6898a17 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -42,7 +42,7 @@ public function testWeekDayArray(array $expectedResult, string $dateValues, stri $calculation = Calculation::getInstance(); $formula = "=WEEKDAY({$dateValues}, {$styles})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php index b2a067e950..c1c2fe774e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -33,8 +33,8 @@ public function providerWEEKNUM(): array public function testWEEKNUM1904($expectedResult, string $formula): void { $this->mightHaveException($expectedResult); - self::setMac1904(); $sheet = $this->getSheet(); + self::setMac1904($sheet); $sheet->getCell('B1')->setValue('1954-11-23'); $sheet->getCell('A1')->setValue("=WEEKNUM($formula)"); self::assertSame($expectedResult, $sheet->getCell('A1')->getCalculatedValue()); @@ -53,7 +53,7 @@ public function testWeekNumArray(array $expectedResult, string $dateValues, stri $calculation = Calculation::getInstance(); $formula = "=WEEKNUM({$dateValues}, {$methods})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php index 3b73828ff5..8580dbd231 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -64,7 +64,7 @@ public function testWorkDayArray(array $expectedResult, string $startDate, strin } else { $formula = "=WORKDAY({$startDate}, {$endDays}, {$holidays})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php index 9c78fbbe3c..7b68710556 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -56,7 +56,7 @@ public function testYearFracArray(array $expectedResult, string $startDate, stri } else { $formula = "=YEARFRAC({$startDate}, {$endDate}, {$methods})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php index 3e320c2416..0a77423d0f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -33,7 +33,7 @@ public function testYearArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=YEAR({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php deleted file mode 100644 index 48a3dcf07d..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php +++ /dev/null @@ -1,55 +0,0 @@ - [ - [Functions::class, 'null'], - ExcelError::null(), - ], - 'NAN' => [ - [Functions::class, 'NAN'], - ExcelError::NAN(), - ], - 'NA' => [ - [Functions::class, 'NA'], - ExcelError::NA(), - ], - 'NAME' => [ - [Functions::class, 'NAME'], - ExcelError::NAME(), - ], - 'REF' => [ - [Functions::class, 'REF'], - ExcelError::REF(), - ], - 'VALUE' => [ - [Functions::class, 'VALUE'], - ExcelError::VALUE(), - ], - 'DIV0' => [ - [Functions::class, 'DIV0'], - ExcelError::DIV0(), - ], - ]; - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php index 6e9673a880..b51ff36142 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\BesselI; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testBESSELI($expectedResult, ...$args): void { - $result = Engineering::BESSELI(...$args); + $result = BesselI::besselI(...$args); self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } @@ -40,7 +40,7 @@ public function testBesselIArray(array $expectedResult, string $value, string $o $calculation = Calculation::getInstance(); $formula = "=BESSELI({$value}, {$ord})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php index 16002ae5d0..466a6e8fc4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\BesselJ; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testBESSELJ($expectedResult, ...$args): void { - $result = Engineering::BESSELJ(...$args); + $result = BesselJ::besselJ(...$args); self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } @@ -40,7 +40,7 @@ public function testBesselJArray(array $expectedResult, string $value, string $o $calculation = Calculation::getInstance(); $formula = "=BESSELJ({$value}, {$ord})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php index 11e0885e21..40582b2804 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\BesselK; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testBESSELK($expectedResult, ...$args): void { - $result = Engineering::BESSELK(...$args); + $result = BesselK::besselK(...$args); self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } @@ -40,7 +40,7 @@ public function testBesselKArray(array $expectedResult, string $value, string $o $calculation = Calculation::getInstance(); $formula = "=BESSELK({$value}, {$ord})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php index 47f05e986f..7b1636c679 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\BesselY; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testBESSELY($expectedResult, ...$args): void { - $result = Engineering::BESSELY(...$args); + $result = BesselY::besselY(...$args); self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } @@ -40,7 +40,7 @@ public function testBesselYArray(array $expectedResult, string $value, string $o $calculation = Calculation::getInstance(); $formula = "=BESSELY({$value}, {$ord})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php index beb31bbb40..78622fad56 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -100,7 +100,7 @@ public function testBin2DecArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=BIN2DEC({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php index ccb2ce7930..8cf87fdf6c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -100,7 +100,7 @@ public function testBin2HexArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=BIN2HEX({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php index 513901a840..213269581c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -100,7 +100,7 @@ public function testBin2OctArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=BIN2OCT({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php index d5d8a26a90..3f4336feaf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -40,7 +40,7 @@ public function testBitAndArray(array $expectedResult, string $number1, string $ $calculation = Calculation::getInstance(); $formula = "=BITAND({$number1}, {$number2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php index 246299ac35..568e81ac95 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -40,7 +40,7 @@ public function testBitLShiftArray(array $expectedResult, string $number, string $calculation = Calculation::getInstance(); $formula = "=BITLSHIFT({$number}, {$bits})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php index 6addf05da6..54b016405e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -40,7 +40,7 @@ public function testBitOrArray(array $expectedResult, string $number1, string $n $calculation = Calculation::getInstance(); $formula = "=BITOR({$number1}, {$number2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php index 5c6f76c718..c7b7dafa82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -40,7 +40,7 @@ public function testBitRShiftArray(array $expectedResult, string $number, string $calculation = Calculation::getInstance(); $formula = "=BITRSHIFT({$number}, {$bits})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php index ed8f2065cc..0666d1e49c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -40,7 +40,7 @@ public function testBitXorArray(array $expectedResult, string $number1, string $ $calculation = Calculation::getInstance(); $formula = "=BITXOR({$number1}, {$number2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php index 827654add3..8fcbd02623 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Complex; use PHPUnit\Framework\TestCase; class ComplexTest extends TestCase @@ -16,13 +16,13 @@ class ComplexTest extends TestCase public function testCOMPLEX($expectedResult, ...$args): void { if (count($args) === 0) { - $result = Engineering::COMPLEX(); + $result = Complex::complex(); } elseif (count($args) === 1) { - $result = Engineering::COMPLEX($args[0]); + $result = Complex::complex($args[0]); } elseif (count($args) === 2) { - $result = Engineering::COMPLEX($args[0], $args[1]); + $result = Complex::complex($args[0], $args[1]); } else { - $result = Engineering::COMPLEX($args[0], $args[1], $args[2]); + $result = Complex::complex($args[0], $args[1], $args[2]); } self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testComplexArray(array $expectedResult, string $real, string $im $calculation = Calculation::getInstance(); $formula = "=COMPLEX({$real}, {$imaginary})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php index f15725cb5e..bc6a4a9c89 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ConvertUOM; use PHPUnit\Framework\TestCase; class ConvertUoMTest extends TestCase @@ -12,31 +12,31 @@ class ConvertUoMTest extends TestCase public function testGetConversionGroups(): void { - $result = Engineering::getConversionGroups(); + $result = ConvertUOM::getConversionCategories(); self::assertIsArray($result); } public function testGetConversionGroupUnits(): void { - $result = Engineering::getConversionGroupUnits(); + $result = ConvertUOM::getConversionCategoryUnits(); self::assertIsArray($result); } public function testGetConversionGroupUnitDetails(): void { - $result = Engineering::getConversionGroupUnitDetails(); + $result = ConvertUOM::getConversionCategoryUnitDetails(); self::assertIsArray($result); } public function testGetConversionMultipliers(): void { - $result = Engineering::getConversionMultipliers(); + $result = ConvertUOM::getConversionMultipliers(); self::assertIsArray($result); } public function testGetBinaryConversionMultipliers(): void { - $result = Engineering::getBinaryConversionMultipliers(); + $result = ConvertUOM::getBinaryConversionMultipliers(); self::assertIsArray($result); } @@ -47,7 +47,7 @@ public function testGetBinaryConversionMultipliers(): void */ public function testCONVERTUOM($expectedResult, ...$args): void { - $result = Engineering::CONVERTUOM(...$args); + $result = ConvertUOM::convert(...$args); self::assertEqualsWithDelta($expectedResult, $result, self::UOM_PRECISION); } @@ -64,7 +64,7 @@ public function testConvertUoMArray(array $expectedResult, string $value, string $calculation = Calculation::getInstance(); $formula = "=CONVERT({$value}, {$fromUoM}, {$toUoM})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, self::UOM_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php index db4c517d08..bfbe0f57d5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -100,7 +100,7 @@ public function testDec2BinArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=DEC2BIN({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php index 6200ac567c..9c72889e0c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -108,7 +108,7 @@ public function testDec2HexArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=DEC2HEX({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php index 2e6007c5e7..4511a6d9ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -100,7 +100,7 @@ public function testDec2OctArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=DEC2OCT({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php index 41d809cac1..6b5135d4d4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Compare; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testDELTA($expectedResult, $a, $b): void { - $result = Engineering::DELTA($a, $b); + $result = Compare::delta($a, $b); self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testDeltaArray(array $expectedResult, string $a, string $b): voi $calculation = Calculation::getInstance(); $formula = "=DELTA({$a}, {$b})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php index 88e808abee..030ef96c0c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ErfC; use PHPUnit\Framework\TestCase; class ErfCTest extends TestCase @@ -18,7 +18,7 @@ class ErfCTest extends TestCase */ public function testERFC($expectedResult, $lower): void { - $result = Engineering::ERFC($lower); + $result = ErfC::complementary($lower); self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } @@ -35,7 +35,7 @@ public function testErfCArray(array $expectedResult, string $lower): void $calculation = Calculation::getInstance(); $formula = "=ERFC({$lower})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php index 8a069ff146..bb3f2c13a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Erf; use PHPUnit\Framework\TestCase; class ErfPreciseTest extends TestCase @@ -18,7 +18,7 @@ class ErfPreciseTest extends TestCase */ public function testERFPRECISE($expectedResult, $limit): void { - $result = Engineering::ERFPRECISE($limit); + $result = Erf::precise($limit); self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } @@ -35,7 +35,7 @@ public function testErfPreciseArray(array $expectedResult, string $limit): void $calculation = Calculation::getInstance(); $formula = "=ERF.PRECISE({$limit})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php index 26e0381ca3..04204d12af 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Erf; use PHPUnit\Framework\TestCase; class ErfTest extends TestCase @@ -19,7 +19,7 @@ class ErfTest extends TestCase */ public function testERF($expectedResult, $lower, $upper = null): void { - $result = Engineering::ERF($lower, $upper); + $result = Erf::erf($lower, $upper); self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } @@ -36,7 +36,7 @@ public function testErfArray(array $expectedResult, string $lower, string $upper $calculation = Calculation::getInstance(); $formula = "=ERF({$lower}, {$upper})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php index 4e5b8ec5f2..22a9a3b7e1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Compare; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testGESTEP($expectedResult, $a, $b): void { - $result = Engineering::GESTEP($a, $b); + $result = Compare::geStep($a, $b); self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testGeStepArray(array $expectedResult, string $a, string $b): vo $calculation = Calculation::getInstance(); $formula = "=GESTEP({$a}, {$b})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php index f70d1943d9..ccce1b9d45 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -103,7 +103,7 @@ public function testHex2BinArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=HEX2BIN({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php index 2e4ceeabb2..c96990fb76 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -103,7 +103,7 @@ public function testHex2DecArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=HEX2DEC({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php index 449925dfb4..312485e33e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -100,7 +100,7 @@ public function testHex2OctArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=HEX2OCT({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php index 417ee5c4e7..58d73ffc64 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -24,7 +24,7 @@ protected function setUp(): void */ public function testIMABS($expectedResult, $value): void { - $result = Engineering::IMABS($value); + $result = ComplexFunctions::absolute($value); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } @@ -41,7 +41,7 @@ public function testImAbsArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMABS({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php index 359352b41c..60d0b9c00e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -24,7 +24,7 @@ protected function setUp(): void */ public function testIMARGUMENT($expectedResult, $value): void { - $result = Engineering::IMARGUMENT($value); + $result = ComplexFunctions::argument($value); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } @@ -41,7 +41,7 @@ public function testImArgumentArray(array $expectedResult, string $complex): voi $calculation = Calculation::getInstance(); $formula = "=IMARGUMENT({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php index 7326bb7f12..ab1bf4853b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMCONJUGATE($expectedResult, $value): void { - $result = Engineering::IMCONJUGATE($value); + $result = ComplexFunctions::conjugate($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImConjugateArray(array $expectedResult, string $complex): vo $calculation = Calculation::getInstance(); $formula = "=IMCONJUGATE({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php index d9d8514b78..7be6b25cfc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMCOS($expectedResult, $value): void { - $result = Engineering::IMCOS($value); + $result = ComplexFunctions::cos($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImCosArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMCOS({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php index 0d0466a1c6..cd62b37bb4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMCOSH($expectedResult, $value): void { - $result = Engineering::IMCOSH($value); + $result = ComplexFunctions::cosh($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImCoshArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMCOSH({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php index 7e178ed28c..890ae40f28 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMCOT($expectedResult, $value): void { - $result = Engineering::IMCOT($value); + $result = ComplexFunctions::cot($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImCotArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMCOT({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php index bb1ca92b91..4fc9634e21 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMCSC($expectedResult, $value): void { - $result = Engineering::IMCSC($value); + $result = ComplexFunctions::csc($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImCscArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMCSC({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); // Avoid testing for excess precision foreach ($expectedResult as &$array) { foreach ($array as &$string) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php index 5d5575fbf3..5da774946f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMCSCH($expectedResult, $value): void { - $result = Engineering::IMCSCH($value); + $result = ComplexFunctions::csch($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImCschArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMCSCH({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php index 58e9154b7d..6cf5b7e1ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexOperations; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -30,7 +30,7 @@ protected function setUp(): void */ public function testIMDIV($expectedResult, ...$args): void { - $result = Engineering::IMDIV(...$args); + $result = ComplexOperations::div(...$args); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -50,7 +50,7 @@ public function testImDivArray(array $expectedResult, string $dividend, string $ $calculation = Calculation::getInstance(); $formula = "=IMDIV({$dividend}, {$divisor})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php index 5fc2dd2a80..7f5f8eb1a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMEXP($expectedResult, $value): void { - $result = Engineering::IMEXP($value); + $result = ComplexFunctions::exp($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImExpArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMEXP({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php index ad157ecb70..03aaf470da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMLN($expectedResult, $value): void { - $result = Engineering::IMLN($value); + $result = ComplexFunctions::ln($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImLnArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMLN({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php index 47503f5e85..6965430d16 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMLOG10($expectedResult, $value): void { - $result = Engineering::IMLOG10($value); + $result = ComplexFunctions::log10($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImLog10Array(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMLOG10({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php index 2ea38872d3..aa0d54d7bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMLOG2($expectedResult, $value): void { - $result = Engineering::IMLOG2($value); + $result = ComplexFunctions::log2($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImLog2Array(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMLOG2({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php index af4f5cf908..4278bc06b0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -30,7 +30,7 @@ protected function setUp(): void */ public function testIMPOWER($expectedResult, ...$args): void { - $result = Engineering::IMPOWER(...$args); + $result = ComplexFunctions::power(...$args); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -50,7 +50,7 @@ public function testImPowerArray(array $expectedResult, string $complex, string $calculation = Calculation::getInstance(); $formula = "=IMPOWER({$complex}, {$real})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php index 845d436fd1..3f79f6be5b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexOperations; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -29,7 +29,7 @@ protected function setUp(): void */ public function testIMPRODUCT($expectedResult, ...$args): void { - $result = Engineering::IMPRODUCT(...$args); + $result = ComplexOperations::product(...$args); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php index b12837e75d..73258dd2bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Complex; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -24,7 +24,7 @@ protected function setUp(): void */ public function testIMREAL($expectedResult, $value): void { - $result = Engineering::IMREAL($value); + $result = Complex::real($value); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } @@ -41,7 +41,7 @@ public function testImRealArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMREAL({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php index 33880aad22..666e6bff4f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMSEC($expectedResult, $value): void { - $result = Engineering::IMSEC($value); + $result = ComplexFunctions::sec($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImSecArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMSEC({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php index bf4285a268..9503913801 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMSECH($expectedResult, $value): void { - $result = Engineering::IMSECH($value); + $result = ComplexFunctions::sech($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImSecHArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMSECH({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php index 515ebc47cb..76d9a8f9c2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMSIN($expectedResult, $value): void { - $result = Engineering::IMSIN($value); + $result = ComplexFunctions::sin($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImSinArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMSIN({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php index c6db788939..370ea3f331 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMSINH($expectedResult, $value): void { - $result = Engineering::IMSINH($value); + $result = ComplexFunctions::sinh($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImSinHArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMSINH({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php index 261cf51ae2..6a21f43673 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMSQRT($expectedResult, $value): void { - $result = Engineering::IMSQRT($value); + $result = ComplexFunctions::sqrt($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImSqrtArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMSQRT({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php index a8d1d1d772..b2a84f058d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexOperations; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -30,7 +30,7 @@ protected function setUp(): void */ public function testIMSUB($expectedResult, ...$args): void { - $result = Engineering::IMSUB(...$args); + $result = ComplexOperations::sub(...$args); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -50,7 +50,7 @@ public function testImSubArray(array $expectedResult, string $subidend, string $ $calculation = Calculation::getInstance(); $formula = "=IMSUB({$subidend}, {$subisor})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php index 0620c68431..56b3709cf1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexOperations; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -29,7 +29,7 @@ protected function setUp(): void */ public function testIMSUM($expectedResult, ...$args): void { - $result = Engineering::IMSUM(...$args); + $result = ComplexOperations::sum(...$args); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php index ca66b2b851..fd25a2c7de 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; use PHPUnit\Framework\TestCase; @@ -31,7 +31,7 @@ protected function setUp(): void */ public function testIMTAN($expectedResult, $value): void { - $result = Engineering::IMTAN($value); + $result = ComplexFunctions::tan($value); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -51,7 +51,7 @@ public function testImTanArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMTAN({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php index 59ad1eb8c7..06fa0d5ca3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Engineering; +use PhpOffice\PhpSpreadsheet\Calculation\Engineering\Complex; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -24,7 +24,7 @@ protected function setUp(): void */ public function testIMAGINARY($expectedResult, $value): void { - $result = Engineering::IMAGINARY($value); + $result = Complex::imaginary($value); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } @@ -41,7 +41,7 @@ public function testImaginaryArray(array $expectedResult, string $complex): void $calculation = Calculation::getInstance(); $formula = "=IMAGINARY({$complex})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php deleted file mode 100644 index 457db0d30d..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php +++ /dev/null @@ -1,24 +0,0 @@ -_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php index e814e76df7..06f3efe224 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -100,7 +100,7 @@ public function testOct2DecArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=OCT2DEC({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php index 0f38752f75..0ac32f8a8d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -100,7 +100,7 @@ public function testOct2HexArray(array $expectedResult, string $value): void $calculation = Calculation::getInstance(); $formula = "=OCT2HEX({$value})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php deleted file mode 100644 index a32d946f59..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php +++ /dev/null @@ -1,22 +0,0 @@ -_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php index 79e3d5cae8..e75847e9d0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Dollar; use PHPUnit\Framework\TestCase; class DollarFrTest extends TestCase @@ -15,11 +15,11 @@ class DollarFrTest extends TestCase public function testDOLLARFR($expectedResult, ...$args): void { if (count($args) === 0) { - $result = Financial::DOLLARFR(); + $result = Dollar::fractional(); } elseif (count($args) === 1) { - $result = Financial::DOLLARFR($args[0]); + $result = Dollar::fractional($args[0]); } else { - $result = Financial::DOLLARFR($args[0], $args[1]); + $result = Dollar::fractional($args[0], $args[1]); } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php index 89c48b6bc8..43dad6d6fd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\InterestRate; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -22,7 +22,7 @@ protected function setUp(): void */ public function testEFFECT($expectedResult, $rate, $periods): void { - $result = Financial::EFFECT($rate, $periods); + $result = InterestRate::effective($rate, $periods); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php index b82f4db86b..5c5ca0a1f3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Single; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testFVSCHEDULE($expectedResult, ...$args): void { - $result = Financial::FVSCHEDULE(...$args); + $result = Single::futureValue(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php index 0e62176615..4ecd0d8695 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; use PHPUnit\Framework\TestCase; class FvTest extends TestCase @@ -12,21 +12,9 @@ class FvTest extends TestCase * * @param mixed $expectedResult */ - public function testFV($expectedResult, array $args): void + public function testFV($expectedResult, array $args = []): void { - if (count($args) === 0) { - $result = Financial::FV(); - } elseif (count($args) === 1) { - $result = Financial::FV($args[0]); - } elseif (count($args) === 2) { - $result = Financial::FV($args[0], $args[1]); - } elseif (count($args) === 3) { - $result = Financial::FV($args[0], $args[1], $args[2]); - } elseif (count($args) === 4) { - $result = Financial::FV($args[0], $args[1], $args[2], $args[3]); - } else { - $result = Financial::FV($args[0], $args[1], $args[2], $args[3], $args[4]); - } + $result = Periodic::futureValue(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IPmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IPmtTest.php index 873c981730..1eeeb7ad74 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IPmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IPmtTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic\Interest; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testIPMT($expectedResult, array $args): void { - $result = Financial::IPMT(...$args); + $result = Interest::payment(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php index d36b585162..c3873df447 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Rates; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testINTRATE($expectedResult, ...$args): void { - $result = Financial::INTRATE(...$args); + $result = Rates::interest(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php index 61e655942f..8821c69d8b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic\Interest; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testISPMT($expectedResult, ...$args): void { - $result = Financial::ISPMT(...$args); + $result = Interest::schedulePayment(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php index 27abfa4244..18e44363ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Variable\Periodic; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testMIRR($expectedResult, ...$args): void { - $result = Financial::MIRR(...$args); + $result = Periodic::modifiedRate(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php index 2d7ded04e0..ddcaa34f0a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; use PHPUnit\Framework\TestCase; class NPerTest extends TestCase @@ -12,21 +12,9 @@ class NPerTest extends TestCase * * @param mixed $expectedResult */ - public function testNPER($expectedResult, array $args): void + public function testNPER($expectedResult, array $args = []): void { - if (count($args) === 0) { - $result = Financial::NPER(); - } elseif (count($args) === 1) { - $result = Financial::NPER($args[0]); - } elseif (count($args) === 2) { - $result = Financial::NPER($args[0], $args[1]); - } elseif (count($args) === 3) { - $result = Financial::NPER($args[0], $args[1], $args[2]); - } elseif (count($args) === 4) { - $result = Financial::NPER($args[0], $args[1], $args[2], $args[3]); - } else { - $result = Financial::NPER($args[0], $args[1], $args[2], $args[3], $args[4]); - } + $result = Periodic::periods(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php index 50c1c9a85e..e8e816ec60 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\InterestRate; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -22,7 +22,7 @@ protected function setUp(): void */ public function testNOMINAL($expectedResult, $rate, $periods): void { - $result = Financial::NOMINAL($rate, $periods); + $result = InterestRate::nominal($rate, $periods); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php index a5e280c41f..9fc1b3f0a1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Variable\Periodic; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testNPV($expectedResult, ...$args): void { - $result = Financial::NPV(...$args); + $result = Periodic::presentValue(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php index dbe1b09a5b..e871158a2c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Single; use PHPUnit\Framework\TestCase; class PDurationTest extends TestCase @@ -12,17 +12,9 @@ class PDurationTest extends TestCase * * @param mixed $expectedResult */ - public function testPDURATION($expectedResult, array $args): void + public function testPDURATION($expectedResult, array $args = []): void { - if (count($args) === 0) { - $result = Financial::PDURATION(); - } elseif (count($args) === 1) { - $result = Financial::PDURATION($args[0]); - } elseif (count($args) === 2) { - $result = Financial::PDURATION($args[0], $args[1]); - } else { - $result = Financial::PDURATION($args[0], $args[1], $args[2]); - } + $result = Single::periods(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php index 5c1f65564e..e6718b7705 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic\Payments; use PHPUnit\Framework\TestCase; class PmtTest extends TestCase @@ -18,11 +18,11 @@ public function testPMT($expectedResult, array $args): void $numberOfPeriods = array_shift($args); $presentValue = array_shift($args); if (count($args) === 0) { - $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue); + $result = Payments::annuity($interestRate, $numberOfPeriods, $presentValue); } elseif (count($args) === 1) { - $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, $args[0]); + $result = Payments::annuity($interestRate, $numberOfPeriods, $presentValue, $args[0]); } else { - $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, $args[0], $args[1]); + $result = Payments::annuity($interestRate, $numberOfPeriods, $presentValue, $args[0], $args[1]); } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php index 142b0fda66..690eefa60f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic\Payments; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testPPMT($expectedResult, array $args): void { - $result = Financial::PPMT(...$args); + $result = Payments::interestPayment(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php index 74673bba9b..71ab34a2d6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testPRICEDISC($expectedResult, array $args): void { - $result = Financial::PRICEDISC(...$args); + $result = Price::priceDiscounted(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php index d3bd4daba7..3ec38b8e94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testPRICEMAT($expectedResult, ...$args): void { - $result = Financial::PRICEMAT(...$args); + $result = Price::priceAtMaturity(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php index 87981c7e29..ab043cbb95 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testPRICE($expectedResult, ...$args): void { - $result = Financial::PRICE(...$args); + $result = Price::price(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-7); } @@ -39,7 +39,7 @@ public function testPRICE3($expectedResult, ...$args): void // These results (PRICE function with basis codes 2 and 3) // agree with published algorithm, LibreOffice, and Gnumeric. // They do not agree with Excel. - $result = Financial::PRICE(...$args); + $result = Price::price(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-7); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php index 4e4a8f80db..fe5b47d6d9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; use PHPUnit\Framework\TestCase; class PvTest extends TestCase @@ -12,21 +12,9 @@ class PvTest extends TestCase * * @param mixed $expectedResult */ - public function testPV($expectedResult, array $args): void + public function testPV($expectedResult, array $args = []): void { - if (count($args) === 0) { - $result = Financial::PV(); - } elseif (count($args) === 1) { - $result = Financial::PV($args[0]); - } elseif (count($args) === 2) { - $result = Financial::PV($args[0], $args[1]); - } elseif (count($args) === 3) { - $result = Financial::PV($args[0], $args[1], $args[2]); - } elseif (count($args) === 4) { - $result = Financial::PV($args[0], $args[1], $args[2], $args[3]); - } else { - $result = Financial::PV($args[0], $args[1], $args[2], $args[3], $args[4]); - } + $result = Periodic::presentValue(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php index 81535ae035..97be9c3171 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic\Interest; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testRATE($expectedResult, ...$args): void { - $result = Financial::RATE(...$args); + $result = Interest::rate(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php index b566d85f40..bebfff3575 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testRECEIVED($expectedResult, ...$args): void { - $result = Financial::RECEIVED(...$args); + $result = Price::received(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php index 9107ba9683..7667d571e9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Single; use PHPUnit\Framework\TestCase; class RriTest extends TestCase @@ -15,13 +15,13 @@ class RriTest extends TestCase public function testRRI($expectedResult, array $args): void { if (count($args) === 0) { - $result = Financial::RRI(); + $result = Single::interestRate(); } elseif (count($args) === 1) { - $result = Financial::RRI($args[0]); + $result = Single::interestRate($args[0]); } elseif (count($args) === 2) { - $result = Financial::RRI($args[0], $args[1]); + $result = Single::interestRate($args[0], $args[1]); } else { - $result = Financial::RRI($args[0], $args[1], $args[2]); + $result = Single::interestRate($args[0], $args[1], $args[2]); } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php index 6ea7908d6e..05842799ab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Depreciation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testSLN($expectedResult, array $args): void { - $result = Financial::SLN(...$args); + $result = Depreciation::straightLine(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php index ede8229495..8eee51e0df 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Depreciation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testSYD($expectedResult, array $args): void { - $result = Financial::SYD(...$args); + $result = Depreciation::sumOfYears(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php index b528b168ff..677cd3e1cb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\TreasuryBill; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testTBILLEQ($expectedResult, ...$args): void { - $result = Financial::TBILLEQ(...$args); + $result = TreasuryBill::bondEquivalentYield(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php index 1d1b242081..86d2d264a0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\TreasuryBill; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testTBILLPRICE($expectedResult, ...$args): void { - $result = Financial::TBILLPRICE(...$args); + $result = TreasuryBill::price(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php index 51daddc866..03a912f2ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\TreasuryBill; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testTBILLYIELD($expectedResult, ...$args): void { - $result = Financial::TBILLYIELD(...$args); + $result = TreasuryBill::yield(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php index 299d753667..a59a905653 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Variable\NonPeriodic; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testXNPV($expectedResult, $message, ...$args): void { - $result = Financial::XNPV(...$args); + $result = NonPeriodic::presentValue(...$args); if (is_numeric($result) && is_numeric($expectedResult)) { if ($expectedResult != 0) { $frac = $result / $expectedResult; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php index 1c966d87dc..2c2577746b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Yields; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testYIELDDISC($expectedResult, ...$args): void { - $result = Financial::YIELDDISC(...$args); + $result = Yields::yieldDiscounted(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php index d689d05757..f16231a3ca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Yields; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testYIELDMAT($expectedResult, ...$args): void { - $result = Financial::YIELDMAT(...$args); + $result = Yields::yieldAtMaturity(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php index 1f22c47421..3158df869c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php @@ -3,7 +3,6 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PHPUnit\Framework\TestCase; @@ -11,7 +10,7 @@ class ErrorTypeTest extends TestCase { public function testErrorTypeNoArgument(): void { - $result = Functions::errorType(); + $result = ExcelError::type(); self::assertSame(ExcelError::NA(), $result); } @@ -23,7 +22,7 @@ public function testErrorTypeNoArgument(): void */ public function testErrorType($expectedResult, $value): void { - $result = Functions::errorType($value); + $result = ExcelError::type($value); self::assertSame($expectedResult, $result); } @@ -40,7 +39,7 @@ public function testErrorTypeArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ERROR.TYPE({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php index 0cf0359117..c422c1283d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsBlankTest extends TestCase { public function testIsBlankNoArgument(): void { - $result = Functions::isBlank(); + $result = Value::isBlank(); self::assertTrue($result); } @@ -21,7 +21,7 @@ public function testIsBlankNoArgument(): void */ public function testIsBlank(bool $expectedResult, $value): void { - $result = Functions::isBlank($value); + $result = Value::isBlank($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsBlankArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISBLANK({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php index 1360a607ea..e7bcbcb270 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue; use PHPUnit\Framework\TestCase; class IsErrTest extends TestCase { public function testIsErrNoArgument(): void { - $result = Functions::isErr(); + $result = ErrorValue::isErr(); self::assertFalse($result); } @@ -21,7 +21,7 @@ public function testIsErrNoArgument(): void */ public function testIsErr(bool $expectedResult, $value): void { - $result = Functions::isErr($value); + $result = ErrorValue::isErr($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsErrArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISERR({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php index 26f5b9c363..8a6d20f601 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue; use PHPUnit\Framework\TestCase; class IsErrorTest extends TestCase { public function testIsErrorNoArgument(): void { - $result = Functions::isError(); + $result = ErrorValue::isError(); self::assertFalse($result); } @@ -21,7 +21,7 @@ public function testIsErrorNoArgument(): void */ public function testIsError(bool $expectedResult, $value): void { - $result = Functions::isError($value); + $result = ErrorValue::isError($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsErrorArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISERROR({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php index baad481678..dd2bafa323 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php @@ -3,15 +3,15 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsEvenTest extends TestCase { public function testIsEvenNoArgument(): void { - $result = Functions::isEven(); + $result = Value::isEven(); self::assertSame(ExcelError::NAME(), $result); } @@ -23,7 +23,7 @@ public function testIsEvenNoArgument(): void */ public function testIsEven($expectedResult, $value): void { - $result = Functions::isEven($value); + $result = Value::isEven($value); self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testIsEvenArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISEVEN({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php index 03e9bb70d0..892c87cddc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php @@ -106,7 +106,7 @@ public function testIsFormulaArray(): void $calculation = Calculation::getInstance($spreadsheet); $formula = '=ISFORMULA(A1:A7)'; - $result = $calculation->_calculateFormulaValue($formula, 'C1', $sheet->getCell('C1')); + $result = $calculation->calculateFormulaValue($formula, 'C1', $sheet->getCell('C1')); self::assertEquals([true, false, true, false, true, false, false], $result); $spreadsheet->disconnectWorksheets(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php index 0c220aeefa..44434fe426 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsLogicalTest extends TestCase { public function testIsLogicalNoArgument(): void { - $result = Functions::isLogical(); + $result = Value::isLogical(); self::assertFalse($result); } @@ -21,7 +21,7 @@ public function testIsLogicalNoArgument(): void */ public function testIsLogical(bool $expectedResult, $value): void { - $result = Functions::isLogical($value); + $result = Value::isLogical($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsLogicalArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISLOGICAL({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php index 5fac18fae0..08e1595388 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue; use PHPUnit\Framework\TestCase; class IsNaTest extends TestCase { public function testIsNaNoArgument(): void { - $result = Functions::isNa(); + $result = ErrorValue::isNa(); self::assertFalse($result); } @@ -21,7 +21,7 @@ public function testIsNaNoArgument(): void */ public function testIsNa(bool $expectedResult, $value): void { - $result = Functions::isNa($value); + $result = ErrorValue::isNa($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsNaArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISNA({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php index 759d7b302f..31d1509a6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsNonTextTest extends TestCase { public function testIsNonTextNoArgument(): void { - $result = Functions::isNonText(); + $result = Value::isNonText(); self::assertTrue($result); } @@ -21,7 +21,7 @@ public function testIsNonTextNoArgument(): void */ public function testIsNonText(bool $expectedResult, $value): void { - $result = Functions::isNonText($value); + $result = Value::isNonText($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsNonTextArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISNONTEXT({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php index 649e4335fc..1f2781bab6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsNumberTest extends TestCase { public function testIsNumberNoArgument(): void { - $result = Functions::isNumber(); + $result = Value::isNumber(); self::assertFalse($result); } @@ -21,7 +21,7 @@ public function testIsNumberNoArgument(): void */ public function testIsNumber(bool $expectedResult, $value): void { - $result = Functions::isNumber($value); + $result = Value::isNumber($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsNumberArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISNUMBER({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php index 4f31ff38e9..9629d591e9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php @@ -3,15 +3,15 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsOddTest extends TestCase { public function testIsOddNoArgument(): void { - $result = Functions::isOdd(); + $result = Value::isOdd(); self::assertSame(ExcelError::NAME(), $result); } @@ -23,7 +23,7 @@ public function testIsOddNoArgument(): void */ public function testIsOdd($expectedResult, $value): void { - $result = Functions::isOdd($value); + $result = Value::isOdd($value); self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testIsOddArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISODD({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php index cdbba409a2..51078061ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php @@ -3,14 +3,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class IsTextTest extends TestCase { public function testIsTextNoArgument(): void { - $result = Functions::isText(); + $result = Value::isText(); self::assertFalse($result); } @@ -21,7 +21,7 @@ public function testIsTextNoArgument(): void */ public function testIsText(bool $expectedResult, $value): void { - $result = Functions::isText($value); + $result = Value::isText($value); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testIsTextArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=ISTEXT({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NTest.php index 1ff5a03d6d..07ec8a57e5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NTest.php @@ -2,14 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class NTest extends TestCase { public function testNNoArgument(): void { - $result = Functions::n(); + $result = Value::asNumber(); self::assertSame(0, $result); } @@ -21,7 +21,7 @@ public function testNNoArgument(): void */ public function testN($expectedResult, $value): void { - $result = Functions::n($value); + $result = Value::asNumber($value); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NullTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NullTest.php index 87810749ef..65ce5ddbd5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NullTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/NullTest.php @@ -2,14 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PHPUnit\Framework\TestCase; class NullTest extends TestCase { public function testNULL(): void { - $result = Functions::null(); + $result = ExcelError::null(); self::assertEquals('#NULL!', $result); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/TypeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/TypeTest.php index 3b97230935..d44014de53 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/TypeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/TypeTest.php @@ -2,14 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; use PHPUnit\Framework\TestCase; class TypeTest extends TestCase { public function testTypeNoArgument(): void { - $result = Functions::TYPE(); + $result = Value::type(); self::assertSame(1, $result); } @@ -20,7 +20,7 @@ public function testTypeNoArgument(): void */ public function testTYPE(int $expectedResult, $value): void { - $result = Functions::TYPE($value); + $result = Value::type($value); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php index a1d546b025..10058042b9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations; use PHPUnit\Framework\TestCase; class AndTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testAND($expectedResult, ...$args): void { - $result = Logical::logicalAnd(...$args); + $result = Operations::and(...$args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php index 1fa78af03d..2afa62ffc6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean; use PHPUnit\Framework\TestCase; class FalseTest extends TestCase @@ -15,7 +15,7 @@ protected function setUp(): void public function testFALSE(): void { - $result = Logical::FALSE(); + $result = Boolean::false(); self::assertFalse($result); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php index 03ad8b3ae6..72b0154293 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Conditional; use PHPUnit\Framework\TestCase; class IfErrorTest extends TestCase @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testIFERROR($expectedResult, $value, $return): void { - $result = Logical::IFERROR($value, $return); + $result = Conditional::ifError($value, $return); self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testIfErrorArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=IFERROR({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php index 1c87de77cf..74590dc4bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Conditional; use PHPUnit\Framework\TestCase; class IfNaTest extends TestCase @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testIFNA($expectedResult, $value, $return): void { - $result = Logical::IFNA($value, $return); + $result = Conditional::ifNa($value, $return); self::assertEquals($expectedResult, $result); } @@ -40,7 +40,7 @@ public function testIfNaArray(array $expectedResult, string $argument1, string $ $calculation = Calculation::getInstance(); $formula = "=IFNA({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php index 5899716106..2f9832085d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Conditional; use PHPUnit\Framework\TestCase; class IfTest extends TestCase @@ -15,13 +15,13 @@ class IfTest extends TestCase public function testIF($expectedResult, ...$args): void { if (count($args) === 0) { - $result = Logical::statementIf(); + $result = Conditional::if(); } elseif (count($args) === 1) { - $result = Logical::statementIf($args[0]); + $result = Conditional::if($args[0]); } elseif (count($args) === 2) { - $result = Logical::statementIf($args[0], $args[1]); + $result = Conditional::if($args[0], $args[1]); } else { - $result = Logical::statementIf($args[0], $args[1], $args[2]); + $result = Conditional::if($args[0], $args[1], $args[2]); } self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php index 6660b9d3de..14b4bdd355 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Conditional; use PHPUnit\Framework\TestCase; class IfsTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testIFS($expectedResult, ...$args): void { - $result = Logical::IFS(...$args); + $result = Conditional::ifSeries(...$args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index 6d8b2ca9e9..af5a4c49a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations; use PHPUnit\Framework\TestCase; class NotTest extends TestCase @@ -16,9 +16,9 @@ class NotTest extends TestCase public function testNOT($expectedResult, ...$args): void { if (count($args) === 0) { - $result = Logical::NOT(); + $result = Operations::not(); } else { - $result = Logical::NOT($args[0]); + $result = Operations::not($args[0]); } self::assertEquals($expectedResult, $result); } @@ -36,7 +36,7 @@ public function testNotArray(array $expectedResult, string $argument1): void $calculation = Calculation::getInstance(); $formula = "=NOT({$argument1})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php index af67c5069e..918ac48f0d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations; use PHPUnit\Framework\TestCase; class OrTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testOR($expectedResult, ...$args): void { - $result = Logical::logicalOr(...$args); + $result = Operations::or(...$args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php index 766b1b7c7a..2eec58a26f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Conditional; use PHPUnit\Framework\TestCase; class SwitchTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testSWITCH($expectedResult, ...$args): void { - $result = Logical::statementSwitch(...$args); + $result = Conditional::switch(...$args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php index 21e65b76c0..19c527ccb9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean; use PHPUnit\Framework\TestCase; class TrueTest extends TestCase @@ -15,7 +15,7 @@ protected function setUp(): void public function testTRUE(): void { - $result = Logical::TRUE(); + $result = Boolean::true(); self::assertTrue($result); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php index 27cb359cbb..c67968ea24 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations; use PHPUnit\Framework\TestCase; class XorTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testXOR($expectedResult, ...$args): void { - $result = Logical::logicalXor(...$args); + $result = Operations::xor(...$args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php index 2a6ae883d4..7da09b478f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Address; use PHPUnit\Framework\TestCase; class AddressTest extends TestCase @@ -15,7 +15,7 @@ class AddressTest extends TestCase */ public function testADDRESS($expectedResult, ...$args): void { - $result = LookupRef::cellAddress(...$args); + $result = Address::cell(...$args); self::assertEquals($expectedResult, $result); } @@ -32,7 +32,7 @@ public function testAddressArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=ADDRESS({$argument1}, {$argument2}, 4)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php index 1a445fd0eb..891e2e7d42 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Selection; use PHPUnit\Framework\TestCase; class ChooseTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testCHOOSE($expectedResult, ...$args): void { - $result = LookupRef::CHOOSE(...$args); + $result = Selection::choose(...$args); self::assertEquals($expectedResult, $result); } @@ -39,7 +39,7 @@ public function testChooseArray(array $expectedResult, string $values, array $se $selections = implode(',', $selections); $formula = "=CHOOSE({$values}, {$selections})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php index 2cd0b73502..1b98e37804 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\RowColumnInformation; class ColumnTest extends AllSetupTeardown { @@ -14,7 +14,7 @@ class ColumnTest extends AllSetupTeardown */ public function testCOLUMN($expectedResult, $cellReference = null): void { - $result = LookupRef\RowColumnInformation::COLUMN($cellReference); + $result = RowColumnInformation::column($cellReference); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php index e8790cbf8a..964778544e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\RowColumnInformation; use PHPUnit\Framework\TestCase; class ColumnsTest extends TestCase @@ -15,7 +15,7 @@ class ColumnsTest extends TestCase */ public function testCOLUMNS($expectedResult, ...$args): void { - $result = LookupRef::COLUMNS(/** @scrutinizer ignore-type */ ...$args); + $result = RowColumnInformation::columns(...$args); self::assertEquals($expectedResult, $result); } @@ -32,7 +32,7 @@ public function testColumnsArray(int $expectedResult, string $argument): void $calculation = Calculation::getInstance(); $formula = "=COLUMNS({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FilterTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FilterTest.php index 5a584c4645..1bedea900c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FilterTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FilterTest.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Filter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; use PHPUnit\Framework\TestCase; class FilterTest extends TestCase @@ -52,6 +53,50 @@ public function testFilterEmpty(): void self::assertSame($expectedResult, $result); } + public function testFilterWithAndLogic(): void + { + $expectedResult = [ + ['East', 'Tom', 'Apple', 6830], + ['East', 'Fritz', 'Banana', 6274], + ]; + + $spreadsheet = new Spreadsheet(); + $worksheet = $spreadsheet->getActiveSheet(); + $worksheet->fromArray($this->sampleDataForRow(), null, 'C3', true); + + // East AND >6,000 + $formula = '=FILTER(C3:F18,(C3:C18="East")*(F3:F18>6000))'; + $worksheet->setCellValue('H1', $formula, true, 'H1:K2'); + $result = $worksheet->getCell('H1')->getCalculatedValue(true); + + self::assertSame($expectedResult, $result); + } + + public function testFilterWithOrLogic(): void + { + $expectedResult = [ + ['East', 'Tom', 'Apple', 6830], + ['East', 'Fritz', 'Apple', 4394], + ['West', 'Sravan', 'Grape', 7195], + ['East', 'Tom', 'Banana', 4213], + ['North', 'Amy', 'Grape', 6420], + ['East', 'Fritz', 'Banana', 6274], + ['North', 'Xi', 'Grape', 7580], + ['South', 'Hector', 'Apple', 8144], + ]; + + $spreadsheet = new Spreadsheet(); + $worksheet = $spreadsheet->getActiveSheet(); + $worksheet->fromArray($this->sampleDataForRow(), null, 'C3', true); + + // East OR >6,000 + $formula = '=FILTER(C3:F18,(C3:C18="East")+(F3:F18>6000))'; + $worksheet->setCellValue('H1', $formula, true, 'H1:K8'); + $result = $worksheet->getCell('H1')->getCalculatedValue(true); + + self::assertSame($expectedResult, $result); + } + protected function sampleDataForRow(): array { return [ diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FormulaTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FormulaTextTest.php index 6c91f3fcee..8dc3340a41 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FormulaTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FormulaTextTest.php @@ -35,4 +35,21 @@ public function testNoCell(): void { self::assertSame('#REF!', Formula::text('B5')); } + + public function testArrayFormula(): void + { + $sheet = $this->getSheet(); + $sheet->setCellValue('B2', '=SEQUENCE(3,3)', true, 'B2:D4'); + + // Execute the calculation to populate the spillage cells + $sheet->getCell('B2')->getCalculatedValue(true); + $sheet->setCellValue('A1', '=FORMULATEXT(B2)'); + $sheet->setCellValue('E5', '=FORMULATEXT(D4)'); + + $result1 = $sheet->getCell('A1')->getCalculatedValue(); + self::assertSame('{=SEQUENCE(3,3)}', $result1, 'Formula Cell'); + + $result2 = $sheet->getCell('E5')->getCalculatedValue(); + self::assertSame('{=SEQUENCE(3,3)}', $result2, 'Spill Range Cell'); + } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php index 084e3d9f7b..d5569b6051 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\HLookup; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -75,7 +75,7 @@ public function testGrandfathered(): void // Some old tests called function directly using array of strings; // ensure these work as before. $expectedResult = '#REF!'; - $result = LookupRef::HLOOKUP( + $result = HLookup::lookup( 'Selection column', ['Selection column', 'Value to retrieve'], 5, @@ -83,7 +83,7 @@ public function testGrandfathered(): void ); self::assertSame($expectedResult, $result); $expectedResult = 'Value to retrieve'; - $result = LookupRef::HLOOKUP( + $result = HLookup::lookup( 'Selection column', ['Selection column', 'Value to retrieve'], 2, @@ -138,7 +138,7 @@ public function testHLookupArray(array $expectedResult, string $values, string $ $calculation = Calculation::getInstance(); $formula = "=HLOOKUP({$values}, {$database}, {$index}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php index fa3f4848b2..a2304fa966 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Matrix; use PHPUnit\Framework\TestCase; class IndexTest extends TestCase @@ -15,7 +15,7 @@ class IndexTest extends TestCase */ public function testINDEX($expectedResult, ...$args): void { - $result = LookupRef::INDEX(/** @scrutinizer ignore-type */ ...$args); + $result = Matrix::index(/** @scrutinizer ignore-type */ ...$args); self::assertEquals($expectedResult, $result); } @@ -32,7 +32,7 @@ public function testIndexArray(array $expectedResult, string $matrix, string $ro $calculation = Calculation::getInstance(); $formula = "=INDEX({$matrix}, {$rows}, {$columns})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php index accfc058c9..bdf3693f27 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php @@ -123,16 +123,6 @@ public function testIndirectFile2(): void } } - public function testDeprecatedCall(): void - { - $sheet = $this->getSheet(); - $sheet->getCell('A1')->setValue('A2'); - $sheet->getCell('A2')->setValue('This is it'); - $result = \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::INDIRECT('A2', $sheet->getCell('A1')); - $result = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenSingleValue($result); - self::assertSame('This is it', $result); - } - /** * @param null|int|string $expectedResult * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php index c2cf4dae6c..dadaab1ae6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Lookup; use PHPUnit\Framework\TestCase; class LookupTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testLOOKUP($expectedResult, ...$args): void { - $result = LookupRef::LOOKUP(...$args); + $result = Lookup::LOOKUP(...$args); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testLookupArray(array $expectedResult, string $values, string $l $calculation = Calculation::getInstance(); $formula = "=LOOKUP({$values}, {$lookup}, {$return})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php index f8e8fa46a9..cb30567e3d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\ExcelMatch; use PHPUnit\Framework\TestCase; class MatchTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testMATCH($expectedResult, ...$args): void { - $result = LookupRef::MATCH(...$args); + $result = ExcelMatch::match(...$args); self::assertEquals($expectedResult, $result); } @@ -38,7 +38,7 @@ public function testMatchArray(array $expectedResult, string $values, string $se $calculation = Calculation::getInstance(); $formula = "=MATCH({$values}, {$selections}, 0)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php deleted file mode 100644 index 007ce1d2b8..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php +++ /dev/null @@ -1,29 +0,0 @@ -_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php index 5b7647be84..f023564073 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -54,7 +54,7 @@ public function testVLookupArray(array $expectedResult, string $values, string $ $calculation = Calculation::getInstance(); $formula = "=VLOOKUP({$values}, {$database}, {$index}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php index 23e0ae35cc..c602dd235b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php @@ -12,7 +12,7 @@ class AbsTest extends AllSetupTeardown * @param mixed $expectedResult * @param mixed $number */ - public function testAbs($expectedResult, $number = 'omitted'): void + public function testAbsolute($expectedResult, $number = 'omitted'): void { $sheet = $this->getSheet(); $this->mightHaveException($expectedResult); @@ -39,7 +39,7 @@ public function testAbsoluteArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ABS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php index ebdc9130e5..bf6c107f32 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php @@ -34,7 +34,7 @@ public function testAcosArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ACOS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php index f9ee3ef49f..cc5f8011ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php @@ -34,7 +34,7 @@ public function testAcoshArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ACOSH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index 9f63ac9d13..f22f333d80 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -38,7 +38,7 @@ public function testAcotArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ACOT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index 8e2555e0a6..e6784f4745 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -38,7 +38,7 @@ public function testAcothArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ACOTH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php index 57f2717f4c..d1c1fb26a1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -35,7 +35,7 @@ public function testArabicArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ARABIC({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php index 87a6da394f..2368a11bfa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php @@ -34,7 +34,7 @@ public function testAsinArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ASIN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php index c6fb5f3266..7ec5817e31 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php @@ -34,7 +34,7 @@ public function testAsinhArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ASINH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php index 2ff47b3b89..67cc04bada 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -35,7 +35,7 @@ public function testAtan2Array(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=ATAN2({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php index d79c8576ce..3a7eb8c709 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php @@ -34,7 +34,7 @@ public function testAtanArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ATAN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php index dad09ba2e7..a06dd3a671 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php @@ -34,7 +34,7 @@ public function testAtanhArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ATANH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php index ab863492e1..d6fcd7e166 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -53,7 +53,7 @@ public function testBaseArray(array $expectedResult, string $argument1, string $ $calculation = Calculation::getInstance(); $formula = "=BASE({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php index aec3bd5546..d0a2f7a48a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php @@ -38,7 +38,7 @@ public function testCeilingArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=CEILING.MATH({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php index 4fe50b7ff1..7c680279db 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php @@ -38,7 +38,7 @@ public function testCeilingArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=CEILING.PRECISE({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php index 5adba7de2e..238d098e73 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -65,7 +65,7 @@ public function testCeilingArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=CEILING({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php index 7c2200a002..8f4dada3e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php @@ -41,7 +41,7 @@ public function testCombinAArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=COMBINA({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php index 18e3eed6c4..203c9374a2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -41,7 +41,7 @@ public function testCombinArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=COMBIN({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php index 5b51fb0fef..54237e6699 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php @@ -34,7 +34,7 @@ public function testCosArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=COS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php index f4135cc2a8..001f1bf128 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php @@ -34,7 +34,7 @@ public function testCoshArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=COSH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index d2d1c4e2a4..25ad5e7bf8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -38,7 +38,7 @@ public function testCotArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=COT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index ec203a7801..52d0a5b403 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -38,7 +38,7 @@ public function testCothArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=COTH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index 73ff086ee9..36d8c0bad4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -38,7 +38,7 @@ public function testCscArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=CSC({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index 8ffb408ac3..099d40c5eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -38,7 +38,7 @@ public function testCschArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=CSCH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php index 20d52853fc..f7f710b559 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php @@ -39,7 +39,7 @@ public function testDegreesArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=DEGREES({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index 1dab09f273..465b67b69b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -34,7 +34,7 @@ public function testEvenArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=EVEN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php index 07014bd453..eb0be95278 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php @@ -41,7 +41,7 @@ public function testExpArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=EXP({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php index 34c9225151..a591bd6421 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -35,7 +35,7 @@ public function testFactDoubleArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=FACTDOUBLE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php index 6bdfa57008..c39c5c770e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -71,7 +71,7 @@ public function testFactArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=FACT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, self::FACT_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php index 1bd37b8971..a8c89dd9de 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -38,7 +38,7 @@ public function testFloorArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=FLOOR.MATH({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php index 247f989ad1..fa87cea324 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -38,7 +38,7 @@ public function testFloorArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=FLOOR.PRECISE({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php index 135f1180a9..b96eaba0ed 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -65,7 +65,7 @@ public function testFloorArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=FLOOR({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php index 42a24af51e..60b24689b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -38,7 +38,7 @@ public function testIntArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=INT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php index b300526a77..94e5889c81 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php @@ -41,7 +41,7 @@ public function testLnArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=LN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php index d78e589aea..639e2b49ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php @@ -41,7 +41,7 @@ public function testLog10Array(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=LOG10({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php index e05f245b27..5ec0aade99 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -47,7 +47,7 @@ public function testLogArray(array $expectedResult, string $argument1, string $a $calculation = Calculation::getInstance(); $formula = "=LOG({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php index b9e48b90ee..64598fadd9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -38,7 +38,7 @@ public function testMRoundArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=MROUND({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php index 029f8392cd..bb8b538b4a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -47,7 +47,7 @@ public function testModArray(array $expectedResult, string $argument1, string $a $calculation = Calculation::getInstance(); $formula = "=MOD({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php deleted file mode 100644 index 2cca8f3651..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php +++ /dev/null @@ -1,111 +0,0 @@ -2')); - self::assertEquals(2, MathTrig::SUMIFS( - [[1], [1], [1]], - [['Y'], ['Y'], ['N']], - '=Y', - [['H'], ['H'], ['H']], - '=H' - )); - self::assertEquals(17, MathTrig::SUMPRODUCT([1, 2, 3], [5, 0, 4])); - self::assertEquals(21, MathTrig::SUMSQ(1, 2, 4)); - self::assertEquals(-20, MathTrig::SUMX2MY2([1, 2], [3, 4])); - self::assertEquals(30, MathTrig::SUMX2PY2([1, 2], [3, 4])); - self::assertEquals(8, MathTrig::SUMXMY2([1, 2], [3, 4])); - self::assertEquals(0, MathTrig::builtinTAN(0)); - self::assertEquals(0, MathTrig::builtinTANH(0)); - self::assertEquals(70, MathTrig::TRUNC(79.2, -1)); - self::assertEquals(1, MathTrig::returnSign(79.2)); - self::assertEquals(80, MathTrig::getEven(79.2)); - $nullVal = null; - MathTrig::nullFalseTrueToNumber($nullVal); - self::assertSame(0, $nullVal); - $nullVal = true; - MathTrig::nullFalseTrueToNumber($nullVal); - self::assertSame(1, $nullVal); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index 8ef0e0f34b..e4384eb9a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -34,7 +34,7 @@ public function testOddArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=ODD({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php index c9e35a3e78..5b3be52571 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -47,7 +47,7 @@ public function testPowerArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=POWER({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php index 1019b35f08..6efb187bb2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -47,7 +47,7 @@ public function testQuotientArray(array $expectedResult, string $argument1, stri $calculation = Calculation::getInstance(); $formula = "=QUOTIENT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php index 5468528fbc..4d63fbfa75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php @@ -39,7 +39,7 @@ public function testRadiansArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=RADIANS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php index 50b7117cf0..a6f20e868e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php @@ -58,7 +58,7 @@ public function testRandBetweenArray( $calculation = Calculation::getInstance(); $formula = "=RandBetween({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertIsArray($result); self::assertCount($expectedRows, /** @scrutinizer ignore-type */ $result); self::assertIsArray($result[0]); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php index dbde63d189..f2bb3b1fb8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -35,7 +35,7 @@ public function testRomanArray(array $expectedResult, string $values, string $st $calculation = Calculation::getInstance(); $formula = "=ROMAN({$values}, {$styles})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index 76ad3015c7..641a9fad0c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -38,7 +38,7 @@ public function testRoundDownArray(array $expectedResult, string $argument1, str $calculation = Calculation::getInstance(); $formula = "=ROUNDDOWN({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php index 710d5b0051..0a56ebb053 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php @@ -38,7 +38,7 @@ public function testRoundArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=ROUND({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index d204a1fb83..4c28a0699f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -38,7 +38,7 @@ public function testRoundUpArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=ROUNDUP({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index c7af031da2..4364d09941 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -38,7 +38,7 @@ public function testSecArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SEC({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index 402adf309e..8c63b3496b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -38,7 +38,7 @@ public function testSechArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SECH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php index 9346a6cc2c..f8df707384 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php @@ -32,4 +32,28 @@ public function providerSEQUENCE(): array { return require 'tests/data/Calculation/MathTrig/SEQUENCE.php'; } + + public function testSequenceAsCellFormula(): void + { + $sheet = $this->getSheet(); + $sheet->getCell('B2')->setValue('=SEQUENCE(3,3,9,-1)', true, 'B2:D4'); + + $result = $sheet->getCell('B2')->getCalculatedValue(); + self::assertSame(9, $result); + + // Check that spillage area has been populated + self::assertSame(5, $sheet->getCell('C3')->getCalculatedValue()); + } + + public function testSequenceAsCellFormulaAsArray(): void + { + $sheet = $this->getSheet(); + $sheet->getCell('B2')->setValue('=SEQUENCE(3,3,9,-1)', true, 'B2:D4'); + + $result = $sheet->getCell('B2')->getCalculatedValue(true); + self::assertSame([[9, 8, 7], [6, 5, 4], [3, 2, 1]], $result); + + // Check that spillage area has been populated + self::assertSame(5, $sheet->getCell('C3')->getCalculatedValue()); + } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php index 04ef6ec307..89fa4cb995 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -53,7 +53,7 @@ public function testSeriesSumArray(array $expectedResult, string $x, string $n, $calculation = Calculation::getInstance(); $formula = "=SERIESSUM({$x}, {$n}, {$m}, {$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index bef03503d9..a4d67e91ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -37,7 +37,7 @@ public function testSignArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SIGN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php index ce7b29c39a..0369b9060f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php @@ -34,7 +34,7 @@ public function testSinArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SIN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php index 1f64d18205..69046c3882 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php @@ -34,7 +34,7 @@ public function testSinhArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SINH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php index 1eac23299f..2da7802b3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -41,7 +41,7 @@ public function testSqrtPiArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SQRTPI({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php index 1068afc880..94ce5a5303 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php @@ -39,7 +39,7 @@ public function testSqrtArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=SQRT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php index 1ae6e2314a..9e18bd6f16 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -13,7 +13,7 @@ class SumIfsTest extends AllSetupTeardown */ public function testSUMIFS($expectedResult, ...$args): void { - $result = Statistical\Conditional::SUMIFS(...$args); + $result = Statistical\Conditional::sumIfSeries(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php index 75993f620b..ae1aa78c62 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php @@ -34,7 +34,7 @@ public function testTanArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=TAN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php index b75a0457b8..91316bcefc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php @@ -34,7 +34,7 @@ public function testTanhArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=TANH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index e1cb6ea5bb..5ee5cbdc56 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -38,7 +38,7 @@ public function testTruncArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=TRUNC({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php index ea3df6bbea..572c19104e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages; use PHPUnit\Framework\TestCase; class AveDevTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testAVEDEV($expectedResult, ...$args): void { - $result = Statistical::AVEDEV(...$args); + $result = Averages::averageDeviations(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php index fec65c2810..013e15400d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages; use PHPUnit\Framework\TestCase; class AverageATest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testAVERAGEA($expectedResult, ...$args): void { - $result = Statistical::AVERAGEA(...$args); + $result = Averages::averageA(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php index c9648d433d..fe696dad0c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional; use PHPUnit\Framework\TestCase; class AverageIfTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testAVERAGEIF($expectedResult, ...$args): void { - $result = Statistical::AVERAGEIF(...$args); + $result = Conditional::averageIf(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php index de59376490..55fc6749ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testAVERAGEIFS($expectedResult, ...$args): void { - $result = Statistical\Conditional::AVERAGEIFS(...$args); + $result = Statistical\Conditional::averageIfSeries(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php index d5e617a98d..63663a6630 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages; use PHPUnit\Framework\TestCase; class AverageTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testAVERAGE($expectedResult, ...$args): void { - $result = Statistical::AVERAGE(...$args); + $result = Averages::average(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php index 02f05c5466..714f04ccc4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Beta; use PHPUnit\Framework\TestCase; class BetaDistTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testBETADIST($expectedResult, ...$args): void { - $result = Statistical::BETADIST(...$args); + $result = Beta::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testBetaDistArray(array $expectedResult, string $argument1, stri $calculation = Calculation::getInstance(); $formula = "=BETADIST({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php index ba3705a130..50a93269a0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Beta; use PHPUnit\Framework\TestCase; class BetaInvTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testBETAINV($expectedResult, ...$args): void { - $result = Statistical::BETAINV(...$args); + $result = Beta::inverse(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testBetaInvArray(array $expectedResult, string $argument1, strin $calculation = Calculation::getInstance(); $formula = "=BETAINV({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php index da617fab58..7cb5f552c5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Binomial; use PHPUnit\Framework\TestCase; class BinomDistRangeTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testBINOMDISTRANGE($expectedResult, ...$args): void { - $result = Statistical\Distributions\Binomial::range(...$args); + $result = Binomial::range(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -42,7 +42,7 @@ public function testBinomDistRangeArray( $calculation = Calculation::getInstance(); $formula = "=BINOM.DIST.RANGE({$trials}, {$probabilities}, {$successes})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php index 94689538bb..e9672a148e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Binomial; use PHPUnit\Framework\TestCase; class BinomDistTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testBINOMDIST($expectedResult, ...$args): void { - $result = Statistical::BINOMDIST(...$args); + $result = Binomial::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -42,7 +42,7 @@ public function testBinomDistArray( $calculation = Calculation::getInstance(); $formula = "=BINOMDIST({$values}, {$trials}, {$probabilities}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php index 6ea2b55baf..af5e2ad17c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Binomial; use PHPUnit\Framework\TestCase; class BinomInvTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testBINOMINV($expectedResult, ...$args): void { - $result = Statistical::CRITBINOM(...$args); + $result = Binomial::inverse(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -42,7 +42,7 @@ public function testBinomInvArray( $calculation = Calculation::getInstance(); $formula = "=BINOM.INV({$trials}, {$probabilities}, {$alphas})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php index eb334b25b9..eeadf0f029 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\ChiSquared; use PHPUnit\Framework\TestCase; class ChiDistLeftTailTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testCHIDIST($expectedResult, ...$args): void { - $result = Statistical\Distributions\ChiSquared::distributionLeftTail(...$args); + $result = ChiSquared::distributionLeftTail(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testChiDistLeftTailArray(array $expectedResult, string $values, $calculation = Calculation::getInstance(); $formula = "=CHISQ.DIST({$values}, {$degrees}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php index 5cd210ef79..6e30566832 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\ChiSquared; use PHPUnit\Framework\TestCase; class ChiDistRightTailTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testCHIDIST($expectedResult, ...$args): void { - $result = Statistical::CHIDIST(...$args); + $result = ChiSquared::distributionRightTail(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testChiDistRightTailArray(array $expectedResult, string $values, $calculation = Calculation::getInstance(); $formula = "=CHISQ.DIST.RT({$values}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php index c4fe1e9444..c499fb0b56 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\ChiSquared; use PHPUnit\Framework\TestCase; class ChiInvLeftTailTest extends TestCase @@ -23,9 +23,9 @@ protected function setUp(): void */ public function testCHIINV($expectedResult, $probability, $degrees): void { - $result = Statistical\Distributions\ChiSquared::inverseLeftTail($probability, $degrees); + $result = ChiSquared::inverseLeftTail($probability, $degrees); if (!is_string($expectedResult)) { - $reverse = Statistical\Distributions\ChiSquared::distributionLeftTail($result, $degrees, true); + $reverse = ChiSquared::distributionLeftTail($result, $degrees, true); self::assertEqualsWithDelta($probability, $reverse, 1E-12); } self::assertEqualsWithDelta($expectedResult, $result, 1E-12); @@ -44,7 +44,7 @@ public function testChiInvLeftTailArray(array $expectedResult, string $probabili $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV({$probabilities}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php index 629466e2c9..c1727b10f7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\ChiSquared; use PHPUnit\Framework\TestCase; class ChiInvRightTailTest extends TestCase @@ -23,9 +23,9 @@ protected function setUp(): void */ public function testCHIINV($expectedResult, $probability, $degrees): void { - $result = Statistical::CHIINV($probability, $degrees); + $result = ChiSquared::inverseRightTail($probability, $degrees); if (!is_string($expectedResult)) { - $reverse = Statistical\Distributions\ChiSquared::distributionRightTail($result, $degrees); + $reverse = ChiSquared::distributionRightTail($result, $degrees); self::assertEqualsWithDelta($probability, $reverse, 1E-12); } self::assertEqualsWithDelta($expectedResult, $result, 1E-12); @@ -44,7 +44,7 @@ public function testChiInvRightTailArray(array $expectedResult, string $probabil $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV.RT({$probabilities}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php index ed608d5849..c6d43a7681 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\ChiSquared; use PHPUnit\Framework\TestCase; class ChiTestTest extends TestCase @@ -16,7 +16,7 @@ class ChiTestTest extends TestCase */ public function testCHITEST($expectedResult, $actual, $expected): void { - $result = Statistical\Distributions\ChiSquared::test($actual, $expected); + $result = ChiSquared::test($actual, $expected); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php index b7a4607c4c..9f387fb0fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Confidence; use PHPUnit\Framework\TestCase; class ConfidenceTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testCONFIDENCE($expectedResult, ...$args): void { - $result = Statistical::CONFIDENCE(...$args); + $result = Confidence::confidence(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testConfidenceArray(array $expectedResult, string $alpha, string $calculation = Calculation::getInstance(); $formula = "=CONFIDENCE({$alpha}, {$stdDev}, {$size})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php index adadf422f6..2b5f9038c3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class CorrelTest extends TestCase @@ -22,7 +22,7 @@ protected function setUp(): void */ public function testCORREL($expectedResult, $xargs, $yargs): void { - $result = Statistical::CORREL($xargs, $yargs); + $result = Trends::correlation($xargs, $yargs); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php index 0e53015885..db7ad9e10f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts; use PHPUnit\Framework\TestCase; class CountATest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testCOUNTA($expectedResult, ...$args): void { - $result = Statistical::COUNTA(...$args); + $result = Counts::countA(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php index 24667a6b15..cb65158975 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts; use PHPUnit\Framework\TestCase; class CountBlankTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testCOUNTBLANK($expectedResult, ...$args): void { - $result = Statistical::COUNTBLANK(...$args); + $result = Counts::blank(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php index c42d7eef1c..66d3054d0d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional; use PHPUnit\Framework\TestCase; class CountIfTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testCOUNTIF($expectedResult, ...$args): void { - $result = Statistical::COUNTIF(...$args); + $result = Conditional::countIf(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php index a68d7240dd..27d7807737 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional; use PHPUnit\Framework\TestCase; class CountIfsTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testCOUNTIFS($expectedResult, ...$args): void { - $result = Statistical::COUNTIFS(...$args); + $result = Conditional::countIfSeries(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php index 07f4f91840..56840f680e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts; use PHPUnit\Framework\TestCase; class CountTest extends TestCase @@ -31,7 +31,7 @@ protected function tearDown(): void */ public function testBasicCOUNT($expectedResult, ...$args): void { - $result = Statistical::COUNT(...$args); + $result = Counts::count(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -47,7 +47,7 @@ public function providerBasicCOUNT(): array */ public function testExcelCOUNT($expectedResult, ...$args): void { - $result = Statistical::COUNT(...$args); + $result = Counts::count(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -65,7 +65,7 @@ public function testOpenOfficeCOUNT($expectedResult, ...$args): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::COUNT(...$args); + $result = Counts::count(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -83,7 +83,7 @@ public function testGnumericCOUNT($expectedResult, ...$args): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); - $result = Statistical::COUNT(...$args); + $result = Counts::count(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php index e85c6f923b..e631f986f6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class CovarTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testCOVAR($expectedResult, ...$args): void { - $result = Statistical::COVAR(...$args); + $result = Trends::covariance(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php index 2db2930046..d7069c9dbc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Deviations; use PHPUnit\Framework\TestCase; class DevSqTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testDEVSQ($expectedResult, ...$args): void { - $result = Statistical::DEVSQ(...$args); + $result = Deviations::sumSquares(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php index 0d80aa3553..d4d25528b6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Exponential; use PHPUnit\Framework\TestCase; class ExponDistTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testEXPONDIST($expectedResult, ...$args): void { - $result = Statistical::EXPONDIST(...$args); + $result = Exponential::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testExponDistArray(array $expectedResult, string $values, string $calculation = Calculation::getInstance(); $formula = "=EXPONDIST({$values}, {$lambdas}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php index 97af9cf8f3..0fcd82c5aa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\F; use PHPUnit\Framework\TestCase; class FDistTest extends TestCase @@ -15,7 +15,7 @@ class FDistTest extends TestCase */ public function testFDIST($expectedResult, ...$args): void { - $result = Statistical::FDIST2(...$args); + $result = F::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testFDistArray(array $expectedResult, string $values, string $u, $calculation = Calculation::getInstance(); $formula = "=F.DIST({$values}, {$u}, {$v}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php index 44f9c348a7..f2b6777d04 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Fisher; use PHPUnit\Framework\TestCase; class FisherInvTest extends TestCase @@ -22,7 +22,7 @@ protected function setUp(): void */ public function testFISHERINV($expectedResult, $value): void { - $result = Statistical::FISHERINV($value); + $result = Fisher::inverse($value); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -39,7 +39,7 @@ public function testFisherArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=FISHERINV({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php index a3750b6f38..06550e00f4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Fisher; use PHPUnit\Framework\TestCase; class FisherTest extends TestCase @@ -22,7 +22,7 @@ protected function setUp(): void */ public function testFISHER($expectedResult, $value): void { - $result = Statistical::FISHER($value); + $result = Fisher::distribution($value); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -39,7 +39,7 @@ public function testFisherArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=FISHER({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php index 7f190093d0..6b6ad79a6e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class ForecastTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testFORECAST($expectedResult, ...$args): void { - $result = Statistical::FORECAST(...$args); + $result = Trends::forecast(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testForecastArray(array $expectedResult, string $testValues, str $calculation = Calculation::getInstance(); $formula = "=FORECAST({$testValues}, {$yValues}, {$xValues})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php index 3ed71725ab..7bba70b7bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Gamma; use PHPUnit\Framework\TestCase; class GammaDistTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testGAMMADIST($expectedResult, ...$args): void { - $result = Statistical::GAMMADIST(...$args); + $result = Gamma::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testGammaDistArray(array $expectedResult, string $values, string $calculation = Calculation::getInstance(); $formula = "=GAMMA.DIST({$values}, {$alpha}, {$beta}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php index d3e7c13c62..bc0b54c63a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Gamma; use PHPUnit\Framework\TestCase; class GammaInvTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testGAMMAINV($expectedResult, ...$args): void { - $result = Statistical::GAMMAINV(...$args); + $result = Gamma::inverse(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testGammaInvArray(array $expectedResult, string $values, string $calculation = Calculation::getInstance(); $formula = "=GAMMA.INV({$values}, {$alpha}, {$beta})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index 5b444e8007..5d22c60dba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Gamma; use PHPUnit\Framework\TestCase; class GammaLnTest extends TestCase @@ -22,7 +22,7 @@ protected function setUp(): void */ public function testGAMMALN($expectedResult, $value): void { - $result = Statistical::GAMMALN($value); + $result = Gamma::ln($value); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -39,7 +39,7 @@ public function testGammaLnArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=GAMMALN({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php index 8372ab327e..aa5ca819d1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Gamma; use PHPUnit\Framework\TestCase; class GammaTest extends TestCase @@ -16,7 +16,7 @@ class GammaTest extends TestCase */ public function testGAMMA($expectedResult, $testValue): void { - $result = Statistical::GAMMAFunction($testValue); + $result = Gamma::gamma($testValue); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -33,7 +33,7 @@ public function testGammaArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=GAMMA({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php index 0914b829ca..57333c771b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StandardNormal; use PHPUnit\Framework\TestCase; class GaussTest extends TestCase @@ -16,7 +16,7 @@ class GaussTest extends TestCase */ public function testGAUSS($expectedResult, $testValue): void { - $result = Statistical::GAUSS($testValue); + $result = StandardNormal::gauss($testValue); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -33,7 +33,7 @@ public function testGaussArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=GAUSS({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php index 859212f53b..a62f32eee5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages\Mean; use PHPUnit\Framework\TestCase; class GeoMeanTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testGEOMEAN($expectedResult, ...$args): void { - $result = Statistical::GEOMEAN(...$args); + $result = Mean::geometric(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php index a796c370ed..e988c20d01 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class GrowthTest extends TestCase @@ -21,11 +21,11 @@ protected function setUp(): void public function testGROWTH($expectedResult, array $yValues, array $xValues, ?array $newValues = null, ?bool $const = null): void { if ($newValues === null) { - $result = Statistical::GROWTH($yValues, $xValues); + $result = Trends::growth($yValues, $xValues); } elseif ($const === null) { - $result = Statistical::GROWTH($yValues, $xValues, $newValues); + $result = Trends::growth($yValues, $xValues, $newValues); } else { - $result = Statistical::GROWTH($yValues, $xValues, $newValues, $const); + $result = Trends::growth($yValues, $xValues, $newValues, $const); } self::assertEqualsWithDelta($expectedResult, $result[0], 1E-12); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php index 2dbc0cba81..8855c53388 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages\Mean; use PHPUnit\Framework\TestCase; class HarMeanTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testHARMEAN($expectedResult, ...$args): void { - $result = Statistical::HARMEAN(...$args); + $result = Mean::harmonic(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php index ecd7218d4d..6491fed255 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\HyperGeometric; use PHPUnit\Framework\TestCase; class HypGeomDistTest extends TestCase @@ -15,7 +15,7 @@ class HypGeomDistTest extends TestCase */ public function testHYPGEOMDIST($expectedResult, ...$args): void { - $result = Statistical::HYPGEOMDIST(...$args); + $result = HyperGeometric::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -37,7 +37,7 @@ public function testHypGeomDistArray( $calculation = Calculation::getInstance(); $formula = "=HYPGEOMDIST({$sampleSuccesses}, {$sampleNumber}, {$populationSuccesses}, {$populationNumber})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php index 9ccea5cb0c..971063396a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class InterceptTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testINTERCEPT($expectedResult, array $xargs, array $yargs): void { - $result = Statistical::INTERCEPT($xargs, $yargs); + $result = Trends::intercept($xargs, $yargs); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php index d793736a52..6652b88d31 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Deviations; use PHPUnit\Framework\TestCase; class KurtTest extends TestCase @@ -14,7 +14,7 @@ class KurtTest extends TestCase */ public function testKURT($expectedResult, ...$args): void { - $result = Statistical::KURT(...$args); + $result = Deviations::kurtosis(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php index 18694210a0..64828e341a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Size; use PHPUnit\Framework\TestCase; class LargeTest extends TestCase @@ -16,7 +16,7 @@ class LargeTest extends TestCase */ public function testLARGE($expectedResult, $values, $position): void { - $result = Statistical::LARGE($values, $position); + $result = Size::large($values, $position); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php index 539d915f6d..5fc70bb157 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class LinEstTest extends TestCase @@ -17,7 +17,7 @@ class LinEstTest extends TestCase */ public function testLINEST(array $expectedResult, $yValues, $xValues, $const, $stats): void { - $result = Statistical::LINEST($yValues, $xValues, $const, $stats); + $result = Trends::lineEstimate($yValues, $xValues, $const, $stats); self::assertIsArray($result); $elements = count($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php index 1537de69a1..f96737a04e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class LogEstTest extends TestCase @@ -17,7 +17,7 @@ class LogEstTest extends TestCase */ public function testLOGEST(array $expectedResult, $yValues, $xValues, $const, $stats): void { - $result = Statistical::LOGEST($yValues, $xValues, $const, $stats); + $result = Trends::logEstimate($yValues, $xValues, $const, $stats); self::assertIsArray($result); $elements = count($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php index 0ae547b8e7..ccefac8903 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\LogNormal; use PHPUnit\Framework\TestCase; class LogInvTest extends TestCase @@ -15,7 +15,7 @@ class LogInvTest extends TestCase */ public function testLOGINV($expectedResult, ...$args): void { - $result = Statistical::LOGINV(...$args); + $result = LogNormal::inverse(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testLogInvArray(array $expectedResult, string $probabilities, st $calculation = Calculation::getInstance(); $formula = "=LOGINV({$probabilities}, {$mean}, {$stdDev})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php index 3d2fac44eb..d7a97819b1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\LogNormal; use PHPUnit\Framework\TestCase; class LogNormDist2Test extends TestCase @@ -15,7 +15,7 @@ class LogNormDist2Test extends TestCase */ public function testLOGNORMDIST2($expectedResult, ...$args): void { - $result = Statistical::LOGNORMDIST2(...$args); + $result = LogNormal::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testLogNormDist2Array(array $expectedResult, string $values, str $calculation = Calculation::getInstance(); $formula = "=LOGNORM.DIST({$values}, {$mean}, {$stdDev}, true)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php index 7fbac2f8b0..45e8d8eea9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\LogNormal; use PHPUnit\Framework\TestCase; class LogNormDistTest extends TestCase @@ -15,7 +15,7 @@ class LogNormDistTest extends TestCase */ public function testLOGNORMDIST($expectedResult, ...$args): void { - $result = Statistical::LOGNORMDIST(...$args); + $result = LogNormal::cumulative(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testLogNormDistArray(array $expectedResult, string $values, stri $calculation = Calculation::getInstance(); $formula = "=LOGNORMDIST({$values}, {$mean}, {$stdDev})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php index ce338e84ca..135a3a9324 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Maximum; use PHPUnit\Framework\TestCase; class MaxATest extends TestCase @@ -14,7 +14,7 @@ class MaxATest extends TestCase */ public function testMAXA($expectedResult, ...$args): void { - $result = Statistical::MAXA(...$args); + $result = Maximum::maxA(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php index d4c00a4ba1..b2b6415271 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional; use PHPUnit\Framework\TestCase; class MaxIfsTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testMAXIFS($expectedResult, ...$args): void { - $result = Statistical::MAXIFS(...$args); + $result = Conditional::maxIfSeries(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php index cd329aa9ea..0b5b03e9b5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Maximum; use PHPUnit\Framework\TestCase; class MaxTest extends TestCase @@ -14,7 +14,7 @@ class MaxTest extends TestCase */ public function testMAX($expectedResult, ...$args): void { - $result = Statistical::MAX(...$args); + $result = Maximum::max(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php index 68e46e189b..aaa82a4ee5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages; use PHPUnit\Framework\TestCase; class MedianTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testMEDIAN($expectedResult, ...$args): void { - $result = Statistical::MEDIAN(...$args); + $result = Averages::median(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php index f24d1ca2bf..a5e5af9121 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Minimum; use PHPUnit\Framework\TestCase; class MinATest extends TestCase @@ -14,7 +14,7 @@ class MinATest extends TestCase */ public function testMINA($expectedResult, ...$args): void { - $result = Statistical::MINA(...$args); + $result = Minimum::minA(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php index 201e9e744e..76f049ae8d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional; use PHPUnit\Framework\TestCase; class MinIfsTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testMINIFS($expectedResult, ...$args): void { - $result = Statistical::MINIFS(...$args); + $result = Conditional::minIfSeries(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php index a5a1658826..09afae2aad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Minimum; use PHPUnit\Framework\TestCase; class MinTest extends TestCase @@ -14,7 +14,7 @@ class MinTest extends TestCase */ public function testMIN($expectedResult, ...$args): void { - $result = Statistical::MIN(...$args); + $result = Minimum::min(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php index 2e73f8109e..725b2abb84 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Binomial; use PHPUnit\Framework\TestCase; class NegBinomDistTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testNEGBINOMDIST($expectedResult, ...$args): void { - $result = Statistical::NEGBINOMDIST(...$args); + $result = Binomial::negative(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -42,7 +42,7 @@ public function testNegBinomDistArray( $calculation = Calculation::getInstance(); $formula = "=NEGBINOMDIST({$failures}, {$successes}, {$probabilities})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php index 367ce51155..1bb0777e06 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Normal; use PHPUnit\Framework\TestCase; class NormDistTest extends TestCase @@ -15,7 +15,7 @@ class NormDistTest extends TestCase */ public function testNORMDIST($expectedResult, ...$args): void { - $result = Statistical::NORMDIST(...$args); + $result = Normal::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testNormDistArray(array $expectedResult, string $values, string $calculation = Calculation::getInstance(); $formula = "=NORMDIST({$values}, {$mean}, {$stdDev}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php index ca056a398d..137f992472 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Normal; use PHPUnit\Framework\TestCase; class NormInvTest extends TestCase @@ -15,7 +15,7 @@ class NormInvTest extends TestCase */ public function testNORMINV($expectedResult, ...$args): void { - $result = Statistical::NORMINV(...$args); + $result = Normal::inverse(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } @@ -32,7 +32,7 @@ public function testNormInvArray(array $expectedResult, string $probabilities, s $calculation = Calculation::getInstance(); $formula = "=NORMINV({$probabilities}, {$mean}, {$stdDev})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php index 2c03b795dc..e5be7ecf6a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StandardNormal; use PHPUnit\Framework\TestCase; class NormSDist2Test extends TestCase @@ -15,7 +15,7 @@ class NormSDist2Test extends TestCase */ public function testNORMSDIST2($expectedResult, ...$args): void { - $result = Statistical::NORMSDIST2(...$args); + $result = StandardNormal::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testNormSDist2Array(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=NORM.S.DIST({$values}, true)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php index a2fbf497ea..37708b21f8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StandardNormal; use PHPUnit\Framework\TestCase; class NormSDistTest extends TestCase @@ -16,7 +16,7 @@ class NormSDistTest extends TestCase */ public function testNORMSDIST($expectedResult, $testValue): void { - $result = Statistical::NORMSDIST($testValue); + $result = StandardNormal::cumulative($testValue); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -33,7 +33,7 @@ public function testNormSDistArray(array $expectedResult, string $values): void $calculation = Calculation::getInstance(); $formula = "=NORMSDIST({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php index a2465f15a7..55c79b7df9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StandardNormal; use PHPUnit\Framework\TestCase; class NormSInvTest extends TestCase @@ -16,7 +16,7 @@ class NormSInvTest extends TestCase */ public function testNORMSINV($expectedResult, $testValue): void { - $result = Statistical::NORMSINV($testValue); + $result = StandardNormal::inverse($testValue); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -33,7 +33,7 @@ public function testNormSInvArray(array $expectedResult, string $probabilities): $calculation = Calculation::getInstance(); $formula = "=NORMSINV({$probabilities})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php index 4022ae40e5..d8311342eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Percentiles; use PHPUnit\Framework\TestCase; class PercentRankTest extends TestCase @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testPERCENTRANK($expectedResult, $valueSet, $value, $digits = 3): void { - $result = Statistical::PERCENTRANK($valueSet, $value, $digits); + $result = Percentiles::percentRank($valueSet, $value, $digits); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php index e4dadb74a0..8dcf11f549 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Percentiles; use PHPUnit\Framework\TestCase; class PercentileTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testPERCENTILE($expectedResult, ...$args): void { - $result = Statistical::PERCENTILE(...$args); + $result = Percentiles::percentile(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php index 1e2401a539..92ee67a65f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Permutations; use PHPUnit\Framework\TestCase; class PermutTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testPERMUT($expectedResult, ...$args): void { - $result = Statistical::PERMUT(...$args); + $result = Permutations::permut(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testPermutArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=PERMUT({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php index e1c8835e26..7d67ff286c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testPERMUT($expectedResult, ...$args): void { - $result = Permutations::PERMUTATIONA(...$args); + $result = Permutations::permutationA(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testPermutationAArray(array $expectedResult, string $argument1, $calculation = Calculation::getInstance(); $formula = "=PERMUTATIONA({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php index 8df54c994f..a187710059 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Poisson; use PHPUnit\Framework\TestCase; class PoissonTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testPOISSON($expectedResult, ...$args): void { - $result = Statistical::POISSON(...$args); + $result = Poisson::distribution(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -38,7 +38,7 @@ public function testPoissonArray(array $expectedResult, string $values, string $ $calculation = Calculation::getInstance(); $formula = "=POISSON({$values}, {$mean}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php index 33b3c599ee..1a4f82d608 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Percentiles; use PHPUnit\Framework\TestCase; class QuartileTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testQUARTILE($expectedResult, ...$args): void { - $result = Statistical::QUARTILE(...$args); + $result = Percentiles::quartile(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php index bbbac36fd1..37e4f326c6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Percentiles; use PHPUnit\Framework\TestCase; class RankTest extends TestCase @@ -23,7 +23,7 @@ protected function setUp(): void */ public function testRANK($expectedResult, $value, $valueSet, $order = 0): void { - $result = Statistical::RANK($value, $valueSet, $order); + $result = Percentiles::rank($value, $valueSet, $order); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php index a85bba06c6..5231815e43 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class RsqTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testRSQ($expectedResult, array $xargs, array $yargs): void { - $result = Statistical::RSQ($xargs, $yargs); + $result = Trends::pearsonSquares($xargs, $yargs); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php index 4415ec4a69..6da5543694 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Deviations; use PHPUnit\Framework\TestCase; class SkewTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testSKEW($expectedResult, array $args): void { - $result = Statistical::SKEW($args); + $result = Deviations::skew($args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php index 9bab264c9d..b2b20bb239 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class SlopeTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testSLOPE($expectedResult, array $xargs, array $yargs): void { - $result = Statistical::SLOPE($xargs, $yargs); + $result = Trends::slope($xargs, $yargs); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php index 52c82f6bed..ef6d6c5ca3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Size; use PHPUnit\Framework\TestCase; class SmallTest extends TestCase @@ -16,7 +16,7 @@ class SmallTest extends TestCase */ public function testSMALL($expectedResult, $values, $position): void { - $result = Statistical::SMALL($values, $position); + $result = Size::small($values, $position); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php index 1de33a778d..00d1e47f32 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations; use PHPUnit\Framework\TestCase; class StDevATest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testSTDEVA($expectedResult, $values): void { - $result = Statistical::STDEVA($values); + $result = StandardDeviations::stdevA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsSTDEVA($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::STDEVA($values); + $result = StandardDeviations::stdevA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php index f19f072e53..6718fbb0fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations; use PHPUnit\Framework\TestCase; class StDevPATest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testSTDEVPA($expectedResult, $values): void { - $result = Statistical::STDEVPA($values); + $result = StandardDeviations::stdevPA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsSTDEVPA($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::STDEVPA($values); + $result = StandardDeviations::stdevPA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php index 39de961dd6..011a60e1a2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations; use PHPUnit\Framework\TestCase; class StDevPTest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testSTDEVP($expectedResult, $values): void { - $result = Statistical::STDEVP($values); + $result = StandardDeviations::stdevP($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsSTDEVP($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::STDEVP($values); + $result = StandardDeviations::stdevP($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php index e99041096d..c433d0104b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations; use PHPUnit\Framework\TestCase; class StDevTest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testSTDEV($expectedResult, $values): void { - $result = Statistical::STDEV($values); + $result = StandardDeviations::stdev($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsSTDEV($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::STDEV($values); + $result = StandardDeviations::stdev($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php index 2177cee5d2..ed97d2aaa4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Standardize; use PHPUnit\Framework\TestCase; class StandardizeTest extends TestCase @@ -15,7 +15,7 @@ class StandardizeTest extends TestCase */ public function testSTANDARDIZE($expectedResult, ...$args): void { - $result = Statistical::STANDARDIZE(...$args); + $result = Standardize::execute(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -32,7 +32,7 @@ public function testStandardizeArray(array $expectedResult, string $argument1, s $calculation = Calculation::getInstance(); $formula = "=STANDARDIZE({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php index cefc79c528..ef64cd139a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class SteyxTest extends TestCase @@ -20,7 +20,7 @@ protected function setUp(): void */ public function testSTEYX($expectedResult, array $xargs, array $yargs): void { - $result = Statistical::STEYX($xargs, $yargs); + $result = Trends::standardError($xargs, $yargs); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php index 87ca19732b..3ff41a3a9c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StudentT; use PHPUnit\Framework\TestCase; class TDistTest extends TestCase @@ -18,7 +18,7 @@ class TDistTest extends TestCase */ public function testTDIST($expectedResult, $value, $degrees, $tails): void { - $result = Statistical::TDIST($value, $degrees, $tails); + $result = StudentT::distribution($value, $degrees, $tails); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -35,7 +35,7 @@ public function testTDistArray(array $expectedResult, string $values, string $de $calculation = Calculation::getInstance(); $formula = "=TDIST({$values}, {$degrees}, {$tails})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php index 1e6f81cfc8..8c6e330de6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StudentT; use PHPUnit\Framework\TestCase; class TinvTest extends TestCase @@ -17,7 +17,7 @@ class TinvTest extends TestCase */ public function testTINV($expectedResult, $probability, $degrees): void { - $result = Statistical::TINV($probability, $degrees); + $result = StudentT::inverse($probability, $degrees); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -34,7 +34,7 @@ public function testTInvArray(array $expectedResult, string $values, string $deg $calculation = Calculation::getInstance(); $formula = "=TINV({$values}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php index 2cb06b777c..37e1f85980 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends; use PHPUnit\Framework\TestCase; class TrendTest extends TestCase @@ -21,11 +21,11 @@ protected function setUp(): void public function testTREND($expectedResult, array $yValues, array $xValues, ?array $newValues = null, ?bool $const = null): void { if ($newValues === null) { - $result = Statistical::TREND($yValues, $xValues); + $result = Trends::trend($yValues, $xValues); } elseif ($const === null) { - $result = Statistical::TREND($yValues, $xValues, $newValues); + $result = Trends::trend($yValues, $xValues, $newValues); } else { - $result = Statistical::TREND($yValues, $xValues, $newValues, $const); + $result = Trends::trend($yValues, $xValues, $newValues, $const); } self::assertEqualsWithDelta($expectedResult, $result[0], 1E-12); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrimMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrimMeanTest.php index 54d7576a46..d9ae9feaa9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrimMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrimMeanTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages\Mean; use PHPUnit\Framework\TestCase; class TrimMeanTest extends TestCase @@ -21,7 +21,7 @@ protected function setUp(): void */ public function testTRIMMEAN($expectedResult, array $args, $percentage): void { - $result = Statistical::TRIMMEAN($args, $percentage); + $result = Mean::trim($args, $percentage); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php index a0bf818234..dbc45d0816 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances; use PHPUnit\Framework\TestCase; class VarATest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testVARA($expectedResult, $values): void { - $result = Statistical::VARA($values); + $result = Variances::varianceA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsVARA($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::VARA($values); + $result = Variances::varianceA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php index 88304d8eea..2f04d1e88e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances; use PHPUnit\Framework\TestCase; class VarPATest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testVARPA($expectedResult, $values): void { - $result = Statistical::VARPA($values); + $result = Variances::variancePA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsVARPA($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::VARPA($values); + $result = Variances::variancePA($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php index 1a0475eb09..5ba80661a3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances; use PHPUnit\Framework\TestCase; class VarPTest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testVARP($expectedResult, $values): void { - $result = Statistical::VARP($values); + $result = Variances::varianceP($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsVARP($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::VARP($values); + $result = Variances::varianceP($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php index 5fc163b50d..76dd3d5d98 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances; use PHPUnit\Framework\TestCase; class VarTest extends TestCase @@ -21,7 +21,7 @@ protected function tearDown(): void */ public function testVAR($expectedResult, $values): void { - $result = Statistical::VARFunc($values); + $result = Variances::variance($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -40,7 +40,7 @@ public function testOdsVAR($expectedResult, $values): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = Statistical::VARFunc($values); + $result = Variances::variance($values); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php index ec8c2ec68f..43d807e442 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\Weibull; use PHPUnit\Framework\TestCase; class WeibullTest extends TestCase @@ -19,7 +19,7 @@ class WeibullTest extends TestCase */ public function testWEIBULL($expectedResult, $value, $alpha, $beta, $cumulative): void { - $result = Statistical::WEIBULL($value, $alpha, $beta, $cumulative); + $result = Weibull::distribution($value, $alpha, $beta, $cumulative); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -36,7 +36,7 @@ public function testWeibullArray(array $expectedResult, string $values, string $ $calculation = Calculation::getInstance(); $formula = "=WEIBULL({$values}, {$alpha}, {$beta}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php index de094f74ac..b3a50e8ec0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Statistical; +use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\StandardNormal; use PHPUnit\Framework\TestCase; class ZTestTest extends TestCase @@ -18,7 +18,7 @@ class ZTestTest extends TestCase */ public function testZTEST($expectedResult, $dataSet, $value, $sigma = null): void { - $result = Statistical::ZTEST($dataSet, $value, $sigma); + $result = StandardNormal::zTest($dataSet, $value, $sigma); self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } @@ -35,7 +35,7 @@ public function testZTestArray(array $expectedResult, string $dataSet, string $m $calculation = Calculation::getInstance(); $formula = "=ZTEST({$dataSet}, {$m0})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php index 5cdca68518..6bd104e606 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -39,7 +39,7 @@ public function testCharArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=CHAR({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 4297d580c9..b17b39613f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -39,7 +39,7 @@ public function testCleanArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=CLEAN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index 5075ad575a..44c9e9f017 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -39,7 +39,7 @@ public function testCodeArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=CODE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php deleted file mode 100644 index 49ac421b84..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php +++ /dev/null @@ -1,44 +0,0 @@ -_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index fed029eb5b..c18ceb5270 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -44,7 +44,7 @@ public function testExactArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=EXACT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index 27ed3762e8..2e260175ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -50,7 +50,7 @@ public function testFindArray(array $expectedResult, string $argument1, string $ $calculation = Calculation::getInstance(); $formula = "=FIND({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index 6c857956bd..62151009ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -50,7 +50,7 @@ public function testFixedArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=FIXED({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index 7f709d64dc..81c092c8fd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -190,7 +190,7 @@ public function testLeftArray(array $expectedResult, string $argument1, string $ $calculation = Calculation::getInstance(); $formula = "=LEFT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index 68f804d8e2..c2bf488b8e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -39,7 +39,7 @@ public function testLenArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=LEN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index 3b1918436d..e5f80e7fdc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -74,7 +74,7 @@ public function testLowerArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=LOWER({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index e4ff934302..830c6fe456 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -212,7 +212,7 @@ public function testMidArray(array $expectedResult, string $argument1, string $a $calculation = Calculation::getInstance(); $formula = "=MID({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 1a909932db..97ccc55613 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -52,7 +52,7 @@ public function testNumberValueArray(array $expectedResult, string $argument1, s $calculation = Calculation::getInstance(); $formula = "=NumberValue({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, self::NV_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index d5e86c12a1..f34f76c042 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -74,7 +74,7 @@ public function testProperArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=PROPER({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index c64c4fe18e..9c4cd81554 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -62,7 +62,7 @@ public function testReplaceArray( $calculation = Calculation::getInstance(); $formula = "=REPLACE({$oldText}, {$start}, {$chars}, {$newText})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php index a36324e115..c8d3ffba3d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php @@ -44,7 +44,7 @@ public function testReptArray(array $expectedResult, string $argument1, string $ $calculation = Calculation::getInstance(); $formula = "=REPT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index d8de3e42af..b386acb980 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -190,7 +190,7 @@ public function testRightArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=RIGHT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index 1cd5dccc56..2157c0e48f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -50,7 +50,7 @@ public function testSearchArray(array $expectedResult, string $argument1, string $calculation = Calculation::getInstance(); $formula = "=SEARCH({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index dfb1e95233..31a427754b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -57,7 +57,7 @@ public function testSubstituteArray(array $expectedResult, string $oldText, stri $calculation = Calculation::getInstance(); $formula = "=SUBSTITUTE({$oldText}, {$fromText}, {$toText})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index e8111a2d11..b95b75745d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\TextData; +use PhpOffice\PhpSpreadsheet\Calculation\TextData\Text; use PHPUnit\Framework\TestCase; class TTest extends TestCase @@ -16,7 +16,7 @@ class TTest extends TestCase */ public function testT($expectedResult, $value): void { - $result = TextData::RETURNSTRING($value); + $result = Text::test($value); self::assertEquals($expectedResult, $result); } @@ -33,7 +33,7 @@ public function testTArray(array $expectedResult, string $argument): void $calculation = Calculation::getInstance(); $formula = "=T({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php index 8583433352..d08eea36b8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -43,7 +43,7 @@ public function testTextjoinArray(array $expectedResult, string $delimiter, stri $calculation = Calculation::getInstance(); $formula = "=TEXTJOIN({$delimiter}, {$blanks}, {$texts})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index 38ad410f0b..effba0664a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -44,7 +44,7 @@ public function testTextArray(array $expectedResult, string $argument1, string $ $calculation = Calculation::getInstance(); $formula = "=TEXT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index c9fe4d8124..df98447f1c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -39,7 +39,7 @@ public function testTrimArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=TRIM({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index da089ca78f..7382975c90 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -74,7 +74,7 @@ public function testUpperArray(array $expectedResult, string $array): void $calculation = Calculation::getInstance(); $formula = "=UPPER({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index cc7b362317..a67b95a5ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -75,7 +75,7 @@ public function testValueArray(array $expectedResult, string $argument): void $calculation = Calculation::getInstance(); $formula = "=VALUE({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php index 3ce6098da5..9b6fb109ee 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Web; -use PhpOffice\PhpSpreadsheet\Calculation\Web\Service; +use PhpOffice\PhpSpreadsheet\Calculation\Web\Service as WebService; use PHPUnit\Framework\TestCase; class UrlEncodeTest extends TestCase @@ -15,7 +15,7 @@ class UrlEncodeTest extends TestCase */ public function testURLENCODE($expectedResult, $text): void { - $result = Service::urlEncode($text); + $result = WebService::urlEncode($text); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php index c458fd22ec..7a46004e39 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Web; -use PhpOffice\PhpSpreadsheet\Calculation\Web; +use PhpOffice\PhpSpreadsheet\Calculation\Web\Service as WebService; use PhpOffice\PhpSpreadsheet\Settings; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientInterface; @@ -42,7 +42,7 @@ public function testWEBSERVICE(string $expectedResult, string $url, ?array $resp Settings::setHttpClient($client, $requestFactory); } - $result = Web::WEBSERVICE($url); + $result = WebService::WEBSERVICE($url); self::assertEquals($expectedResult, $result); } @@ -65,13 +65,13 @@ public function testWEBSERVICEReturnErrorWhenClientThrows(): void Settings::setHttpClient($client, $requestFactory); - $result = Web::WEBSERVICE('https://example.com'); + $result = WebService::WEBSERVICE('https://example.com'); self::assertEquals('#VALUE!', $result); } public function testWEBSERVICEThrowsIfNotClientConfigured(): void { $this->expectExceptionMessage('HTTP client must be configured via Settings::setHttpClient() to be able to use WEBSERVICE function.'); - Web::WEBSERVICE('https://example.com'); + WebService::WEBSERVICE('https://example.com'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsMatrixResizeTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsMatrixResizeTest.php new file mode 100644 index 0000000000..40ea7a0476 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsMatrixResizeTest.php @@ -0,0 +1,24 @@ +getActiveSheet(); + $sheet1->setTitle('SheetOne'); // no space in sheet title + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setTitle('Sheet Two'); // space in sheet title + + $sheet1->setCellValue('C3', '=SEQUENCE(3,3,-4)', true, 'C3:E5'); + $sheet2->setCellValue('C3', '=SEQUENCE(3,3, 9, -1)', true, 'C3:E5'); + $sheet1->setCellValue('A8', "=ANCHORARRAY({$reference})", true, $range); + + $result1 = $sheet1->getCell('A8')->getCalculatedValue(true, true); + self::assertSame($expectedResult, $result1); + $attributes1 = $sheet1->getCell('A8')->getFormulaAttributes(); + self::assertSame(['t' => 'array', 'ref' => $range], $attributes1); + } + + public function anchorArrayDataProvider(): array + { + return [ + [ + 'C3', + 'A8:C10', + [[-4, -3, -2], [-1, 0, 1], [2, 3, 4]], + ], + [ + "'Sheet Two'!C3", + 'A8:C10', + [[9, 8, 7], [6, 5, 4], [3, 2, 1]], + ], + ]; + } + + /** + * @dataProvider singleDataProvider + */ + public function testSingleArrayFormula(string $reference, array $expectedResult): void + { + $spreadsheet = new Spreadsheet(); + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setTitle('SheetOne'); // no space in sheet title + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setTitle('Sheet Two'); // space in sheet title + + $sheet1->setCellValue('C3', '=SEQUENCE(3,3,-4)', true, 'C3:E5'); + $sheet2->setCellValue('C3', '=SEQUENCE(3,3, 9, -1)', true, 'C3:E5'); + + $sheet1->setCellValue('A8', "=SINGLE({$reference})"); + + $result1 = $sheet1->getCell('A8')->getCalculatedValue(true, true); + self::assertSame($expectedResult, $result1); + } + + public function singleDataProvider(): array + { + return [ + [ + 'C3', + [[-4]], + ], + [ + "'Sheet Two'!C3", + [[9]], + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/TranslationTest.php b/tests/PhpSpreadsheetTests/Calculation/TranslationTest.php index ac1f15a15b..23ecdc7018 100644 --- a/tests/PhpSpreadsheetTests/Calculation/TranslationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/TranslationTest.php @@ -48,10 +48,10 @@ public function testTranslation(string $expectedResult, string $locale, string $ self::markTestSkipped("Unable to set locale to {$locale}"); } - $translatedFormula = Calculation::getInstance()->_translateFormulaToLocale($formula); + $translatedFormula = Calculation::getInstance()->translateFormulaToLocale($formula); self::assertSame($expectedResult, $translatedFormula); - $restoredFormula = Calculation::getInstance()->_translateFormulaToEnglish($translatedFormula); + $restoredFormula = Calculation::getInstance()->translateFormulaToEnglish($translatedFormula); self::assertSame($formula, $restoredFormula); } diff --git a/tests/PhpSpreadsheetTests/Cell/CellArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Cell/CellArrayFormulaTest.php new file mode 100644 index 0000000000..7cccdd4ee2 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Cell/CellArrayFormulaTest.php @@ -0,0 +1,99 @@ +getActiveSheet()->getCell('A1'); + $cell->setValueExplicit('=MAX(ABS({5, -3; 1, -12}))', DataType::TYPE_FORMULA, true); + + self::assertSame(12, $cell->getCalculatedValue()); + self::assertTrue($cell->isArrayFormula()); + self::assertSame('A1', $cell->arrayFormulaRange()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetValueArrayFormulaWithSpillage(): void + { + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit('=SEQUENCE(3, 3, 1, 1)', DataType::TYPE_FORMULA, true, 'A1:C3'); + + self::assertSame(1, $cell->getCalculatedValue()); + self::assertTrue($cell->isArrayFormula()); + self::assertSame('A1:C3', $cell->arrayFormulaRange()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetValueInSpillageRangeCell(): void + { + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit('=SEQUENCE(3, 3, 1, 1)', DataType::TYPE_FORMULA, true, 'A1:C3'); + + $cellAddress = 'C3'; + $spillageCell = $spreadsheet->getActiveSheet()->getCell($cellAddress); + self::assertTrue($spillageCell->isInSpillageRange()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testUpdateValueInSpillageRangeCell(): void + { + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit('=SEQUENCE(3, 3, 1, 1)', DataType::TYPE_FORMULA, true, 'A1:C3'); + + $cellAddress = 'C3'; + $spillageCell = $spreadsheet->getActiveSheet()->getCell($cellAddress); + self::assertTrue($spillageCell->isInSpillageRange()); + + $this->expectException(Exception::class); + $this->expectExceptionMessage("Cell {$cellAddress} is within the spillage range of a formula, and cannot be changed"); + $spillageCell->setValue('PHP'); + + $spreadsheet->disconnectWorksheets(); + } + + public function testUpdateArrayFormulaForSpillageRange(): void + { + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit('=SEQUENCE(3, 3, 1, 1)', DataType::TYPE_FORMULA, true, 'A1:C3'); + + $cell->setValueExplicit('=SEQUENCE(2, 2, 4, -1)', DataType::TYPE_FORMULA, true, 'A1:B2'); + + self::assertSame(4, $cell->getCalculatedValue()); + self::assertTrue($cell->isArrayFormula()); + self::assertSame('A1:B2', $cell->arrayFormulaRange()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetValueToFormerSpillageCell(): void + { + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit('=SEQUENCE(3, 3, 1, 1)', DataType::TYPE_FORMULA, true, 'A1:C3'); + + $cell->setValueExplicit('=SEQUENCE(2, 2, 4, -1)', DataType::TYPE_FORMULA, true, 'A1:B2'); + + $cellAddress = 'C3'; + $formerSpillageCell = $spreadsheet->getActiveSheet()->getCell($cellAddress); + $formerSpillageCell->setValue('PHP'); + + self::assertSame('PHP', $formerSpillageCell->getValue()); + + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Cell/CellFormulaTest.php b/tests/PhpSpreadsheetTests/Cell/CellFormulaTest.php new file mode 100644 index 0000000000..821ce4ca10 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Cell/CellFormulaTest.php @@ -0,0 +1,104 @@ +getActiveSheet()->getCell('A1'); + $cell->setValueExplicit($formula, DataType::TYPE_FORMULA); + + self::assertSame($formula, $cell->getValue()); + self::assertTrue($cell->isFormula()); + self::assertFalse($cell->isArrayFormula()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetFormulaDeterminedByBinder(): void + { + $formula = '=A2+B2'; + + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValue($formula); + + self::assertSame($formula, $cell->getValue()); + self::assertTrue($cell->isFormula()); + self::assertFalse($cell->isArrayFormula()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetFormulaInvalidValue(): void + { + $formula = true; + + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + + $cell->setValueExplicit($formula, DataType::TYPE_FORMULA); + + self::assertSame('TRUE', $cell->getValue()); + self::assertFalse($cell->isFormula()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetFormulaInvalidFormulaValue(): void + { + $formula = 'invalid formula'; + + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + + $cell->setValueExplicit($formula, DataType::TYPE_FORMULA); + + self::assertSame($formula, $cell->getValue()); + self::assertFalse($cell->isFormula()); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetArrayFormulaExplicitNoRange(): void + { + $formula = '=SUM(B2:B6*C2:C6)'; + + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit($formula, DataType::TYPE_FORMULA, true); + + self::assertSame($formula, $cell->getValue()); + self::assertTrue($cell->isFormula()); + self::assertTrue($cell->isArrayFormula()); + self::assertArrayHasKey('ref', $cell->getFormulaAttributes()); + self::assertSame('A1', $cell->getFormulaAttributes()['ref']); + + $spreadsheet->disconnectWorksheets(); + } + + public function testSetArrayFormulaExplicitWithRange(): void + { + $formula = '=SEQUENCE(3,3,-10,2.5)'; + + $spreadsheet = new Spreadsheet(); + $cell = $spreadsheet->getActiveSheet()->getCell('A1'); + $cell->setValueExplicit($formula, DataType::TYPE_FORMULA, true, 'A1:C3'); + + self::assertSame($formula, $cell->getValue()); + self::assertTrue($cell->isFormula()); + self::assertTrue($cell->isArrayFormula()); + self::assertArrayHasKey('ref', $cell->getFormulaAttributes()); + self::assertSame('A1:C3', $cell->getFormulaAttributes()['ref']); + + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Cell/CellTest.php b/tests/PhpSpreadsheetTests/Cell/CellTest.php index 2ffe0e2922..ab5da08f4e 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellTest.php @@ -25,7 +25,7 @@ public function testSetValueExplicit($expected, $value, string $dataType): void $cell = $spreadsheet->getActiveSheet()->getCell('A1'); $cell->setValueExplicit($value, $dataType); - self::assertSame($expected, $cell->getValue()); + self::assertEqualsWithDelta($expected, $cell->getValue(), 1.0e-12); $spreadsheet->disconnectWorksheets(); } diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index bb5535776f..e36a9f2864 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -33,8 +33,8 @@ public function providerGenerateFunctionListByName(): array [ [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'], - 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']], - 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']], + 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical\Operations::class, 'and']], + 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'dummy']], ], <<<'EXPECTED' # Function list by name @@ -44,7 +44,7 @@ public function providerGenerateFunctionListByName(): array Excel Function | Category | PhpSpreadsheet Function -------------------------|--------------------------------|-------------------------------------- ABS | CATEGORY_MATH_AND_TRIG | abs -AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd +AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::and ## I @@ -64,8 +64,8 @@ public function providerGenerateFunctionListByCategory(): array [ [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'], - 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']], - 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']], + 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical\Operations::class, 'and']], + 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'dummy']], ], <<<'EXPECTED' # Function list by category @@ -104,7 +104,7 @@ public function providerGenerateFunctionListByCategory(): array Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- -AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd +AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::and IFS | **Not yet Implemented** ## CATEGORY_LOOKUP_AND_REFERENCE diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php index a9a26a5ee8..a96dfd1839 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php @@ -11,11 +11,9 @@ class ReadFilterFilter implements IReadFilter * @param int $row Row number * @param string $worksheetName Optional worksheet name * - * @return bool - * * @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell() */ - public function readCell($column, $row, $worksheetName = '') + public function readCell($column, $row, $worksheetName = ''): bool { // define filter range $rowMin = 2; diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php index 31e60bdd40..11d26b6a0a 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php @@ -52,9 +52,9 @@ public function filter0(int $row): bool return false; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { - if ($this->filterType == 1) { + if ($this->filterType === 1) { return $this->filter1($row); } diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php new file mode 100644 index 0000000000..60a0496b70 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/ArrayFormulaTest.php @@ -0,0 +1,87 @@ +spreadsheet = $reader->load($filename); + } + + /** + * @dataProvider arrayFormulaReaderProvider + */ + public function testArrayFormulaReader( + string $cellAddress, + string $expectedRange, + string $expectedFormula, + array $expectedValue + ): void { + $worksheet = $this->spreadsheet->getActiveSheet(); + + $cell = $worksheet->getCell($cellAddress); + self::assertTrue($cell->isArrayFormula()); + self::assertSame($expectedRange, $cell->arrayFormulaRange()); + self::assertSame($expectedFormula, strtoupper($cell->getValue())); + self::assertSame($expectedValue, $cell->getCalculatedValue(true, true)); +// self::assertSame(8, $cell->getCalculatedValue()); +// self::assertSame(8, $cell->getCalculatedValue()); +// self::assertSame(12, $worksheet->getCell('C2')->getCalculatedValue()); +// self::assertSame(10, $worksheet->getCell('B3')->getCalculatedValue()); +// self::assertSame(15, $worksheet->getCell('C3')->getCalculatedValue()); + } + + public function arrayFormulaReaderProvider(): array + { + return [ + [ + 'D1', + 'D1:E2', + '=A1:B1*A1:A2', + [[4, 6], [8, 12]], + ], + [ + 'G1', + 'G1:J1', + '=SIN({-1,0,1,2})', + [[-0.8414709848078965, 0.0, 0.8414709848078965, 0.9092974268256817]], + ], + [ + 'D4', + 'D4:E5', + '=A4:B4*A4:A5', + [[9, 12], [15, 20]], + ], + [ + 'D7', + 'D7:E8', + '=A7:B7*A7:A8', + [[16, 20], [24, 30]], + ], + [ + 'D10', + 'D10:E11', + '=A10:B10*A10:A11', + [[25, 30], [35, 42]], + ], + [ + 'D13', + 'D13:E14', + '=A13:B13*A13:A14', + [[36, 42], [48, 56]], + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php index 8d8fd62b40..27e68f5f84 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php @@ -7,7 +7,7 @@ /** Define a Read Filter class implementing IReadFilter */ class GnumericFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return $row !== 4; } diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php new file mode 100644 index 0000000000..e38176405f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Ods/ArrayFormulaTest.php @@ -0,0 +1,90 @@ +spreadsheet = $reader->load($filename); + } + + /** + * @dataProvider arrayFormulaReaderProvider + * + * @param mixed $expectedValue + */ + public function testArrayFormulaReader( + string $cellAddress, + string $expectedRange, + string $expectedFormula, + $expectedValue + ): void { + $worksheet = $this->spreadsheet->getActiveSheet(); + + $cell = $worksheet->getCell($cellAddress); + self::assertTrue($cell->isArrayFormula()); + self::assertSame($expectedRange, $cell->arrayFormulaRange()); + self::assertSame($expectedFormula, strtoupper($cell->getValue())); + self::assertSame($expectedValue, $cell->getCalculatedValue(true, true)); + } + + public function arrayFormulaReaderProvider(): array + { + return [ + [ + 'B2', + 'B2:C3', + '={2,3}*{4;5}', + [[8, 12], [10, 15]], + ], + [ + 'E1', + 'E1:H1', + '=SIN({-1,0,1,2})', + [[-0.8414709848078965, 0.0, 0.8414709848078965, 0.9092974268256817]], + ], + [ + 'E3', + 'E3', + '=MAX(SIN({-1,0,1,2}))', + 0.9092974268256817, + ], + [ + 'D5', + 'D5:E6', + '=A5:B5*A5:A6', + [[4, 6], [8, 12]], + ], + [ + 'D8', + 'D8:E9', + '=A8:B8*A8:A9', + [[9, 12], [15, 20]], + ], + [ + 'D11', + 'D11:E12', + '=A11:B11*A11:A12', + [[16, 20], [24, 30]], + ], + [ + 'D14', + 'D14:E15', + '=A14:B14*A14:A15', + [[25, 30], [35, 42]], + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/ReaderFlagsTest.php b/tests/PhpSpreadsheetTests/Reader/ReaderFlagsTest.php new file mode 100644 index 0000000000..1a08d031c3 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/ReaderFlagsTest.php @@ -0,0 +1,106 @@ +reader = new Xlsx(); + } + + /** + * @dataProvider flagsProvider + */ + public function testFlags(int $flags, array $settings): void + { + $this->reader->setFlags($flags); + + self::assertSame($settings[self::EMPTY_CELLS], $this->reader->getReadEmptyCells()); + self::assertSame($settings[self::DATA_ONLY], $this->reader->getReadDataOnly()); + self::assertSame($settings[self::WITH_CHARTS], $this->reader->getIncludeCharts()); + } + + public function flagsProvider(): array + { + return [ + [ + 0, + [ + self::EMPTY_CELLS => true, + self::DATA_ONLY => false, + self::WITH_CHARTS => false, + ], + ], + [ + IReader::IGNORE_EMPTY_CELLS, + [ + self::EMPTY_CELLS => false, + self::DATA_ONLY => false, + self::WITH_CHARTS => false, + ], + ], + [ + IReader::READ_DATA_ONLY, + [ + self::EMPTY_CELLS => true, + self::DATA_ONLY => true, + self::WITH_CHARTS => false, + ], + ], + [ + IReader::IGNORE_EMPTY_CELLS | IReader::READ_DATA_ONLY, + [ + self::EMPTY_CELLS => false, + self::DATA_ONLY => true, + self::WITH_CHARTS => false, + ], + ], + [ + IReader::LOAD_WITH_CHARTS, + [ + self::EMPTY_CELLS => true, + self::DATA_ONLY => false, + self::WITH_CHARTS => true, + ], + ], + [ + IReader::IGNORE_EMPTY_CELLS | IReader::LOAD_WITH_CHARTS, + [ + self::EMPTY_CELLS => false, + self::DATA_ONLY => false, + self::WITH_CHARTS => true, + ], + ], + [ + IReader::READ_DATA_ONLY | IReader::LOAD_WITH_CHARTS, + [ + self::EMPTY_CELLS => true, + self::DATA_ONLY => true, + self::WITH_CHARTS => true, + ], + ], + [ + IReader::IGNORE_EMPTY_CELLS | IReader::READ_DATA_ONLY | IReader::LOAD_WITH_CHARTS, + [ + self::EMPTY_CELLS => false, + self::DATA_ONLY => true, + self::WITH_CHARTS => true, + ], + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Xls/DateReaderTest.php b/tests/PhpSpreadsheetTests/Reader/Xls/DateReaderTest.php new file mode 100644 index 0000000000..5ba83166bc --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xls/DateReaderTest.php @@ -0,0 +1,117 @@ +load($filename); + + self::assertSame(Date::CALENDAR_WINDOWS_1900, $spreadsheet->getExcelCalendar()); + + $worksheet = $spreadsheet->getActiveSheet(); + self::assertSame(44562, $worksheet->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet->getCell('A1')->getFormattedValue()); + self::assertSame(44926, $worksheet->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet->getCell('A2')->getFormattedValue()); + } + + public function testReadExcel1904Spreadsheet(): void + { + $filename = 'tests/data/Reader/XLS/1904_Calendar.xls'; + $reader = new Xls(); + $spreadsheet = $reader->load($filename); + + self::assertSame(Date::CALENDAR_MAC_1904, $spreadsheet->getExcelCalendar()); + + $worksheet = $spreadsheet->getActiveSheet(); + self::assertSame(43100, $worksheet->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet->getCell('A1')->getFormattedValue()); + self::assertSame(43464, $worksheet->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet->getCell('A2')->getFormattedValue()); + } + + public function testNewDateInLoadedExcel1900Spreadsheet(): void + { + $filename = 'tests/data/Reader/XLS/1900_Calendar.xls'; + $reader = new Xls(); + $spreadsheet = $reader->load($filename); + + $worksheet = $spreadsheet->getActiveSheet(); + $worksheet->getCell('A4')->setValue('=DATE(2023,1,1)'); + self::assertEquals(44927, $worksheet->getCell('A4')->getCalculatedValue()); + } + + public function testNewDateInLoadedExcel1904Spreadsheet(): void + { + $filename = 'tests/data/Reader/XLS/1904_Calendar.xls'; + $reader = new Xls(); + $spreadsheet = $reader->load($filename); + + $worksheet = $spreadsheet->getActiveSheet(); + $worksheet->getCell('A4')->setValue('=DATE(2023,1,1)'); + self::assertEquals(43465, $worksheet->getCell('A4')->getCalculatedValue()); + } + + public function testSwitchCalendars(): void + { + $filename1900 = 'tests/data/Reader/XLS/1900_Calendar.xls'; + $reader1900 = new Xls(); + $spreadsheet1900 = $reader1900->load($filename1900); + $worksheet1900 = $spreadsheet1900->getActiveSheet(); + + $filename1904 = 'tests/data/Reader/XLS/1904_Calendar.xls'; + $reader1904 = new Xls(); + $spreadsheet1904 = $reader1904->load($filename1904); + $worksheet1904 = $spreadsheet1904->getActiveSheet(); + + self::assertSame(44562, $worksheet1900->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1900->getCell('A1')->getFormattedValue()); + self::assertSame(44926, $worksheet1900->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1900->getCell('A2')->getFormattedValue()); + self::assertSame(44561, $worksheet1900->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1900->getCell('B1')->getFormattedValue()); + self::assertSame(44927, $worksheet1900->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1900->getCell('B2')->getFormattedValue()); + + self::assertSame(43100, $worksheet1904->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1904->getCell('A1')->getFormattedValue()); + self::assertSame(43464, $worksheet1904->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1904->getCell('A2')->getFormattedValue()); + self::assertSame(43099, $worksheet1904->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1904->getCell('B1')->getFormattedValue()); + self::assertSame(43465, $worksheet1904->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1904->getCell('B2')->getFormattedValue()); + + // Check that accessing date values from one spreadsheet doesn't break accessing correct values from another + self::assertSame(44561, $worksheet1900->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1900->getCell('B1')->getFormattedValue()); + self::assertSame(44927, $worksheet1900->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1900->getCell('B2')->getFormattedValue()); + self::assertSame(44562, $worksheet1900->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1900->getCell('A1')->getFormattedValue()); + self::assertSame(44926, $worksheet1900->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1900->getCell('A2')->getFormattedValue()); + + self::assertSame(43099, $worksheet1904->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1904->getCell('B1')->getFormattedValue()); + self::assertSame(43465, $worksheet1904->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1904->getCell('B2')->getFormattedValue()); + self::assertSame(43100, $worksheet1904->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1904->getCell('A1')->getFormattedValue()); + self::assertSame(43464, $worksheet1904->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1904->getCell('A2')->getFormattedValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/DateReaderTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/DateReaderTest.php new file mode 100644 index 0000000000..042683f9c3 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/DateReaderTest.php @@ -0,0 +1,125 @@ +load($filename); + + self::assertSame(Date::CALENDAR_WINDOWS_1900, $spreadsheet->getExcelCalendar()); + + $worksheet = $spreadsheet->getActiveSheet(); + self::assertSame(44562, $worksheet->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet->getCell('A1')->getFormattedValue()); + self::assertSame(44926, $worksheet->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet->getCell('A2')->getFormattedValue()); + self::assertSame(44561, $worksheet->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet->getCell('B1')->getFormattedValue()); + self::assertSame(44927, $worksheet->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet->getCell('B2')->getFormattedValue()); + } + + public function testReadExcel1904Spreadsheet(): void + { + $filename = 'tests/data/Reader/XLSX/1904_Calendar.xlsx'; + $reader = new Xlsx(); + $spreadsheet = $reader->load($filename); + + self::assertSame(Date::CALENDAR_MAC_1904, $spreadsheet->getExcelCalendar()); + + $worksheet = $spreadsheet->getActiveSheet(); + self::assertSame(43100, $worksheet->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet->getCell('A1')->getFormattedValue()); + self::assertSame(43464, $worksheet->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet->getCell('A2')->getFormattedValue()); + self::assertSame(43099, $worksheet->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet->getCell('B1')->getFormattedValue()); + self::assertSame(43465, $worksheet->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet->getCell('B2')->getFormattedValue()); + } + + public function testNewDateInLoadedExcel1900Spreadsheet(): void + { + $filename = 'tests/data/Reader/XLSX/1900_Calendar.xlsx'; + $reader = new Xlsx(); + $spreadsheet = $reader->load($filename); + + $worksheet = $spreadsheet->getActiveSheet(); + $worksheet->getCell('A4')->setValue('=DATE(2023,1,1)'); + self::assertEquals(44927, $worksheet->getCell('A4')->getCalculatedValue()); + } + + public function testNewDateInLoadedExcel1904Spreadsheet(): void + { + $filename = 'tests/data/Reader/XLSX/1904_Calendar.xlsx'; + $reader = new Xlsx(); + $spreadsheet = $reader->load($filename); + + $worksheet = $spreadsheet->getActiveSheet(); + $worksheet->getCell('A4')->setValue('=DATE(2023,1,1)'); + self::assertEquals(43465, $worksheet->getCell('A4')->getCalculatedValue()); + } + + public function testSwitchCalendars(): void + { + $filename1900 = 'tests/data/Reader/XLSX/1900_Calendar.xlsx'; + $reader1900 = new Xlsx(); + $spreadsheet1900 = $reader1900->load($filename1900); + $worksheet1900 = $spreadsheet1900->getActiveSheet(); + + $filename1904 = 'tests/data/Reader/XLSX/1904_Calendar.xlsx'; + $reader1904 = new Xlsx(); + $spreadsheet1904 = $reader1904->load($filename1904); + $worksheet1904 = $spreadsheet1904->getActiveSheet(); + + self::assertSame(44562, $worksheet1900->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1900->getCell('A1')->getFormattedValue()); + self::assertSame(44926, $worksheet1900->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1900->getCell('A2')->getFormattedValue()); + self::assertSame(44561, $worksheet1900->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1900->getCell('B1')->getFormattedValue()); + self::assertSame(44927, $worksheet1900->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1900->getCell('B2')->getFormattedValue()); + + self::assertSame(43100, $worksheet1904->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1904->getCell('A1')->getFormattedValue()); + self::assertSame(43464, $worksheet1904->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1904->getCell('A2')->getFormattedValue()); + self::assertSame(43099, $worksheet1904->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1904->getCell('B1')->getFormattedValue()); + self::assertSame(43465, $worksheet1904->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1904->getCell('B2')->getFormattedValue()); + + // Check that accessing date values from one spreadsheet doesn't break accessing correct values from another + self::assertSame(44561, $worksheet1900->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1900->getCell('B1')->getFormattedValue()); + self::assertSame(44927, $worksheet1900->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1900->getCell('B2')->getFormattedValue()); + self::assertSame(44562, $worksheet1900->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1900->getCell('A1')->getFormattedValue()); + self::assertSame(44926, $worksheet1900->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1900->getCell('A2')->getFormattedValue()); + + self::assertSame(43099, $worksheet1904->getCell('B1')->getCalculatedValue()); + self::assertSame('2021-12-31', $worksheet1904->getCell('B1')->getFormattedValue()); + self::assertSame(43465, $worksheet1904->getCell('B2')->getCalculatedValue()); + self::assertSame('2023-01-01', $worksheet1904->getCell('B2')->getFormattedValue()); + self::assertSame(43100, $worksheet1904->getCell('A1')->getValue()); + self::assertSame('2022-01-01', $worksheet1904->getCell('A1')->getFormattedValue()); + self::assertSame(43464, $worksheet1904->getCell('A2')->getValue()); + self::assertSame('2022-12-31', $worksheet1904->getCell('A2')->getFormattedValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php index 859e5b56b3..5814f21f79 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php @@ -9,7 +9,7 @@ */ class OddColumnReadFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return (\ord(\substr($columnAddress, -1, 1)) % 2) === 1; } diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxTest.php index 6b0ebf67d8..ed64599155 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxTest.php @@ -220,10 +220,10 @@ public function testLoadWithReadFilter(): void $reader = new Xlsx(); $reader->setReadFilter(new OddColumnReadFilter()); $data = $reader->load($filename)->getActiveSheet()->toArray(); - $ref = [1.0, null, 3.0, null, 5.0, null, 7.0, null, 9.0, null]; + $ref = [1, null, 3, null, 5, null, 7, null, 9]; for ($i = 0; $i < 10; ++$i) { - self::assertEquals($ref, \array_slice($data[$i], 0, 10, true)); + self::assertEquals($ref, \array_slice($data[$i], 0, 9, true)); } } diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php index b53fffd590..864549cc97 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php @@ -7,7 +7,7 @@ /** Define a Read Filter class implementing IReadFilter */ class XmlFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return $row !== 4; } diff --git a/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php b/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php index 30da1d759b..404ed99d2e 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php @@ -4,6 +4,7 @@ use Exception; use PhpOffice\PhpSpreadsheet\Cell\DataType; +use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\CellIterator; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; @@ -129,6 +130,26 @@ public function testSetCodeNameDuplicate(): void self::assertSame('Test Code Name', $sheet->getCodeName()); } + public function testFromAndToArray(): void + { + $testData = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + + $workbook = new Spreadsheet(); + $worksheet = $workbook->getActiveSheet(); + $currentCell = 'B2'; + $cell = $worksheet->getCell($currentCell); + + $worksheet->fromArray($testData); + self::assertSame($currentCell, $cell->getCoordinate(), 'Cell retained after fromArray()'); + + self::assertSame($testData, $worksheet->toArray()); + self::assertSame($currentCell, $cell->getCoordinate(), 'Cell retained after toArray()'); + + $workbook->addNamedRange(new NamedRange('NAMED_RANGE', $worksheet, 'A1:C3')); + self::assertSame($testData, $worksheet->namedRangeToArray('NAMED_RANGE')); + self::assertSame($currentCell, $cell->getCoordinate(), 'Cell retained after namedRangeToArray()'); + } + public function testFreezePaneSelectedCell(): void { $worksheet = new Worksheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ArrayFormulaTest.php new file mode 100644 index 0000000000..1314c1445f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ArrayFormulaTest.php @@ -0,0 +1,23 @@ +getActiveSheet(); + $worksheet->setCellValue('B2', '={2,3}*{4;5}', true, $arrayFormulaRange); + + $reloaded = $this->writeAndReload($spreadsheet, 'Ods'); + + $cell = $reloaded->getActiveSheet()->getCell('B2'); + self::assertTrue($cell->isArrayFormula()); + self::assertSame($arrayFormulaRange, $cell->arrayFormulaRange()); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaTest.php new file mode 100644 index 0000000000..ca5512d622 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaTest.php @@ -0,0 +1,35 @@ +load('tests/data/Writer/XLSX/ArrayFormula.xlsx'); + + $cellFormulaAttributes = $spreadsheet->getActiveSheet()->getCell('A1')->getFormulaAttributes(); + + self::assertArrayHasKey('t', $cellFormulaAttributes); + self::assertSame('array', $cellFormulaAttributes['t']); + self::assertArrayHasKey('ref', $cellFormulaAttributes); + + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); + $spreadsheet->disconnectWorksheets(); + + $reloadedCellFormulaAttributes = $reloadedSpreadsheet->getActiveSheet()->getCell('A1')->getFormulaAttributes(); + + self::assertArrayHasKey('t', $reloadedCellFormulaAttributes); + self::assertArrayHasKey('ref', $reloadedCellFormulaAttributes); + + self::assertSame($cellFormulaAttributes['t'], $reloadedCellFormulaAttributes['t']); + self::assertSame($cellFormulaAttributes['ref'], $reloadedCellFormulaAttributes['ref']); + + $reloadedSpreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/data/Calculation/MathTrig/MMULT.php b/tests/data/Calculation/MathTrig/MMULT.php index 7b424d589f..3bb60a2449 100644 --- a/tests/data/Calculation/MathTrig/MMULT.php +++ b/tests/data/Calculation/MathTrig/MMULT.php @@ -90,6 +90,11 @@ [6], ], ], + [ + [[-14, 20], [-30, 44]], + [[1, 2], [3, 4]], + [[-2, 4], [-6, 8]], + ], [ '#VALUE!', // null in first array [ diff --git a/tests/data/Calculation/MatrixResize.php b/tests/data/Calculation/MatrixResize.php new file mode 100644 index 0000000000..18bbf0db3a --- /dev/null +++ b/tests/data/Calculation/MatrixResize.php @@ -0,0 +1,67 @@ +