Example #1
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->raw('new \\')->raw($this->class)->raw('(')->each($this->arguments, function ($argument, Loop $loop) use($compiler) {
         $compiler->repr($argument);
         if ($loop->isNotLast()) {
             $compiler->raw(', ');
         }
     })->raw(')');
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$blueprint->setTemplate(')->string($this->templateName)->raw(', new \\Phn\\Dal\\Template(')->indent()->write('[')->indent()->each($this->arguments, function ($argument, Loop $loop) use($compiler) {
         $compiler->write('')->string($argument['argument'])->raw(' => ');
         if (isset($argument['default'])) {
             $compiler->raw('new \\Phn\\Dal\\Argument\\ArgumentWithDefault(')->string($argument['type'])->raw(', ')->compile($argument['default'])->raw(')');
         } else {
             $compiler->raw('new \\Phn\\Dal\\Argument\\Argument(')->string($argument['type'])->raw(')');
         }
         if ($loop->isNotLast()) {
             $compiler->raw(',');
         }
     })->outdent()->write('],')->write('')->compile($this->body)->outdent()->write('));');
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$blueprint->setFunction(')->string($this->functionName)->raw(', new \\Phn\\Dal\\Func(')->indent()->write('[')->indent()->each($this->arguments, function ($argument, Loop $loop) use($compiler) {
         $compiler->write('')->string($argument['argument'])->raw(' => ');
         if (isset($argument['default'])) {
             $compiler->raw('new \\Phn\\Dal\\Argument\\ArgumentWithDefault(')->string($argument['type'])->raw(', ')->compile($argument['default'])->raw(')');
         } else {
             $compiler->raw('new \\Phn\\Dal\\Argument\\Argument(')->string($argument['type'])->raw(')');
         }
         if ($loop->isNotLast()) {
             $compiler->raw(',');
         }
     })->outdent()->write('],')->write('')->compile($this->body)->raw(',')->write('new \\Phn\\Dal\\ExecutionStrategy\\ReturnExpr(')->string($this->returnExpr['expr'])->raw(', ')->repr($this->returnExpr['field'] ?? null)->raw(', ')->repr($this->returnExpr['type'] ?? null)->raw(')')->outdent()->write('));');
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$mapper->export(')->string($this->resourceName)->runIf($this->alias !== null, function () use($compiler) {
         $compiler->raw(', ')->string($this->alias);
     })->raw(');');
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->raw('function (\\Phn\\Template\\Environment $env, array $context = [], array $blocks = []) {')->indent()->write('$fragments = [];')->nl()->compile($this->root)->nl()->write('return new \\Phn\\Fragment\\Node($fragments);')->outdent()->write('}');
 }