Skip to content

Commit 83977c9

Browse files
committed
Fix emptiness checks in PHP 8
1 parent 189072b commit 83977c9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Processor/Expression/BinaryOperatorEvaluator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public static function evaluate(
145145
return \strtolower((string) $l_value) === \strtolower((string) $r_value) ? 1 : 0 ^ $expr->negatedInt;
146146
}
147147

148+
if (empty($l_value) && empty($r_value)) {
149+
return !$expr->negatedInt;
150+
}
151+
148152
return $l_value == $r_value ? 1 : 0 ^ $expr->negatedInt;
149153

150154
case '<>':
@@ -153,7 +157,11 @@ public static function evaluate(
153157
return \strtolower((string) $l_value) !== \strtolower((string) $r_value) ? 1 : 0 ^ $expr->negatedInt;
154158
}
155159

156-
return (float) $l_value != (float) $r_value ? 1 : 0 ^ $expr->negatedInt;
160+
if (empty($l_value) && empty($r_value)) {
161+
return $expr->negatedInt;
162+
}
163+
164+
return $l_value != $r_value ? 1 : 0 ^ $expr->negatedInt;
157165

158166
case '>':
159167
if ($as_string) {

0 commit comments

Comments
 (0)