@param ParserTag      $tag
@param FileRepository $files

@return bool
343717
public static function addAttributes(ParserTag $tag, FileRepository $files)
    {
        $file = $files->findByUuid($tag->getAttribute('uuid'));
        $tag->setAttribute('base_name', $file->base_name);
        $tag->setAttribute('downloads', $file->downloads->count());
        $tag->setAttribute('size', $file->humanSize);

        return true;
    }
851727
public function insert(WorkspaceTag $tag)
    {
        $this->om->persist($tag);
        $this->om->flush();
    }
132501
private function isLabelableNode( Tag $tag ) {
		$labelableTags = [ 'button', 'meter', 'output', 'progress', 'select', 'textarea' ];
		$tagName = strtolower( $tag->getTag() );

		if ( $tagName === 'input' && $tag->getAttribute( 'type' ) !== 'hidden' ) {
			return true;
		}
		if ( in_array( $tagName, $labelableTags, true ) ) {
			return true;
		}
		return false;
	}
878393
private function isTagDisplayable(WorkspaceTag $tag, array $tagWorkspaces, array $hierarchy)
    {
        $displayable = false;
        $tagId = $tag->getId();

        if ((isset($tagWorkspaces[$tagId]) && count($tagWorkspaces[$tagId]) > 0)
            || !is_null($tag->getWorkspace())) {

            $displayable = true;
        } else {

            if (isset($hierarchy[$tagId]) && count($hierarchy[$tagId]) > 0) {
                $children = $hierarchy[$tagId];

                foreach ($children as $child) {

                    $displayable = $this->isTagDisplayable($child, $tagWorkspaces, $hierarchy);

                    if ($displayable) {
                        break;
                    }
                }
            }
        }

        return $displayable;
    }
165880
public function findIdentifiersByTag($tag)
    {
        $tagsFiles = \glob(GeneralUtility::getFileAbsFileName(self::RELATIVE_STORAGE_FOLDER) . '*/*/*' . self::FILE_EXTENSION_TAG);
        $identifiers = [];
        foreach ($tagsFiles as $tagsFile) {
            if (false !== \mb_strpos(\file_get_contents($tagsFile), '|' . $tag . '|')) {
                $identifiers[] = \file_get_contents(\str_replace(self::FILE_EXTENSION_TAG, self::FILE_EXTENSION_IDENTIFIER, $tagsFile));
            }
        }

        return $identifiers;
    }
503684
public function hasTag($tag)
    {
        if ($this->isTopTag($tag)) {
            return true;
        }

        return isset($this->tags[$tag]) && is_array($this->tags[$tag]);
    }
462112
private function removeTag($tag)
    {
        try {
            if (isset($this->_hashmap[$tag])) {
                foreach (array_keys($this->_hashmap[$tag]) as $key) {
                    if (\apc_delete($key)) {
                        unset($this->_hashmap[$tag][$key]);
                    }
                }

                return $this->saveHashmap();
            }
        } catch (\Exception $e) {
            $this->log('warning', \sprintf('Unable to delete cache for tag %s : %s', $tag, $e->getMessage()));

            return false;
        }

        return true;
    }
341714
public boolean acceptTaggedScenario(final Set<String> tags) {

        if (acceptAll || (acceptedTags.isEmpty() && excludedTags.isEmpty())) {
            return true;
        } else if (acceptedTags.size() > 0 && (tags == null || tags.isEmpty())) {
            return false;
        } else if (containsAny(tags, excludedTags)) {
            return false;
        } else {
            return tags == null || tags.containsAll(acceptedTags);
        }
    }
1352046
public function hasTags(array $tags, $matchAll = true)
    {
        $routeTags = $this->getRoute()->getTags();
        $diffCount = count(array_diff($tags, $routeTags));
        $tagsCount = count($tags);

        if ($matchAll) {
            if ($diffCount === 0) {
                return true;
            }
        } else {
            if ($tagsCount > $diffCount) {
                return true;
            }
        }

        return false;
    }
952958
public function hasTag(string $tag): bool
    {
        return is_array($this->tags) && array_key_exists($tag, $this->tags);
    }
1355583
public function hasTag($tag)
    {
        if (is_array($tag)) {
            return true;
        }

        @list($tag, $ref) = explode('#', $tag);

        return isset($this->tags[$tag]) || $this->isTopTag($tag);
    }
966728
public function has(string $key, array $tags): bool 
    {
        return $this->cache->tags($tags)->has($key);
    }
