예제 #1
0
 /** @return Method */
 public function addBody($statement, array $args = NULL)
 {
     $this->body .= (func_num_args() > 1 ? Helpers::formatArgs($statement, $args) : $statement) . "\n";
     return $this;
 }
예제 #2
0
 /**
  * Formats PHP statement.
  * @return string
  */
 public function formatPhp($statement, $args, $self = NULL)
 {
     $that = $this;
     array_walk_recursive($args, function (&$val) use($self, $that) {
         list($val) = $that->normalizeEntity(array($val));
         if ($val instanceof Statement) {
             $val = new PhpLiteral($that->formatStatement($val, $self));
         } elseif ($val === '@' . ContainerBuilder::THIS_CONTAINER) {
             $val = new PhpLiteral('$this');
         } elseif ($service = $that->getServiceName($val, $self)) {
             $val = $service === $self ? '$service' : $that->formatStatement(new Statement($val));
             $val = new PhpLiteral($val);
         }
     });
     return PhpHelpers::formatArgs($statement, $args);
 }
예제 #3
0
 private function formatPhp($statement, $args, $self = NULL)
 {
     $that = $this;
     array_walk_recursive($args, function (&$val) use($self, $that) {
         if ($val instanceof Statement) {
             $val = new PhpLiteral($that->formatStatement($val, $self));
         } elseif (!is_string($val)) {
             return;
         } elseif ($val === '@' . ContainerBuilder::THIS_CONTAINER) {
             $val = new PhpLiteral('$this');
         } elseif ($service = $that->getServiceName($val, $self)) {
             if ($service === $self) {
                 $val = new PhpLiteral('$service');
             } elseif ($that->definitions[$service]->shared) {
                 $val = new PhpLiteral('$this->' . PhpHelpers::formatMember($service));
             } else {
                 $val = new PhpLiteral('$this->' . PhpHelpers::formatMember('create' . ucfirst($service)) . '()');
             }
         }
     });
     return PhpHelpers::formatArgs($statement, $args);
 }