Skip to content

Commit 6ad3adf

Browse files
author
MarkBaker
committed
Resolve some phpstan issues
1 parent 097f5cc commit 6ad3adf

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/PhpSpreadsheet/Calculation/BinaryComparison.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,22 @@ class BinaryComparison
1616
*
1717
* @param null|string $str1 First string value for the comparison
1818
* @param null|string $str2 Second string value for the comparison
19-
*
20-
* @return int
2119
*/
22-
private static function strcmpLowercaseFirst($str1, $str2)
20+
private static function strcmpLowercaseFirst($str1, $str2): int
2321
{
24-
$inversedStr1 = StringHelper::strCaseReverse($str1);
25-
$inversedStr2 = StringHelper::strCaseReverse($str2);
22+
$inversedStr1 = StringHelper::strCaseReverse($str1 ?? '');
23+
$inversedStr2 = StringHelper::strCaseReverse($str2 ?? '');
2624

27-
return strcmp($inversedStr1 ?? '', $inversedStr2 ?? '');
25+
return strcmp($inversedStr1, $inversedStr2);
2826
}
2927

3028
/**
3129
* PHP8.1 deprecates passing null to strcmp.
3230
*
3331
* @param null|string $str1 First string value for the comparison
3432
* @param null|string $str2 Second string value for the comparison
35-
*
36-
* @return int
3733
*/
38-
private static function strcmpAllowNull($str1, $str2)
34+
private static function strcmpAllowNull($str1, $str2): int
3935
{
4036
return strcmp($str1 ?? '', $str2 ?? '');
4137
}
@@ -44,7 +40,7 @@ private static function strcmpAllowNull($str1, $str2)
4440
* @param mixed $operand1
4541
* @param mixed $operand2
4642
*/
47-
public static function compare($operand1, $operand2, string $operator)
43+
public static function compare($operand1, $operand2, string $operator): bool
4844
{
4945
// Simple validate the two operands if they are string values
5046
if (is_string($operand1) && $operand1 > '' && $operand1[0] == Calculation::FORMULA_STRING_QUOTE) {
@@ -81,18 +77,18 @@ private static function evaluateComparison($operand1, $operand2, string $operato
8177
// Equality
8278
case '=':
8379
return self::equal($operand1, $operand2);
84-
// Greater than or equal
85-
case '>=':
86-
return self::greaterThanOrEqual($operand1, $operand2, $useLowercaseFirstComparison);
87-
// Less than or equal
88-
case '<=':
89-
return self::lessThanOrEqual($operand1, $operand2, $useLowercaseFirstComparison);
9080
// Greater than
9181
case '>':
9282
return self::greaterThan($operand1, $operand2, $useLowercaseFirstComparison);
9383
// Less than
9484
case '<':
9585
return self::lessThan($operand1, $operand2, $useLowercaseFirstComparison);
86+
// Greater than or equal
87+
case '>=':
88+
return self::greaterThanOrEqual($operand1, $operand2, $useLowercaseFirstComparison);
89+
// Less than or equal
90+
case '<=':
91+
return self::lessThanOrEqual($operand1, $operand2, $useLowercaseFirstComparison);
9692
// Inequality
9793
case '<>':
9894
return self::notEqual($operand1, $operand2);

0 commit comments

Comments
 (0)