@param string $matchType

@return Term
436966
public function setMatchType(string $matchType): self
    {
        if (!isset($this->field)) {
            throw new \LogicException();
        }

        $this->matchType = $matchType;

        return $this;
    }
1041024
public function withFilteredSteps(callable $matcher)
    {
        $clone = clone $this;

        foreach ($clone->stages as $stage => &$steps) {
            $steps = array_filter($steps, function ($step) use ($matcher, $stage) {
                return $matcher($stage, $step);
            });
        }

        return $clone;
    }
307526
public function explain(array $matchers, array $arguments): MatcherResult
    {
        $isMatch = true;
        $matcherMatches = [];
        $argumentMatches = [];
        $argumentCount = count($arguments);
        $index = 0;

        foreach ($matchers as $matcher) {
            if ($matcher instanceof WildcardMatcher) {
                $matcherIsMatch = true;
                $innerMatcher = $matcher->matcher();
                $minimumArguments = $matcher->minimumArguments();
                $maximumArguments = $matcher->maximumArguments();

                for ($count = 0; $count < $minimumArguments; ++$count) {
                    if ($index >= $argumentCount) {
                        $matcherIsMatch = false;
                        $argumentMatches[] = false;

                        break;
                    }

                    if ($innerMatcher->matches($arguments[$index])) {
                        $argumentMatches[] = true;
                    } else {
                        $matcherIsMatch = false;
                        $argumentMatches[] = false;
                    }

                    ++$index;
                }

                if ($maximumArguments < 0) {
                    while (
                        $index < $argumentCount &&
                        $innerMatcher->matches($arguments[$index])
                    ) {
                        $argumentMatches[] = true;
                        ++$index;
                    }
                } else {
                    for (; $count < $maximumArguments; ++$count) {
                        if (
                            $index >= $argumentCount ||
                            !$innerMatcher->matches($arguments[$index])
                        ) {
                            break;
                        }

                        $argumentMatches[] = true;
                        ++$index;
                    }
                }

                $isMatch = $isMatch && $matcherIsMatch;
                $matcherMatches[] = $matcherIsMatch;

                continue;
            }

            $matcherIsMatch =
                $index < $argumentCount &&
                $matcher->matches($arguments[$index]);

            $isMatch = $isMatch && $matcherIsMatch;
            $matcherMatches[] = $matcherIsMatch;
            $argumentMatches[] = $matcherIsMatch;
            ++$index;
        }

        for (; $index < $argumentCount; ++$index) {
            $argumentMatches[] = false;
            $isMatch = false;
        }

        return new MatcherResult($isMatch, $matcherMatches, $argumentMatches);
    }
92936
public function setMatchTypes($matchTypes)
	{
		if (is_array($matchTypes)) {
			$this->matchTypes = $matchTypes;
		} else {
			foreach ( (array) $matchTypes as $key => $matchType) {
				$this->matchTypes[$key] = $matchType;
			}
		}
	}
820274
private function getParametersFromMatchString($matchString, $pattern)
    {
        $parameters = [];
        $parameterIndices = $this->getMatchStringParameterIndices($matchString, $pattern);

        foreach ($parameterIndices as $position => $parameterIndex) {
            $start = $parameterIndex['index'];
            $foo = $position + 1;

            if (isset($parameterIndices[$position + 1])) {
                $length = $parameterIndices[$foo]['index'] - $start - strlen($parameterIndices[$foo]['prefix']);

                $parameters[] = substr($matchString, $start, $length);
            } else {
                $parameter = substr($matchString, $start);

                if (!empty($parameter)) {
                    $parameters[] = $parameter;
                }
            }
        }

        return $parameters;
    }
328681
public function getAll($termType) {
        $arr = array();
        foreach ($this->terms as $term) {
            if ((string)$term->getTermType() === $termType) {
                array_push($arr, $term);
            }
        }
        return $arr;
    }
1305322
public function getMatcherConfiguration($matcherClass)
    {
        if ( ! array_key_exists($matcherClass, $this->configuration["matcher_settings"])) {
            return null;
        }

        $configuration = $this->configuration["matcher_settings"][$matcherClass];

        unset($this->configuration["matcher_settings"][$matcherClass]);

        return $configuration;
    }
