@@ -16,26 +16,22 @@ class BinaryComparison
16
16
*
17
17
* @param null|string $str1 First string value for the comparison
18
18
* @param null|string $str2 Second string value for the comparison
19
- *
20
- * @return int
21
19
*/
22
- private static function strcmpLowercaseFirst ($ str1 , $ str2 )
20
+ private static function strcmpLowercaseFirst ($ str1 , $ str2 ): int
23
21
{
24
- $ inversedStr1 = StringHelper::strCaseReverse ($ str1 );
25
- $ inversedStr2 = StringHelper::strCaseReverse ($ str2 );
22
+ $ inversedStr1 = StringHelper::strCaseReverse ($ str1 ?? '' );
23
+ $ inversedStr2 = StringHelper::strCaseReverse ($ str2 ?? '' );
26
24
27
- return strcmp ($ inversedStr1 ?? '' , $ inversedStr2 ?? '' );
25
+ return strcmp ($ inversedStr1 , $ inversedStr2 );
28
26
}
29
27
30
28
/**
31
29
* PHP8.1 deprecates passing null to strcmp.
32
30
*
33
31
* @param null|string $str1 First string value for the comparison
34
32
* @param null|string $str2 Second string value for the comparison
35
- *
36
- * @return int
37
33
*/
38
- private static function strcmpAllowNull ($ str1 , $ str2 )
34
+ private static function strcmpAllowNull ($ str1 , $ str2 ): int
39
35
{
40
36
return strcmp ($ str1 ?? '' , $ str2 ?? '' );
41
37
}
@@ -44,7 +40,7 @@ private static function strcmpAllowNull($str1, $str2)
44
40
* @param mixed $operand1
45
41
* @param mixed $operand2
46
42
*/
47
- public static function compare ($ operand1 , $ operand2 , string $ operator )
43
+ public static function compare ($ operand1 , $ operand2 , string $ operator ): bool
48
44
{
49
45
// Simple validate the two operands if they are string values
50
46
if (is_string ($ operand1 ) && $ operand1 > '' && $ operand1 [0 ] == Calculation::FORMULA_STRING_QUOTE ) {
@@ -81,18 +77,18 @@ private static function evaluateComparison($operand1, $operand2, string $operato
81
77
// Equality
82
78
case '= ' :
83
79
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 );
90
80
// Greater than
91
81
case '> ' :
92
82
return self ::greaterThan ($ operand1 , $ operand2 , $ useLowercaseFirstComparison );
93
83
// Less than
94
84
case '< ' :
95
85
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 );
96
92
// Inequality
97
93
case '<> ' :
98
94
return self ::notEqual ($ operand1 , $ operand2 );
0 commit comments