Skip to content

Commit c03cbe3

Browse files
[ExpressionLanguage] Improve tests on BinaryNode
1 parent 590f629 commit c03cbe3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ public function evaluate(array $functions, array $values): mixed
152152
return $left >= $right;
153153
case '<=':
154154
return $left <= $right;
155-
case 'not in':
156-
return !\in_array($left, $right, true);
157-
case 'in':
158-
return \in_array($left, $right, true);
159155
case '+':
160156
return $left + $right;
161157
case '-':
@@ -179,6 +175,8 @@ public function evaluate(array $functions, array $values): mixed
179175
case 'matches':
180176
return $this->evaluateMatches($right, $left);
181177
}
178+
179+
throw new \LogicException(\sprintf('"%s" does not support the "%s" operator.', __CLASS__, $operator));
182180
}
183181

184182
public function toArray(): array

src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,14 @@ public function testInOperatorStrictness(mixed $value)
258258

259259
$this->assertFalse($node->evaluate([], []));
260260
}
261+
262+
public function testEvaluateUnsupportedOperator()
263+
{
264+
$node = new BinaryNode('unsupported', new ConstantNode(1), new ConstantNode(2));
265+
266+
$this->expectException(\LogicException::class);
267+
$this->expectExceptionMessage('"Symfony\Component\ExpressionLanguage\Node\BinaryNode" does not support the "unsupported" operator.');
268+
269+
$node->evaluate([], []);
270+
}
261271
}

0 commit comments

Comments
 (0)