Ejemplo n.º 1
0
 /**
  * @param Node[] $stmts
  * @return Node[]
  */
 private function translateReturnStatements(array $stmts)
 {
     // Ignore factories
     if ($this->definition->isFactory()) {
         $var = new Node\Expr\Variable($this->definition->getIdentifier());
     } else {
         $var = new Node\Expr\PropertyFetch(new Node\Expr\Variable('this'), $this->definition->getIdentifier());
     }
     $setterStmts = $this->compileInterfaces($var);
     $visitor = new Visitor\ReturnTranslatorVisitor($var, $setterStmts);
     $fileTraverser = new NodeTraverser();
     $fileTraverser->addVisitor($visitor);
     return $fileTraverser->traverse($stmts);
 }
Ejemplo n.º 2
0
 private function makeClosure(Definition\ClosureDefinition $definition, InjectionPoint $ip)
 {
     $ip->method = null;
     $params = array();
     foreach ($definition->getParams() as $position => $param) {
         $params[$position] = $this->makeParam($param);
     }
     $closure = $definition->getClosure();
     $reflectionFunction = new \ReflectionFunction($closure);
     return $reflectionFunction->invokeArgs($params);
 }