1072358
protected function processEndTag(Tag $tag)
	{
		$tagName = $tag->getName();

		if (empty($this->cntOpen[$tagName]))
		{
			// This is an end tag with no start tag
			return;
		}

		/**
		* @var array List of tags need to be closed before given tag
		*/
		$closeTags = [];

		// Iterate through all open tags from last to first to find a match for our tag
		$i = count($this->openTags);
		while (--$i >= 0)
		{
			$openTag = $this->openTags[$i];

			if ($tag->canClose($openTag))
			{
				break;
			}

			$closeTags[] = $openTag;
			++$this->currentFixingCost;
		}

		if ($i < 0)
		{
			// Did not find a matching tag
			$this->logger->debug('Skipping end tag with no start tag', ['tag' => $tag]);

			return;
		}

		// Accumulate flags to determine whether whitespace should be trimmed
		$flags = $tag->getFlags();
		foreach ($closeTags as $openTag)
		{
			$flags |= $openTag->getFlags();
		}
		$ignoreWhitespace = (bool) ($flags & self::RULE_IGNORE_WHITESPACE);

		// Only reopen tags if we haven't exceeded our "fixing" budget
		$keepReopening = (bool) ($this->currentFixingCost < $this->maxFixingCost);

		// Iterate over tags that are being closed, output their end tag and collect tags to be
		// reopened
		$reopenTags = [];
		foreach ($closeTags as $openTag)
		{
			$openTagName = $openTag->getName();

			// Test whether this tag should be reopened automatically
			if ($keepReopening)
			{
				if ($openTag->getFlags() & self::RULE_AUTO_REOPEN)
				{
					$reopenTags[] = $openTag;
				}
				else
				{
					$keepReopening = false;
				}
			}

			// Find the earliest position we can close this open tag
			$tagPos = $tag->getPos();
			if ($ignoreWhitespace)
			{
				$tagPos = $this->getMagicEndPos($tagPos);
			}

			// Output an end tag to close this start tag, then update the context
			$endTag = new Tag(Tag::END_TAG, $openTagName, $tagPos, 0);
			$endTag->setFlags($openTag->getFlags());
			$this->outputTag($endTag);
			$this->popContext();
		}

		// Output our tag, moving the cursor past it, then update the context
		$this->outputTag($tag);
		$this->popContext();

		// If our fixing budget allows it, peek at upcoming tags and remove end tags that would
		// close tags that are already being closed now. Also, filter our list of tags being
		// reopened by removing those that would immediately be closed
		if (!empty($closeTags) && $this->currentFixingCost < $this->maxFixingCost)
		{
			/**
			* @var integer Rightmost position of the portion of text to ignore
			*/
			$ignorePos = $this->pos;

			$i = count($this->tagStack);
			while (--$i >= 0 && ++$this->currentFixingCost < $this->maxFixingCost)
			{
				$upcomingTag = $this->tagStack[$i];

				// Test whether the upcoming tag is positioned at current "ignore" position and it's
				// strictly an end tag (not a start tag or a self-closing tag)
				if ($upcomingTag->getPos() > $ignorePos
				 || $upcomingTag->isStartTag())
				{
					break;
				}

				// Test whether this tag would close any of the tags we're about to reopen
				$j = count($closeTags);

				while (--$j >= 0 && ++$this->currentFixingCost < $this->maxFixingCost)
				{
					if ($upcomingTag->canClose($closeTags[$j]))
					{
						// Remove the tag from the lists and reset the keys
						array_splice($closeTags, $j, 1);

						if (isset($reopenTags[$j]))
						{
							array_splice($reopenTags, $j, 1);
						}

						// Extend the ignored text to cover this tag
						$ignorePos = max(
							$ignorePos,
							$upcomingTag->getPos() + $upcomingTag->getLen()
						);

						break;
					}
				}
			}

			if ($ignorePos > $this->pos)
			{
				/**
				* @todo have a method that takes (pos,len) rather than a Tag
				*/
				$this->outputIgnoreTag(new Tag(Tag::SELF_CLOSING_TAG, 'i', $this->pos, $ignorePos - $this->pos));
			}
		}

		// Re-add tags that need to be reopened, at current cursor position
		foreach ($reopenTags as $startTag)
		{
			$newTag = $this->addCopyTag($startTag, $this->pos, 0);

			// Re-pair the new tag
			$endTag = $startTag->getEndTag();
			if ($endTag)
			{
				$newTag->pairWith($endTag);
			}
		}
	}
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;
            }
        }
    }
101019
public function tag($tags)
    {
        $tags = $this->makeTagsArray($tags);

        $this->addTags($tags);

        if (count($tags) > 0) {
            $this->tags()->sync(
                Tag::whereIn('tag', $tags)->pluck('id')->all()
            );

            return;
        }

        $this->tags()->detach();
    }
853419
public static function matchTagsWithSortOrder(array $tags1, array $tags2)
    {
        if (count(self::diffTags($tags1, $tags2, true)) == 0 &&
            count(self::diffTags($tags2, $tags1, true)) == 0)
            return true;

        return false;

    }
608517
private function saveTag($tag, $digest)
    {
        $path = $this->getTagPath($tag) . DIRECTORY_SEPARATOR . $digest;
        if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
            return false;
        }

        $tmpFile = tempnam(dirname($path), basename($path));
        if (false === $fp = @fopen($tmpFile, 'wb')) {
            return false;
        }
        @fwrite($fp, $digest);
        @fclose($fp);

        if ($digest != file_get_contents($tmpFile)) {
            return false;
        }

        if (false === @rename($tmpFile, $path)) {
            return false;
        }

        @chmod($path, 0666 & ~umask());

        return true;
    }