You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Numeric string handling in Sum::sumErroringStrings() and Sum::sumIgnoringStrings() should be consistent.
What is the current behaviour?
sumErroringStrings casts all string params to integers whereas sumIgnoringStrings just sums them. The expected behaviour would be for both functions to cast string inputs to floats.
<?phprequire__DIR__ . '/vendor/autoload.php';
usePhpOffice\PhpSpreadsheet\Calculation\MathTrig\Sum;
// This outputs int(4)var_dump(Sum::sumErroringStrings("1.2", "3.4"));
// This outputs float(4.6)var_dump(Sum::sumIgnoringStrings("1.2", "3.4"));
What features do you think are causing the issue
Reader
Writer
Styles
Data Validations
Formula Calculations
Charts
AutoFilter
Form Elements
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Yes, affects all formats
Which versions of PhpSpreadsheet and PHP are affected?
All PHP versions and 1.28 of phpspreadsheet
The text was updated successfully, but these errors were encountered:
betterphp
changed the title
Inconsistent string handling between Sum::sumErroringStrings() anbd
Inconsistent string handling between Sum::sumErroringStrings() and Sum::sumIgnoringStrings()
Jul 27, 2023
(#3653)
* Fixed inconsistent string handling in SUM() implementations
* Use assertEqual instead of assertSame to allow ints and floats with the
same value
* Removewd special handling of empty strings and use default casts
* Eliminate Phpstan errors
* More Test Cases
* More New Tests
---------
Co-authored-by: oleibman <[email protected]>
This is:
What is the expected behaviour?
Numeric string handling in
Sum::sumErroringStrings()
andSum::sumIgnoringStrings()
should be consistent.What is the current behaviour?
sumErroringStrings
casts all string params to integers whereassumIgnoringStrings
just sums them. The expected behaviour would be for both functions to cast string inputs to floats.What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Yes, affects all formats
Which versions of PhpSpreadsheet and PHP are affected?
All PHP versions and 1.28 of phpspreadsheet
The text was updated successfully, but these errors were encountered: