Zephir\Documentation\Docblock::setDescription PHP Method

setDescription() public method

public setDescription ( string $description )
$description string
    public function setDescription($description)
    {
        $this->description = $description;
    }

Usage Example

Example #1
0
 /**
  * Parses the internal annotation string
  *
  * @return Docblock the parsed docblock
  */
 public function parse()
 {
     $this->docblockObj = new Docblock();
     $this->ignoreSpaces = false;
     $this->ignoreStar = true;
     $this->commentOpen = false;
     $this->annotationNameOpen = false;
     $this->annotationOpen = false;
     $this->summaryOpen = true;
     $this->descriptionOpen = false;
     $this->currentAnnotationStr = null;
     $this->currentAnnotationContentStr = null;
     $this->summaryStr = "";
     $this->descriptionStr = "";
     $this->currentLine = 0;
     $this->currentCharIndex = 0;
     $this->annotationLen = strlen($this->annotation);
     $this->currentChar = $this->annotation[0];
     while (null !== $this->currentChar) {
         $currentChar = $this->currentChar;
         if ($this->ignoreSpaces && ctype_space($currentChar)) {
         } else {
             if (!$this->commentOpen) {
                 if ($currentChar == "/") {
                     if ($this->nextCharacter() == "*" && $this->nextCharacter() == "*") {
                         $this->commentOpen = true;
                     } else {
                         continue;
                     }
                 }
             } else {
                 if ($currentChar == "*") {
                     $nextCharacter = $this->nextCharacter();
                     if ("/" == $nextCharacter) {
                         // stop annotation parsing on end of comment
                         $this->__tryRegisterAnnotation();
                         break;
                     } elseif ($this->ignoreStar) {
                         if ($nextCharacter == " ") {
                             $this->nextCharacter();
                         }
                         continue;
                     }
                 }
                 if ($currentChar == "@") {
                     $this->descriptionStr = trim($this->descriptionStr);
                     if ($this->descriptionOpen && strlen($this->descriptionStr) > 0) {
                         $this->descriptionOpen = false;
                     }
                     $this->currentAnnotationStr = "";
                     $this->currentAnnotationContentStr = "";
                     $this->ignoreSpaces = false;
                     $this->annotationNameOpen = true;
                 } elseif ($this->annotationNameOpen || $this->annotationOpen) {
                     // stop annotation parsing on new line
                     if ($currentChar == "\n" || $currentChar == "\r") {
                         $this->__tryRegisterAnnotation();
                         $this->ignoreSpaces = false;
                         $this->ignoreStar = true;
                     } elseif ($this->annotationNameOpen) {
                         if (ctype_space($currentChar)) {
                             $this->annotationNameOpen = false;
                             $this->annotationOpen = true;
                         } else {
                             $this->currentAnnotationStr .= $currentChar;
                         }
                     } elseif ($this->annotationOpen) {
                         $this->currentAnnotationContentStr .= $currentChar;
                     }
                 } elseif ($this->summaryOpen) {
                     // stop summary on new line
                     if (strlen($this->summaryStr) > 0 && ($currentChar == "\n" || $currentChar == "\r")) {
                         $this->summaryOpen = false;
                         $this->descriptionOpen = true;
                         $this->ignoreStar = true;
                     } else {
                         $this->summaryStr .= $currentChar;
                     }
                 } elseif ($this->descriptionOpen) {
                     // stop description on new line
                     if ($currentChar == "\n" || $currentChar == "\r") {
                         $this->descriptionStr .= PHP_EOL;
                     } else {
                         $this->descriptionStr .= $currentChar;
                     }
                 }
             }
         }
         $this->nextCharacter();
     }
     $this->docblockObj->setSummary(trim($this->summaryStr));
     $this->docblockObj->setDescription(trim($this->descriptionStr));
     return $this->docblockObj;
 }