Example #1
0
 /**
  * @dataProvider descriptionProvider
  *
  * @param string   $expectedShort
  * @param string   $expectedLong
  * @param string[] $expectedTagNames
  * @param string   $comment
  */
 public function testDescription($expectedShort, $expectedLong, $expectedTagNames, $comment)
 {
     $docBlock = new DocBlock($comment);
     $this->assertSame($expectedShort, $docBlock->getShortDescription());
     $this->assertSame($expectedLong, $docBlock->getLongDescription()->getContents());
     $tags = $docBlock->getTags();
     $tagNames = array_map(function ($tag) {
         return $tag->getName();
     }, $tags);
     $this->assertSame($expectedTagNames, $tagNames);
 }
Example #2
0
 /**
  * godoc-style merging of a class or method name with the phpdoc short description.
  *
  * @param string                              $name
  * @param \nochso\WriteMe\Reflection\DocBlock $doc
  * @param string|null                         $displayName
  *
  * @return string
  */
 private function mergeNameWithShortDescription($name, DocBlock $doc, $displayName = null)
 {
     if ($displayName === null) {
         $displayName = $name;
     }
     $merged = $displayName;
     $words = explode(' ', trim($doc->getShortDescription()), 2);
     if (count($words) >= 2 && strtolower($words[0]) == strtolower($name)) {
         $merged .= ' ' . $words[1];
     } else {
         $merged .= ' ' . $doc->getShortDescription();
     }
     return rtrim($merged);
 }