예제 #1
0
 /** @return string  PHP code */
 public function __toString()
 {
     $parameters = array();
     foreach ($this->parameters as $param) {
         $parameters[] = ($param->typeHint ? $param->typeHint . ' ' : '') . ($param->reference ? '&' : '') . '$' . $param->name . ($param->optional ? ' = ' . Helpers::dump($param->defaultValue) : '');
     }
     $uses = array();
     foreach ($this->uses as $param) {
         $uses[] = ($param->reference ? '&' : '') . '$' . $param->name;
     }
     return ($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '') . ($this->abstract ? 'abstract ' : '') . ($this->final ? 'final ' : '') . ($this->visibility ? $this->visibility . ' ' : '') . ($this->static ? 'static ' : '') . 'function' . ($this->returnReference ? ' &' : '') . ($this->name ? ' ' . $this->name : '') . '(' . implode(', ', $parameters) . ')' . ($this->uses ? ' use (' . implode(', ', $uses) . ')' : '') . ($this->abstract || $this->body === FALSE ? ';' : ($this->name ? "\n" : ' ') . "{\n" . Nette\Utils\Strings::indent(trim($this->body), 1) . "\n}");
 }
예제 #2
0
 /** @return string  PHP code */
 public function __toString()
 {
     $consts = array();
     foreach ($this->consts as $name => $value) {
         $consts[] = "const {$name} = " . Helpers::dump($value) . ";\n";
     }
     $properties = array();
     foreach ($this->properties as $property) {
         $properties[] = ($property->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $property->documents)) . "\n */\n" : '') . $property->visibility . ($property->static ? ' static' : '') . ' $' . $property->name . ($property->value === null ? '' : ' = ' . Helpers::dump($property->value)) . ";\n";
     }
     return Nette\Utils\Strings::normalize(($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '') . ($this->abstract ? 'abstract ' : '') . ($this->final ? 'final ' : '') . $this->type . ' ' . $this->name . ' ' . ($this->extends ? 'extends ' . implode(', ', (array) $this->extends) . ' ' : '') . ($this->implements ? 'implements ' . implode(', ', (array) $this->implements) . ' ' : '') . "\n{\n\n" . Nette\Utils\Strings::indent(($this->traits ? "use " . implode(', ', (array) $this->traits) . ";\n\n" : '') . ($this->consts ? implode('', $consts) . "\n\n" : '') . ($this->properties ? implode("\n", $properties) . "\n\n" : '') . implode("\n\n\n", $this->methods), 1) . "\n\n}") . "\n";
 }
예제 #3
0
파일: PhpAdapter.php 프로젝트: svobodni/web
 /**
  * Generates configuration in PHP format.
  * @return string
  */
 public function dump(array $data)
 {
     return "<?php // generated by Nette \nreturn " . Nette\Utils\PhpGenerator\Helpers::dump($data) . ';';
 }
예제 #4
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);
 }
예제 #5
0
Nette\Utils\LimitedScope::load($file);}function
dump(array$data){return"<?php // generated by Nette \nreturn ".Nette\Utils\PhpGenerator\Helpers::dump($data).';';}}}namespace Nette\Config{use