|
33 | 33 | namespace SQLParser\Node; |
34 | 34 |
|
35 | 35 | use Mouf\Database\MagicQueryException; |
| 36 | +use Mouf\Database\MagicQueryParserException; |
36 | 37 | use SQLParser\SqlRenderInterface; |
37 | 38 | use Doctrine\DBAL\Connection; |
38 | 39 | use Mouf\MoufManager; |
@@ -620,16 +621,16 @@ public static function simplify($nodes) |
620 | 621 | */ |
621 | 622 |
|
622 | 623 | if (isset(self::$OPERATOR_TO_CLASS[$operation]) && is_subclass_of(self::$OPERATOR_TO_CLASS[$operation], 'SQLParser\Node\AbstractTwoOperandsOperator')) { |
623 | | - $leftOperand = array_shift($operands); |
624 | | - while (!empty($operands)) { |
625 | | - $rightOperand = array_shift($operands); |
626 | | - |
627 | | - $instance = new self::$OPERATOR_TO_CLASS[$operation](); |
628 | | - $instance->setLeftOperand($leftOperand); |
629 | | - $instance->setRightOperand($rightOperand); |
630 | | - $leftOperand = $instance; |
| 624 | + if (count($operands) !== 2) { |
| 625 | + throw new MagicQueryParserException("Expected exactly 2 operands on ".self::$OPERATOR_TO_CLASS[$operation].". Found ".count($operands)); |
631 | 626 | } |
632 | 627 |
|
| 628 | + $leftOperand = array_shift($operands); |
| 629 | + $rightOperand = array_shift($operands); |
| 630 | + $instance = new self::$OPERATOR_TO_CLASS[$operation](); |
| 631 | + $instance->setLeftOperand($leftOperand); |
| 632 | + $instance->setRightOperand($rightOperand); |
| 633 | + |
633 | 634 | return $instance; |
634 | 635 | } elseif (isset(self::$OPERATOR_TO_CLASS[$operation]) && is_subclass_of(self::$OPERATOR_TO_CLASS[$operation], 'SQLParser\Node\AbstractManyInstancesOperator')) { |
635 | 636 | $instance = new self::$OPERATOR_TO_CLASS[$operation](); |
|
0 commit comments