/** * Get named element by it's name. * * @param string $name * @return ConstantDeclaration */ public function get($name) { if (!$this->has($name)) { //Automatically creating constant $constant = new ConstantDeclaration($name, null); $this->add($constant); return $constant; } return parent::get($name); }
/** * Get named element by it's name. * * @param string $name * @return MethodDeclaration */ public function get($name) { if (!$this->has($name)) { //Automatically creating constant $method = new MethodDeclaration($name); $this->add($method); return $method; } return parent::get($name); }
/** * Get named element by it's name. * * @param string $name * @return PropertyDeclaration */ public function get($name) { if (!$this->has($name)) { //Automatically creating constant $property = new PropertyDeclaration($name); $this->add($property); return $property; } return parent::get($name); }
/** * Get named element by it's name. * * @param string $name * @return ParameterDeclaration */ public function get($name) { if (!$this->has($name)) { //Automatically creating constant $parameter = new ParameterDeclaration($name, null); $this->add($parameter); return $parameter; } return parent::get($name); }
/** * {@inheritdoc} */ public function render($indentLevel = 0) { $result = ''; $indentShift = 0; if (!$this->docComment->isEmpty()) { $result .= $this->docComment->render($indentLevel) . "\n"; } if (!empty($this->getName())) { $result = $this->indent("namespace {$this->getName()} {", $indentLevel) . "\n"; $indentShift = 1; } if (!empty($this->uses)) { $result .= $this->renderUses($indentLevel + $indentShift) . "\n\n"; } $result .= $this->elements->render($indentLevel + $indentShift); if (!empty($this->getName())) { $result .= "\n" . $this->indent("}", $indentLevel); } return $result; }
/** * {@inheritdoc} */ public function render($indentLevel = 0) { $result = "<?php\n"; if (!$this->docComment->isEmpty()) { $result .= $this->docComment->render($indentLevel) . "\n"; } if (!empty($this->namespace)) { $result .= "namespace {$this->namespace};\n\n"; } if (!empty($this->uses)) { $result .= $this->renderUses($indentLevel) . "\n\n"; } $result .= $this->elements->render($indentLevel); return $result; }