/**
  * @covers phpDocumentor\Descriptor\DescriptorAbstract::setTags
  * @covers phpDocumentor\Descriptor\DescriptorAbstract::getTags
  */
 public function testSettingAndGettingTags()
 {
     $this->assertNull($this->fixture->getTags());
     /** @var Collection $mock */
     $mock = m::mock('phpDocumentor\\Descriptor\\Collection');
     $this->fixture->setTags($mock);
     $this->assertSame($mock, $this->fixture->getTags());
 }
 /**
  * If the ProjectDescriptor's settings allow internal tags then return the Descriptor, otherwise null to filter it.
  *
  * @param DescriptorAbstract $value
  *
  * @return DescriptorAbstract|null
  */
 public function filter($value)
 {
     $isInternalAllowed = $this->builder->isVisibilityAllowed(Settings::VISIBILITY_INTERNAL);
     if ($isInternalAllowed) {
         $value->setDescription(preg_replace('/{@internal\\ (.+)}}/', '$1', $value->getDescription()));
         return $value;
     }
     // remove inline @internal tags
     $value->setDescription(preg_replace('/{@internal\\ .+}}/', '', $value->getDescription()));
     // if internal elements are not allowed; filter this element
     if ($value->getTags()->get('internal')) {
         return null;
     }
     return $value;
 }
 /**
  * Assemble DocBlock.
  *
  * @param DocBlock|null      $docBlock
  * @param DescriptorAbstract $target
  *
  * @return void
  */
 protected function assembleDocBlock($docBlock, $target)
 {
     if (!$docBlock) {
         return;
     }
     $target->setSummary($docBlock->getShortDescription());
     $target->setDescription($docBlock->getLongDescription()->getContents());
     /** @var DocBlock\Tag $tag */
     foreach ($docBlock->getTags() as $tag) {
         $tagDescriptor = $this->builder->buildDescriptor($tag);
         // allow filtering of tags
         if (!$tagDescriptor) {
             continue;
         }
         $target->getTags()->get($tag->getName(), new Collection())->add($tagDescriptor);
     }
 }
 /**
  * Adds each tag to the XML Node representing the DocBlock.
  *
  * The Descriptor contains an array of tag groups (that are tags grouped by their name), which in itself contains
  * an array of the individual tags.
  *
  * @param \DOMElement        $docBlock
  * @param DescriptorAbstract $descriptor
  *
  * @return void
  */
 protected function addTags(\DOMElement $docBlock, $descriptor)
 {
     foreach ($descriptor->getTags() as $tagGroup) {
         if (!$tagGroup) {
             continue;
         }
         foreach ($tagGroup as $tag) {
             $this->tagConverter->convert($docBlock, $tag);
         }
     }
 }
Example #5
0
 /**
  * Adds each tag to the $xml_node.
  *
  * @param \DOMElement        $xml_node
  * @param DescriptorAbstract $element
  *
  * @return void
  */
 protected function addTags(\DOMElement $xml_node, $element)
 {
     foreach ($element->getTags() as $tagGroup) {
         if ($tagGroup === null) {
             continue;
         }
         foreach ($tagGroup as $tag) {
             $this->buildDocBlockTag($xml_node, $tag, $element);
         }
     }
 }
 /**
  * @param DescriptorAbstract $descriptor
  * @param string             $description
  */
 protected function givenDescriptorHasTodoTagWithDescription($descriptor, $description)
 {
     $todoTag = new TagDescriptor('todo');
     $todoTag->setDescription($description);
     $todoTags = $descriptor->getTags()->get('todo', array());
     $todoTags[] = $todoTag;
     $descriptor->getTags()->set('todo', $todoTags);
 }