mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-04 22:50:27 +00:00
Resolve Phpstan Messages in Calculation Functions Internal and MathTrig (#3288)
Reduce number of Phpstan messages by addressing their issues.
This commit is contained in:
@@ -25,61 +25,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/FormulaParser.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:ifCondition\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:ifCondition\\(\\) has parameter \\$condition with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:isCellValue\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:isCellValue\\(\\) has parameter \\$idx with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:isMatrixValue\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:isMatrixValue\\(\\) has parameter \\$idx with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:isValue\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:isValue\\(\\) has parameter \\$idx with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:operandSpecialHandling\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Functions\\:\\:operandSpecialHandling\\(\\) has parameter \\$operand with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Functions.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Internal\\\\MakeMatrix\\:\\:make\\(\\) has parameter \\$args with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Internal/MakeMatrix.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\:\\:CHOOSE\\(\\) has parameter \\$chooseArgs with no type specified\\.$#"
|
||||
count: 1
|
||||
@@ -155,21 +100,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"/\" between array\\|float\\|int\\|string and array\\|float\\|int\\|string results in an error\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"/\" between array\\|float\\|int\\|string and float\\|int results in an error\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\IntClass\\:\\:evaluate\\(\\) should return array\\|string but returns int\\.$#"
|
||||
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
|
||||
|
||||
@@ -130,22 +130,26 @@ class Functions
|
||||
return '#Not Yet Implemented';
|
||||
}
|
||||
|
||||
public static function isMatrixValue($idx)
|
||||
/** @param mixed $idx */
|
||||
public static function isMatrixValue($idx): bool
|
||||
{
|
||||
return (substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0);
|
||||
}
|
||||
|
||||
public static function isValue($idx)
|
||||
/** @param mixed $idx */
|
||||
public static function isValue($idx): bool
|
||||
{
|
||||
return substr_count($idx, '.') === 0;
|
||||
}
|
||||
|
||||
public static function isCellValue($idx)
|
||||
/** @param mixed $idx */
|
||||
public static function isCellValue($idx): bool
|
||||
{
|
||||
return substr_count($idx, '.') > 1;
|
||||
}
|
||||
|
||||
public static function ifCondition($condition)
|
||||
/** @param mixed $condition */
|
||||
public static function ifCondition($condition): string
|
||||
{
|
||||
$condition = self::flattenSingleValue($condition);
|
||||
|
||||
@@ -180,6 +184,11 @@ class Functions
|
||||
return str_replace('""""', '""', $operator . $operand);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $operand
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function operandSpecialHandling($operand)
|
||||
{
|
||||
if (is_numeric($operand) || is_bool($operand)) {
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Internal;
|
||||
|
||||
class MakeMatrix
|
||||
{
|
||||
/** @param array $args */
|
||||
public static function make(...$args): array
|
||||
{
|
||||
return $args;
|
||||
|
||||
@@ -40,7 +40,7 @@ class Combinations
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return round(Factorial::fact($numObjs) / Factorial::fact($numObjs - $numInSet)) / Factorial::fact($numInSet);
|
||||
return round(Factorial::fact($numObjs) / Factorial::fact($numObjs - $numInSet)) / Factorial::fact($numInSet); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ class Combinations
|
||||
}
|
||||
|
||||
return round(
|
||||
Factorial::fact($numObjs + $numInSet - 1) / Factorial::fact($numObjs - 1)
|
||||
Factorial::fact($numObjs + $numInSet - 1) / Factorial::fact($numObjs - 1) // @phpstan-ignore-line
|
||||
) / Factorial::fact($numInSet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
|
||||
|
||||
class Factorial
|
||||
@@ -120,6 +121,6 @@ class Factorial
|
||||
|
||||
$summer = self::fact($summer);
|
||||
|
||||
return $summer / $divisor;
|
||||
return is_numeric($summer) ? ($summer / $divisor) : ExcelError::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class IntClass
|
||||
*
|
||||
* @param array|float $number Number to cast to an integer, or can be an array of numbers
|
||||
*
|
||||
* @return array|string Integer value, or a string containing an error
|
||||
* @return array|int|string Integer value, or a string containing an error
|
||||
* If an array of numbers is passed as the argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user