Pop\Code\Generator\DocblockGenerator::setTag PHP Метод

setTag() публичный Метод

Add a basic tag
public setTag ( string $name, string $desc = null ) : DocblockGenerator
$name string
$desc string
Результат DocblockGenerator
    public function setTag($name, $desc = null)
    {
        $this->tags[$name] = $desc;
        return $this;
    }

Usage Example

Пример #1
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 ? 'array()' : $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' ? 'array()' : 'null';
         $this->output .= ' = ' . $val . ';';
     }
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }
All Usage Examples Of Pop\Code\Generator\DocblockGenerator::setTag