BetterReflection\NodeCompiler\CompileNodeToValue::compileBinaryOperator PHP Метод

compileBinaryOperator() приватный Метод

Compile a binary operator node
private compileBinaryOperator ( PhpParser\Node\Expr\BinaryOp $node, BetterReflection\NodeCompiler\CompilerContext $context ) : mixed
$node PhpParser\Node\Expr\BinaryOp
$context BetterReflection\NodeCompiler\CompilerContext
Результат mixed
    private function compileBinaryOperator(Node\Expr\BinaryOp $node, CompilerContext $context)
    {
        if ($node instanceof Node\Expr\BinaryOp\Plus) {
            return $this($node->left, $context) + $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Mul) {
            return $this($node->left, $context) * $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Minus) {
            return $this($node->left, $context) - $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Div) {
            return $this($node->left, $context) / $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Concat) {
            return $this($node->left, $context) . $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\BooleanAnd) {
            return $this($node->left, $context) && $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\BooleanOr) {
            return $this($node->left, $context) || $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\BitwiseAnd) {
            return $this($node->left, $context) & $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\BitwiseOr) {
            return $this($node->left, $context) | $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\BitwiseXor) {
            return $this($node->left, $context) ^ $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Equal) {
            return $this($node->left, $context) == $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Greater) {
            return $this($node->left, $context) > $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\GreaterOrEqual) {
            return $this($node->left, $context) >= $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Identical) {
            return $this($node->left, $context) === $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\LogicalAnd) {
            return $this($node->left, $context) and $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\LogicalOr) {
            return $this($node->left, $context) or $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\LogicalXor) {
            return $this($node->left, $context) xor $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Mod) {
            return $this($node->left, $context) % $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\NotEqual) {
            return $this($node->left, $context) != $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\NotIdentical) {
            return $this($node->left, $context) !== $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Pow) {
            return $this($node->left, $context) ** $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\ShiftLeft) {
            return $this($node->left, $context) << $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\ShiftRight) {
            return $this($node->left, $context) >> $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\Smaller) {
            return $this($node->left, $context) < $this($node->right, $context);
        }
        if ($node instanceof Node\Expr\BinaryOp\SmallerOrEqual) {
            return $this($node->left, $context) <= $this($node->right, $context);
        }
        throw new Exception\UnableToCompileNode('Unable to compile binary operator: ' . get_class($node));
    }