Fix MATCH an error was appearing when comparing strings against 0 (always true) + making a return statement a bit more explicit (#855)

This commit is contained in:
Fräntz Miccoli 2019-03-06 22:37:06 +01:00 committed by Mark Baker
parent 432e5845e1
commit 8b589c4ef3
3 changed files with 19 additions and 2 deletions

View File

@ -12,7 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Added support for inline styles in Html reader (borders, alignment, width, height)
- QuotedText cells no longer treated as formulae if the content begins with a `=`
- Clean handling for DDE in formulae
### Fixed
- Fix handling for escaped enclosures and new lines in CSV Separator Inference
- Fix MATCH an error was appearing when comparing strings against 0 (always true)
## [1.6.0] - 2019-01-02

View File

@ -522,9 +522,13 @@ class LookupRef
if ($matchType == 0 || $matchType == 1) {
foreach ($lookupArray as $i => $lookupArrayValue) {
if (($matchType == 0) && ($lookupArrayValue == $lookupValue)) {
$onlyNumeric = is_numeric($lookupArrayValue) && is_numeric($lookupValue);
$onlyNumericExactMatch = $onlyNumeric && $lookupArrayValue == $lookupValue;
$nonOnlyNumericExactMatch = !$onlyNumeric && $lookupArrayValue === $lookupValue;
$exactMatch = $onlyNumericExactMatch || $nonOnlyNumericExactMatch;
if (($matchType == 0) && $exactMatch) {
// exact match
return ++$i;
return $i + 1;
} elseif (($matchType == 1) && ($lookupArrayValue <= $lookupValue)) {
$i = array_search($i, $keySet);

View File

@ -96,4 +96,13 @@ return [
[8, 8, 3, 2],
-1,
],
// 0s are causing errors, because things like 0 == 'x' is true. Thanks PHP!
[
3,
'x',
[[0], [0], ['x'], ['x'], ['x']],
0
],
];