Author: Elliot Levin (elliotlevin@hotmail.com)
Inheritance: extends Serializable
Beispiel #1
0
 public function __construct(O\Expression $expression, IParameterHasher $hasher, IFunction $function = null, $data = null)
 {
     parent::__construct($hasher, $data);
     if ($function !== null) {
         $this->contextFactory = $function->getEvaluationContextFactory();
         $this->evaluator = $expression->asEvaluator($this->contextFactory->getEvaluationContext());
     } else {
         $this->evaluator = $expression->asEvaluator();
     }
     $this->data = $data;
 }
 public function processFunction(IFunction $function)
 {
     $parameterScopeVariableMap = array_map(function ($variable) {
         return $this->prefix . $variable;
     }, $function->getParameterScopedVariableMap());
     return $function->update($function->getScopeType(), $function->getNamespace(), $parameterScopeVariableMap, $this->walkAll($function->getParameters()->getAll()), $this->walkAll($function->getBodyExpressions()));
 }
Beispiel #3
0
 public function appendFunction(IFunction $function)
 {
     if ($function->isInternal()) {
         throw new Exception('Internal functions are not supported');
     }
     $this->append('{');
     if ($function->countBodyExpressions() === 0) {
         $this->append('}');
     } elseif ($function->countBodyExpressions() === 1) {
         $this->append(' ');
         $this->append($function->getBodyExpressions()[0]->compile() . ';');
         $this->append(' }');
     } else {
         $this->appendLine();
         $this->append(implode(';' . PHP_EOL, Expression::compileAll($function->getBodyExpressions())) . ';');
         $this->appendLine();
         $this->append('}');
     }
     $parameterMap = $function->getParameterScopedVariableMap();
     if (!empty($parameterMap)) {
         $this->append(' with parameters: [');
         $parameters = [];
         foreach ($parameterMap as $variableName) {
             $parameters[] = "\${$variableName}";
         }
         $this->append(implode(', ', $parameters));
         $this->append(']');
     }
 }
Beispiel #4
0
 /**
  * {@inheritDoc}
  */
 public function processFunction(IFunction $function)
 {
     return $function->update($function->getScopeType(), $function->getNamespace(), $function->getParameterScopedVariableMap(), $this->walkAll($function->getParameters()->getAll()), $this->walkAll($function->getBodyExpressions()));
 }