1064656
private function createLinkOrSeeTagFromRegexMatch(array $match)
    {
        list($completeMatch, $tagName, $tagContent) = $match;

        return Tag::createInstance('@' . $tagName . ' ' . $tagContent);
    }
253844
private function check($matchType, $type, $name, $args)
    {
        $value = array_shift($args);

        if (!isset($args[0])) {
          $args[0] = ['rule' => Policy::ANY];
        }

        // see what other options we've been given
        if (is_string($args[0]) && ($args[0] === Policy::ANY || $args[0] === Policy::ALL) ) {
          $args['rule'] = $args[0];
          unset($args[0]);
        } elseif (is_array($args[0])) {
          $args = $args[0];
        }

        $this->checks[$type][] = new Check($matchType, $value, $args);
    }
1233350
public function findTermTaxonomies($request, $match)
    {
        $content = Pluf_Shortcuts_GetObjectOr404('CMS_Content', $match['parentId']);
        $tt = new CMS_TermTaxonomy();
        Pluf::loadFunction('Pluf_Shortcuts_GetAssociationTableName');
        $assoc = $tt->_con->pfx . Pluf_Shortcuts_GetAssociationTableName('CMS_Content', 'CMS_TermTaxonomy');
        $tt_table = $tt->_con->pfx . $tt->_a['table'];
        Pluf::loadFunction('Pluf_Shortcuts_GetForeignKeyName');
        $tt_fk = Pluf_Shortcuts_GetForeignKeyName('CMS_TermTaxonomy');
        $content_fk = Pluf_Shortcuts_GetForeignKeyName('CMS_Content');
        $tt->_a['views'] = array(
            'join_content' => array(
                'join' => 'LEFT JOIN ' . $assoc . ' ON ' . $tt_table . '.id=' . $tt_fk
            )
        );
        $sql = new Pluf_SQL('`' . $content_fk . '`=%s', array(
            $content->id
        ));
        $builder = new Pluf_Paginator_Builder($tt);
        return $builder->setRequest($request)
            ->setView('join_content')
            ->setWhereClause($sql)
            ->build();
    }
610058
static public function contentTypeToSuffix($contentType)
    {
        $types = self::byContentType();
        return isset($types[$contentType]) ? $types[$contentType]['suffix'] : null;
    }
849797
public function getExtensionByType($type)
    {
        if ($this->isValidType($type)) {
            return $this->mime[$type];
        } else {
            throw new RuntimeException(sprintf('Invalid type "%s" supplied', $type));
        }
    }
123556
final public function sqlLikeSearch(
        string $fieldName,
        string $searchTerms,
        bool $matchAnyTerm = true,
        string $termsSeparator = ' '
    ): string {
        return implode(
            ($matchAnyTerm) ? ' OR ' : ' AND ',
            array_map(function (string $term) use ($fieldName): string {
                return '(' . $this->sqlLike($fieldName, $term) . ')';
            }, array_unique(array_filter(explode($termsSeparator, $searchTerms) ?: [])))
        );
    }
1276826
public static function anInstanceOf($type): Matcher
    {
        $container = self::$globals::$container;

        return $container->matcherFactory->anInstanceOf($type);
    }
208630
private function matchesIdAndEntityType()
    {
        $expr = $this->connection->getExpressionBuilder();

        return $expr->andX(
            $expr->eq('entity_id', ':entity_id'),
            $expr->eq('entity_type', ':entity_type')
        );
    }
826207
protected function resolveType($type)
    {
        $types = $this->billTypes;

        // Type is a normal key
        if (isset($types[$type])) {
            return $type;
        }

        // Type is a title of type instead of its key
        if (in_array($type, $types, true)) {
            return array_search($type, $types, true);
        }

        // Assuming only second part is passed. Match from the end
        $foundKey = null;
        foreach ($types as $key => $title) {
            list(, $name) = explode(',', $key);
            if ($name === $type) {
                if ($foundKey !== null) {
                    throw new InvalidValueException('Payment type "' . $type . '" is ambiguous');
                }

                $foundKey = $key;
            }
        }

        if ($foundKey) {
            return $foundKey;
        }

        throw new InvalidValueException('Payment type "' . $type . '" is not recognized');
    }
424657
private function match(int $type)
    {
        if (! $this->lexer->isNextToken($type)) {
            $this->syntaxError();
        }

        $value = $this->lexer->lookahead['value'];
        $this->lexer->moveNext();

        return $value;
    }