コード例 #1
0
 /**
  * Render interface
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $this->output = null !== $this->namespace ? $this->namespace->render(true) . PHP_EOL : null;
     $this->output .= null !== $this->docblock ? $this->docblock->render(true) : null;
     $this->output .= 'interface ' . $this->name;
     if (null !== $this->parent) {
         $this->output .= ' extends ' . $this->parent;
     }
     $this->output .= PHP_EOL . '{' . PHP_EOL;
     $this->output .= $this->formatMethods() . PHP_EOL;
     $this->output .= '}' . PHP_EOL;
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }
コード例 #2
0
 /**
  * Render property
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $static = null;
     if ($this->visibility != 'const') {
         $varDeclaration = ' $';
         if ($this->static) {
             $static = ' static';
         }
     } else {
         $varDeclaration = ' ';
     }
     if (null === $this->docblock) {
         $this->docblock = new DocblockGenerator(null, $this->indent);
     }
     $this->docblock->setTag('var', $this->type);
     $this->output = PHP_EOL . $this->docblock->render(true);
     $this->output .= $this->indent . $this->visibility . $static . $varDeclaration . $this->name;
     if (null !== $this->value) {
         if ($this->type == 'array') {
             $val = count($this->value) == 0 ? '[]' : $this->formatArrayValues();
             $this->output .= ' = ' . $val . PHP_EOL;
         } else {
             if ($this->type == 'integer' || $this->type == 'int' || $this->type == 'float') {
                 $this->output .= ' = ' . $this->value . ';';
             } else {
                 if ($this->type == 'boolean') {
                     $val = $this->value ? 'true' : 'false';
                     $this->output .= " = " . $val . ";";
                 } else {
                     $this->output .= " = '" . $this->value . "';";
                 }
             }
         }
     } else {
         $val = $this->type == 'array' ? '[]' : 'null';
         $this->output .= ' = ' . $val . ';';
     }
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }
コード例 #3
0
ファイル: ClassGenerator.php プロジェクト: popphp/pop-code
 /**
  * Render class
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $abstract = $this->abstract ? 'abstract ' : null;
     $this->output = null !== $this->namespace ? $this->namespace->render(true) . PHP_EOL : null;
     $this->output .= null !== $this->docblock ? $this->docblock->render(true) : null;
     $this->output .= $abstract . 'class ' . $this->name;
     if (null !== $this->parent) {
         $this->output .= ' extends ' . $this->parent;
     }
     if (null !== $this->interface) {
         $this->output .= ' implements ' . $this->interface;
     }
     $this->output .= PHP_EOL . '{';
     $this->output .= $this->formatProperties() . PHP_EOL;
     $this->output .= $this->formatMethods() . PHP_EOL;
     $this->output .= '}' . PHP_EOL;
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }
コード例 #4
0
ファイル: MethodGenerator.php プロジェクト: popphp/pop-code
 /**
  * Render method
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $final = $this->final ? 'final ' : null;
     $abstract = $this->abstract ? 'abstract ' : null;
     $static = $this->static ? ' static' : null;
     $args = $this->formatArguments();
     $this->output = PHP_EOL . (null !== $this->docblock ? $this->docblock->render(true) : null);
     $this->output .= $this->indent . $final . $abstract . $this->visibility . $static . ' function ' . $this->name . '(' . $args . ')';
     if (!$this->abstract && !$this->interface) {
         $this->output .= PHP_EOL . $this->indent . '{' . PHP_EOL;
         $this->output .= $this->body . PHP_EOL;
         $this->output .= $this->indent . '}';
     } else {
         $this->output .= ';';
     }
     $this->output .= PHP_EOL;
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }
コード例 #5
0
ファイル: FunctionGenerator.php プロジェクト: popphp/pop-code
 /**
  * Render function
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $args = $this->formatArguments();
     $this->output = PHP_EOL . (null !== $this->docblock ? $this->docblock->render(true) : null);
     if ($this->closure) {
         $this->output .= $this->indent . '$' . $this->name . ' = function(' . $args . ')';
     } else {
         $this->output .= $this->indent . 'function ' . $this->name . '(' . $args . ')';
     }
     $this->output .= PHP_EOL . $this->indent . '{' . PHP_EOL;
     $this->output .= $this->body . PHP_EOL;
     $this->output .= $this->indent . '}';
     if ($this->closure) {
         $this->output .= ';';
     }
     $this->output .= PHP_EOL;
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }
コード例 #6
0
 /**
  * Render namespace
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $this->docblock = new DocblockGenerator(null, $this->indent);
     $this->docblock->setTag('namespace');
     $this->output = $this->docblock->render(true);
     $this->output .= $this->indent . 'namespace ' . $this->namespace . ';' . PHP_EOL;
     if (count($this->use) > 0) {
         $this->output .= PHP_EOL;
         foreach ($this->use as $ns => $as) {
             $this->output .= $this->indent . 'use ';
             $this->output .= $ns;
             if (null !== $as) {
                 $this->output .= ' as ' . $as;
             }
             $this->output .= ';' . PHP_EOL;
         }
     }
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }