public function __invoke(Node $node, CompilerContext $context)
{
if ($node instanceof Node\Scalar\String_ || $node instanceof Node\Scalar\DNumber || $node instanceof Node\Scalar\LNumber) {
return $node->value;
}
// common edge case - negative numbers
if ($node instanceof Node\Expr\UnaryMinus) {
return $this($node->expr, $context) * -1;
}
if ($node instanceof Node\Expr\Array_) {
return $this->compileArray($node, $context);
}
if ($node instanceof Node\Expr\ConstFetch) {
return $this->compileConstFetch($node);
}
if ($node instanceof Node\Expr\ClassConstFetch) {
return $this->compileClassConstFetch($node, $context);
}
if ($node instanceof Node\Expr\BinaryOp) {
return $this->compileBinaryOperator($node, $context);
}
throw new Exception\UnableToCompileNode('Unable to compile expression: ' . get_class($node));
}