From ea4074d3ae191a4edc22e65d7a495cc533f5a18c Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Thu, 11 Jul 2024 10:04:35 +0200 Subject: [PATCH] Add support for UnaryMinus and UnaryPlus expressions --- src/Resolver/NodeExpressionResolver.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Resolver/NodeExpressionResolver.php b/src/Resolver/NodeExpressionResolver.php index 778d203..93df977 100644 --- a/src/Resolver/NodeExpressionResolver.php +++ b/src/Resolver/NodeExpressionResolver.php @@ -589,6 +589,16 @@ protected function resolveExprBinaryOpLogicalXor(Expr\BinaryOp\LogicalXor $node) return $this->resolve($node->left) xor $this->resolve($node->right); } + protected function resolveExprUnaryMinus(Expr\UnaryMinus $node): int|float + { + return -$this->resolve($node->expr); + } + + protected function resolveExprUnaryPlus(Expr\UnaryPlus $node): int|float + { + return $this->resolve($node->expr); + } + private function getDispatchMethodFor(Node $node): string { $nodeType = $node->getType();