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
- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
Unary operators on arrays used to allow coercible non-numeric array elements such as boolean. This is the case in the replaced Shared/JAMA code, mirroring behaviour in Excel.
What is the current behavior?
Any array elements which are non-numeric are replaced with a #VALUE error.
The simplified code which replaced JAMA in #3260 requires all array elements to be is_numeric. The old behaviour was similar to validateBinaryOperand() in that it assumed non-strings would coerce to numeric and only did further validation on strings.
FixPHPOffice#3389. It seems some functionality was left behind when JAMA was eliminated (PR PHPOffice#3260). In particular, it is apparently a known trick to use double negation on boolean values as arguments to functions like SUMPRODUCT.
* Coerce Bool to Int for Unary Operation on Arrays
Fix#3389. It seems some functionality was left behind when JAMA was eliminated (PR #3260). In particular, it is apparently a known trick to use double negation on boolean values as arguments to functions like SUMPRODUCT.
* Fix 3396
Treat booleans in arrays as int for mathematical operators as well.
* Edge Case
When array operand was neither numeric nor boolean, PhpSpreadsheet had always been evaluating the operand as #NUM!. It will now propagate an error string like #DIV/0!, and treat non-error strings as #VALUE!, consistent with Excel.
This is:
What is the expected behavior?
Unary operators on arrays used to allow coercible non-numeric array elements such as boolean. This is the case in the replaced Shared/JAMA code, mirroring behaviour in Excel.
What is the current behavior?
Any array elements which are non-numeric are replaced with a #VALUE error.
The simplified code which replaced JAMA in #3260 requires all array elements to be
is_numeric
. The old behaviour was similar to validateBinaryOperand() in that it assumed non-strings would coerce to numeric and only did further validation on strings.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:
Running this produces:
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
All formats.
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 1.26
PHP 8.1
UnaryOperatorIssue.xlsx
The text was updated successfully, but these errors were encountered: