/** * 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; } }
/** * 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; } }