/** * Appends a tag at the end of the list of tags. * * @param Tag $tag The tag to add. * * @return Tag The newly added tag. * * @throws \LogicException When the tag belongs to a different DocBlock. */ public function appendTag(Tag $tag) { if (null === $tag->getDocBlock()) { $tag->setDocBlock($this); } if ($tag->getDocBlock() === $this) { $this->tags[] = $tag; } else { throw new \LogicException('This tag belongs to a different DocBlock object.'); } return $tag; }