Validate the given branch.

Returns true on success, the name of the offending tag on failure.

@param string $tag   The tag to check.

@param string $alias The alias for the given branch.

@return bool|string
425107
public function validate($tag, $alias)
    {
        $simpleAlias  = preg_replace('~(\.x)?-dev~', '', $alias);
        $versionLevel = count(explode('.', $simpleAlias));
        $reducedTag   = preg_replace('~-.*$~', '', $tag);
        $reducedTag   = implode('.', array_slice(explode('.', $reducedTag), 0, $versionLevel));

        return version_compare($reducedTag, $simpleAlias, '<=');
    }
729619
public static function clearTag($tag): bool
    {
        if (self::getInstance() instanceof HierarchicalPoolInterface) {
            return self::getInstance()->invalidateTag($tag);
        }
        return false;
    }
847273
public static function isValid($hashtag)
    {
        $hashtag = ltrim($hashtag, '#');
        if (empty($hashtag)) {
            return false;
        }

        $test = preg_replace('/[^a-zA-Z0-9_]/', '', $hashtag);
        if ($test !== $hashtag) {
            return false;
        }

        if ('_' === $hashtag[0]) {
            return false;
        }

        $len = strlen($hashtag);
        if ($len > 139) {
            return false;
        }

        for ($i = 0; $i < $len; $i++) {
            if (!is_numeric($hashtag[$i])) {
                return true;
            }
        }

        return false;
    }
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;
    }
1290528
protected function isValidTag(string $tag, Message $message = null): void
    {
        $allowedTag = $this->getAllowedTag();
        if (!\in_array($tag, $allowedTag, true)) {
            throw new InvalidKeyException(sprintf(
                'tag must be either "%s".',
                implode(', ', $allowedTag)
            ));
        }

        if ($tag === SendInterface::TAG_ISSUE_RESOLUTION && $message !== null && !$message instanceof GenericTemplate) {
            throw new InvalidClassException(sprintf(
                'message must be an instance of %s if tag is set to %s.',
                GenericTemplate::class,
                SendInterface::TAG_ISSUE_RESOLUTION
            ));
        }
    }
1263906
protected function validateTag($version)
    {
        try {
            if (!strpos($version, '/')) {
                return false;
            }
            return $this->versionParser->normalize(
                $this->_getBranchWithoutNamespace($version)
            );
        } catch (\Exception $e) {
            return false;
        }
    }
520443
public static function validate($license = null)
    {
        if (!is_string($license)) {
            return false;
        }

        return preg_match('#' . self::$regex. '#', $license);
    }
356427
protected function _tagExists($tag) {
		$tagsTable = $this->_table->{$this->getConfig('tagsAlias')}->getTarget();
		$result = $tagsTable->find()
			->where([
				$tagsTable->aliasField('slug') => $tag,
			])
			->select([
				$tagsTable->aliasField($tagsTable->getPrimaryKey())
			])
			->first();
		if (!empty($result)) {
			return $result->id;
		}
		return null;
	}
375523
protected function isTag($branchOrTag)
    {
        $tagList = $this->getTagList();
        
        if(!is_array($tagList)) {
            return false;
        }
        
        return \in_array($branchOrTag, $tagList, true);
    }
1373247
public function removeTag(Tag $tag)
    {
        if ($this->tags->contains($tag)) {
            $this->tags->removeElement($tag);
            return true;
        }
        return false;
    }
10365
private function isOpenTag($token): bool
    {
        if (!is_array($token)) {
            return false;
        }

        if ($token[0] == T_ECHO && $token[1] == '<?=') {
            return true;
        }

        return $token[0] == T_OPEN_TAG || $token[0] == T_OPEN_TAG_WITH_ECHO;
    }
861072
public static function parse(Tag &$Tag)
    {
        if (!empty($Tag->content) && $Tag->hasOption('translate') && is_callable(Config::get('translator'))) {
            $Tag->content = call_user_func_array(
                Config::get('translator'),
                array(
                    $Tag->content,
                    Config::get('textdomain')
                )
            );
        }
        
        if ($Tag->hasOption('bbContent')) {
            self::bb($Tag->content);
        }

        if ($Tag->hasOption('markdown')) {
            $Tag->addOption('cleanContent');
            self::markdown($Tag->content);
        }

        if ($Tag->hasOption('compress')) {
            self::compress($Tag);
        }

        return $Tag->content;
    }
1219145
protected function requireAncestor(Tag $tag)
	{
		$tagName   = $tag->getName();
		$tagConfig = $this->tagsConfig[$tagName];

		if (isset($tagConfig['rules']['requireAncestor']))
		{
			foreach ($tagConfig['rules']['requireAncestor'] as $ancestorName)
			{
				if (!empty($this->cntOpen[$ancestorName]))
				{
					return false;
				}
			}

			$this->logger->err('Tag requires an ancestor', [
				'requireAncestor' => implode(',', $tagConfig['rules']['requireAncestor']),
				'tag'             => $tag
			]);

			return true;
		}

		return false;
	}
1262534
protected function closeAncestor(Tag $tag)
	{
		if (!empty($this->openTags))
		{
			$tagName   = $tag->getName();
			$tagConfig = $this->tagsConfig[$tagName];

			if (!empty($tagConfig['rules']['closeAncestor']))
			{
				$i = count($this->openTags);

				while (--$i >= 0)
				{
					$ancestor     = $this->openTags[$i];
					$ancestorName = $ancestor->getName();

					if (isset($tagConfig['rules']['closeAncestor'][$ancestorName]))
					{
						++$this->currentFixingCost;

						// We have to close this ancestor. First we reinsert this tag...
						$this->tagStack[] = $tag;

						// ...then we add a new end tag for it with a better priority
						$this->addMagicEndTag($ancestor, $tag->getPos(), $tag->getSortPriority() - 1);

						return true;
					}
				}
			}
		}

		return false;
	}
1236951
private function subtag_check ($tagName)
  {
    $propName = lcfirst ($tagName);
    if ($this->current instanceof Metadata) {
      switch ($this->current->type) {
        // All descendants of a metadata property are always metadata.
        case type::metadata:
          return true;
      }
      // Descendants of a content property are children, not properties.
      return false;
    }
    // If the current component defines an property with the same name as the tag being checked, and if that property
    // supports begin specified as a tag, the tag is a subtag.
    return $this->current->supportsProperties () && $this->current->props->defines ($propName, true);
  }
1286890
protected function outputBrTag(Tag $tag)
	{
		$this->outputText($tag->getPos(), 0, false);
		$this->output .= '<br/>';
	}
460092
public function addAlias($alias, $tagName)
    {
        if($this->getComponentFactory($tagName)) {
            $this->alias[(string) $alias] = (string) $tagName;
        }
        return $this;
    }