Author: Elliot Levin (elliotlevin@hotmail.com)
Inheritance: extends Expression
 protected function visitFunctionCall(O\FunctionCallExpression $expression)
 {
     $functionName = $expression->getName()->getValue();
     if (!isset($this->functions[$functionName])) {
         throw new PinqDemoSqlException("Function not supported: {$functionName}");
     }
     $arguments = [];
     foreach ($expression->getArguments() as $argument) {
         $arguments[] = $this->compileInContext($argument);
     }
     $this->sql .= $this->functions[$functionName] . '(' . implode(', ', $arguments) . ')';
 }
Beispiel #2
0
 public function visitFunctionCall(O\FunctionCallExpression $expression)
 {
     $nameExpression = $expression->getName();
     $this->walk($nameExpression);
     $this->walkAll($expression->getArguments());
     if ($nameExpression instanceof O\ValueExpression) {
         $function = $this->typeSystem->getFunction($nameExpression->getValue());
         $this->metadata[$expression] = $function;
         $this->analysis[$expression] = $function->getReturnType();
     } else {
         throw new TypeException('Invalid function expression: dynamic function calls are not allowed');
     }
 }
 protected final function visitCount(O\Expression $expression)
 {
     $this->interpretation->interpretCount($this->getId('count'));
     if ($expression instanceof O\MethodCallExpression) {
         $this->interpretSourceAsScope($expression);
     } elseif ($expression instanceof O\FunctionCallExpression && count($expression->getArguments()) > 0) {
         $this->scopeInterpreter->interpretScope($expression->getArguments()[0]->getValue());
     } else {
         throw new PinqException('Cannot interpret count request: invalid expression type, expecting %s, %s given', O\MethodCallExpression::getType() . ' or ' . O\FunctionCallExpression::getType() . ' with at least one argument', $expression->getType());
     }
 }