PHPSA\Compiler\Expression\Operators\UnaryMinus::compile PHP Method

compile() protected method

-{expr}
protected compile ( PhpParser\Node\Expr\UnaryMinus $expr, Context $context ) : CompiledExpression
$expr PhpParser\Node\Expr\UnaryMinus
$context PHPSA\Context
return PHPSA\CompiledExpression
    protected function compile($expr, Context $context)
    {
        $left = $context->getExpressionCompiler()->compile($expr->expr);
        switch ($left->getType()) {
            case CompiledExpression::INTEGER:
            case CompiledExpression::DOUBLE:
            case CompiledExpression::NUMBER:
            case CompiledExpression::BOOLEAN:
            case CompiledExpression::STRING:
            case CompiledExpression::NULL:
                return CompiledExpression::fromZvalValue(-(int) $left->getValue());
        }
        return new CompiledExpression();
    }
UnaryMinus