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

compile() protected method

protected compile ( PhpParser\Node\Expr\New_ $expr, Context $context ) : CompiledExpression
$expr PhpParser\Node\Expr\New_
$context PHPSA\Context
return PHPSA\CompiledExpression
    protected function compile($expr, Context $context)
    {
        if ($expr->class instanceof Node\Name) {
            $name = $expr->class->parts[0];
            $arguments = [];
            if (count($expr->args) > 0) {
                foreach ($expr->args as $argument) {
                    $arguments[] = $context->getExpressionCompiler()->compile($argument->value);
                }
            } else {
                if (class_exists($name, true)) {
                    return new CompiledExpression(CompiledExpression::OBJECT, new $name());
                }
            }
            return new CompiledExpression(CompiledExpression::OBJECT);
        }
        $context->debug('Unknown how to pass new', $expr);
        return new CompiledExpression();
    }
NewOp