Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed inconsistent string handling in SUM() implementations, issue #3652 #3653

Merged
merged 7 commits into from
Aug 15, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/PhpSpreadsheet/Calculation/MathTrig/Sum.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Sum
*
* @param mixed ...$args Data values
*
* @return float|string
* @return float|integer|string
oleibman marked this conversation as resolved.
Show resolved Hide resolved
*/
public static function sumIgnoringStrings(...$args)
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public static function sumIgnoringStrings(...$args)
*
* @param mixed ...$args Data values
*
* @return float|string
* @return float|integer|string
oleibman marked this conversation as resolved.
Show resolved Hide resolved
*/
public static function sumErroringStrings(...$args)
{
Expand All @@ -56,10 +56,7 @@ public static function sumErroringStrings(...$args)
$aArgs = Functions::flattenArrayIndexed($args);
foreach ($aArgs as $k => $arg) {
// Is it a numeric value?
if (is_numeric($arg) || empty($arg)) {
if (is_string($arg)) {
$arg = (int) $arg;
}
if (is_numeric($arg)) {
$returnValue += $arg;
} elseif (is_bool($arg)) {
$returnValue += (int) $arg;
Expand Down