private function addParameterMapping(ExpressionCompiler $compiler) { $name = $compiler->nextName(); $indexName = $compiler->nextName(); $paramName = $compiler->nextName(); $compiler->setAttribute('parameter_mapping_name', $name)->writeln("\${$name} = array();")->write("foreach (")->compileInternal(new VariableExpression('object'))->writeln("->reflection->getParameters() as \${$indexName} => \${$paramName}) {")->indent()->writeln("\${$name}[\${$paramName}->name] = \${$indexName};")->outdent()->writeln("}\n"); }
public function compilePreconditions(ExpressionCompiler $compiler, FunctionExpression $function) { if (1 !== count($function->args)) { throw new \RuntimeException(sprintf('The %s() function expects exactly one argument, but got "%s".', $this->getName(), var_export($function->args, true))); } $argName = $compiler->nextName(); $compiler->write("\${$argName} = ")->compileInternal($function->args[0])->writeln(';'); $compiler->attributes['arg_name'] = $argName; }
public function compilePreconditions(ExpressionCompiler $compiler, ExpressionInterface $expr) { if ('user' === $expr->name) { $compiler->setAttribute('user_var_name', $name = $compiler->nextName())->write("\${$name} = ")->compileInternal(new VariableExpression('token'))->write("->getUser();\n\n"); } }