Generates a type tag (return or var) but checks if one exists and updates this one

@param AbstractTag $tag
330366
protected function generateTypeTag(AbstractTag $tag) {
		$docblock = $this->getDocblock();
		$type = $this->getType();

		if (!empty($type)) {

			// try to find tag at first and update
			$tags = $docblock->getTags($tag->getTagName());
			if ($tags->size() > 0) {
				$ttag = $tags->get(0);
				$ttag->setType($this->getType());
				$ttag->setDescription($this->getTypeDescription());
			}

			// ... anyway create and append
			else {
				$docblock->appendTag($tag
					->setType($this->getType())
					->setDescription($this->getTypeDescription())
				);
			}
		}
	}
253712
public function hasTag(Tag $tag)
    {
        foreach ($this->_tags as $knownTag) {
            if ($knownTag->getId() == $tag->getId()) {
                return true;
            }
        }

        return false;
    }
250514
public function tag($abstracts, $tags)
    {
        $tags = is_array($tags) ? $tags : array_slice(func_get_args(), 1);

        foreach ($tags as $tag) {
            if (! isset($this->tags[$tag])) {
                $this->tags[$tag] = [];
            }

            foreach ((array) $abstracts as $abstract) {
                $this->tags[$tag][] = $abstract;
            }
        }
    }
872408
@SuppressWarnings("unchecked")
    public T addTag(String tag) {
        if (this.tags_ == null) {
            tags_ = new ArrayList<>();
        }
        this.tags_.add(tag);
        return (T) this;
    }
1043091
private static function open(TagInterface $tag, $autoClosed = false)
    {
        $output =  '<' . $tag->getType();

        if ($tag->hasAttributes()) {
            $output .= ' ' . $tag->renderAttributes();
        }

        $output .= ($autoClosed ? '/>' : '>');

        return $output;
    }
1307644
private function record_tag($tag)
    {
        if (isset($this->tags[$tag . 'count'])) { //check for the existence of this tag type
            $this->tags[$tag . 'count']++;
            $this->tags[$tag . $this->tags[$tag . 'count']] = $this->indent_level; //and record the present indent level
        } else { //otherwise initialize this tag type
            $this->tags[$tag . 'count'] = 1;
            $this->tags[$tag . $this->tags[$tag . 'count']] = $this->indent_level; //and record the present indent level
        }
        $this->tags[$tag . $this->tags[$tag . 'count'] . 'parent'] = $this->tags['parent']; //set the parent (i.e. in the case of a div this.tags.div1parent)
        $this->tags['parent'] = $tag . $this->tags[$tag . 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
    }
1023580
public function setTag(string $tag): void
    {
        if (!in_array($tag, static::ALLOWED_TAGS)) {
            throw new \InvalidArgumentException('Tag can be one of this type '.implode(' ', static::ALLOWED_TAGS));
        }

        $this->tag = $tag;
    }
905359
public function addTag(Tag $tag)
    {
        // Add tag if not existing
        if (!$this->hasTag($tag)) {
            $this->tags[$tag->getTag()] = $tag;
        }

        // Increment counter if no override in the Tag entity
        if ($tag->getCounter() === null) {
            $tag->incCounter();
        }

        // Store the max counter
        if ($tag->getCounter() > $this->max) {
            $this->max = $tag->getCounter();
        }

        return $this;
    }
530286
public function doGenerate($tag, array $parameters)
    {
        if (isset($parameters['siteaccess'])) {
            // We generate for a different siteaccess, so potentially in a different language.
            $languages = $this->configResolver->getParameter('languages', null, $parameters['siteaccess']);
            unset($parameters['siteaccess']);
        } else {
            $languages = $this->configResolver->getParameter('languages');
        }

        $tagUrl = '';
        $isInternal = false;
        $originalTagId = $tagId = $tag->id;

        try {
            do {
                $tag = $this->tagsService->loadTag($tagId, $languages);

                $tagKeyword = null;
                foreach ($languages as $language) {
                    $tagKeyword = $tag->getKeyword($language);
                    if (!empty($tagKeyword)) {
                        break;
                    }
                }

                if (empty($tagKeyword)) {
                    if ($tag->alwaysAvailable) {
                        $tagKeyword = $tag->getKeyword();
                    }

                    if (empty($tagKeyword)) {
                        throw new LogicException("Unknown error when generating URL for tag ID #{$originalTagId}");
                    }
                }

                $tagUrl = '/' . $tagKeyword . $tagUrl;

                $tagId = $tag->parentTagId;
            } while ($tagId > 0);
        } catch (NotFoundException $e) {
            $isInternal = true;
            $tagUrl = $this->defaultRouter->generate(
                self::INTERNAL_TAG_ROUTE,
                [
                    'tagId' => $originalTagId,
                ]
            );
        } catch (LogicException $e) {
            if ($this->logger !== null) {
                $this->logger->warning($e->getMessage());
            }

            $isInternal = true;
            $tagUrl = $this->defaultRouter->generate(
                self::INTERNAL_TAG_ROUTE,
                [
                    'tagId' => $originalTagId,
                ]
            );
        }

        $queryString = '';
        if (!empty($parameters)) {
            $queryString = '?' . http_build_query($parameters, '', '&');
        }

        return (!$isInternal ? $this->getPathPrefix() : '') . '/' . trim($tagUrl, '/') . $queryString;
    }
937981
public function DelSubCommunity(string $tag = NULL)
    {
        if (GnUtil::IsNullOrEmpty($tag)) {
            throw new \InvalidArgumentException("tag required");
        }

        $this->ExecuteCall("DelSubCommunity", (object)[
            "tag" => $tag
        ], GnResponseType::Json, FALSE, PHP_INT_MAX);
    }
952958
public function hasTag(string $tag): bool
    {
        return is_array($this->tags) && array_key_exists($tag, $this->tags);
    }
482419
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;
    }
1054531
public function attachTag(Tag $tag)
    {
        if (!$this->hasTag($tag)) {
            $this->_tags[] = $tag;
        }

        return $this;
    }
861473
public function addTag($tag, $message = null)
    {
        if ($message === null) {
            $message = $tag;
        }
        return $this->run("tag -a $tag -m $message");
    }
488227
public function taggedAs($tag)
    {
        if (empty($this->current_node)) {
            return;
        }

        $this->current_node->tags = $tag;
        $this->current_node->save();
    }
853009
public function getTag($tag)
    {
        if (!isset($this->tags[ $tag ])) {
            throw new \OutOfBoundsException("Tag {$tag} does not exist.");
        }

        return $this->tags[ $tag ];
    }
383891
public function withTag(string $tag): self
    {
        if ($this->has($tag)) {
            return $this;
        }
        self::validateTag($tag);
        $newTags = $this->tags;
        $newTags[] = $tag;
        return new static($newTags);
    }