mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-15 04:26:25 +00:00
POWER Needs to Accept NULL Args
Investigating issue #1622, I found that its extremely complicated formula, which had been leading to an incorrect result, now led to an exception. I am able to fix the exception; unfortunately, I am no closer to resolving the original issue. So I'll apply the baby step while continuing to investigate. Function POWER had changed from untyped args to a defined set of types. The set of types was determined according to the doc block, but that was incomplete - it had neglected to include `null` and `bool`. This PR corrects the function prototype and the doc block, and adds the missing tests for those conditions.
This commit is contained in:
@@ -52,14 +52,14 @@ class Operations
|
||||
*
|
||||
* Computes x raised to the power y.
|
||||
*
|
||||
* @param array|float|int|string $x Or can be an array of values
|
||||
* @param array|float|int|string $y Or can be an array of values
|
||||
* @param null|array|bool|float|int|string $x Or can be an array of values
|
||||
* @param null|array|bool|float|int|string $y Or can be an array of values
|
||||
*
|
||||
* @return array|float|int|string The result, or a string containing an error
|
||||
* 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 power(array|float|int|string $x, array|float|int|string $y): array|float|int|string
|
||||
public static function power(null|array|bool|float|int|string $x, null|array|bool|float|int|string $y): array|float|int|string
|
||||
{
|
||||
if (is_array($x) || is_array($y)) {
|
||||
return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $y);
|
||||
|
||||
@@ -410,4 +410,9 @@ return [
|
||||
],
|
||||
['#VALUE!', 'x', 2],
|
||||
['#VALUE!', 2, 'x'],
|
||||
'exponent is null' => [1, 2, null],
|
||||
'base is null' => [0, null, 2],
|
||||
'both null' => ['#NUM!', null, null],
|
||||
'exponent is bool' => [2, 2, true],
|
||||
'base is bool' => [0, false, 2],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user