Get all matches.

@param string $line
@param bool   $matchCommentOnly

@return string[]|null
339074
private function getMatches($line, $matchCommentOnly = false)
    {
        if (preg_match($this->regex, $line, $matches)) {
            if (!empty($matches['tag2'])) {
                $matches['tag'] = $matches['tag2'];
                $matches['hint'] = $matches['hint2'];
            }

            return $matches;
        }
        if ($matchCommentOnly && preg_match($this->regexCommentLine, $line, $matches)) {
            $matches['tag'] = null;
            $matches['var'] = '';
            $matches['hint'] = '';

            return $matches;
        }
    }
976394
@NotNull
  List<RuleMatch> getFilteredExtensionMatches(List<RuleMatch> matches, List<RemoteRuleMatch> extensionMatches) {
    List<RuleMatch> filteredExtMatches = new ArrayList<>();
    for (RemoteRuleMatch extensionMatch : extensionMatches) {
      if (!extensionMatch.isTouchedByOneOf(matches)) {
        AnalyzedSentence sentence = new AnalyzedSentence(new AnalyzedTokenReadings[]{});
        HiddenRule hiddenRule = new HiddenRule(extensionMatch.getLocQualityIssueType().orElse(null), extensionMatch.estimatedContextForSureMatch());
        RuleMatch hiddenRuleMatch = new RuleMatch(hiddenRule, sentence, extensionMatch.getErrorOffset(),
                extensionMatch.getErrorOffset()+extensionMatch.getErrorLength(), "(hidden message)");
        filteredExtMatches.add(hiddenRuleMatch);
      }
    }
    return filteredExtMatches;
  }
1359020
protected function getMatchers()
    {
        // @todo change to dynamic
        return [
            Matchers\DateMatch::class,
            Matchers\DigitMatch::class,
            Matchers\L33tMatch::class,
            Matchers\RepeatMatch::class,
            Matchers\SequenceMatch::class,
            Matchers\SpatialMatch::class,
            Matchers\YearMatch::class,
            Matchers\DictionaryMatch::class,
        ];
    }
290657
protected function findMatchingCookies(callable $match)
    {
        $cookies = [];

        foreach ($this->cookies as $cookie) {
            if ($match($cookie)) {
                $cookies[] = $cookie;
            }
        }

        return $cookies;
    }
1163146
protected function match($code, $line)
    {
        foreach ($this->patterns as $token => $pattern) {
            if (!preg_match($pattern, $code, $matches)) {
                continue;
            }

            return new Token($token, $matches[1], $line);
        }

        return false;
    }
579241
public function matchAll($pattern, $subject, &$matches = null, $flags = PREG_PATTERN_ORDER, $offset = 0)
    {
        return $this->sandbox->run('preg_match_all', [$pattern, $subject, &$matches, $flags, $offset], $this->throw);
    }
920083
protected function getMatcher($matcherIdentifier)
    {
        if ($this->container->has($matcherIdentifier)) {
            return $this->container->get($matcherIdentifier);
        }

        return parent::getMatcher($matcherIdentifier);
    }
1164329
private function getLinesNumbers(string $line)
    {
        $matches = [];
        preg_match('/@@ -(.*) \+(.*) @@?(.*)/', $line, $matches);
        if (!strpos($matches[1], ',')) {
            // one line
            $this->originStartLine = $matches[1];
            $this->originEndLine = $matches[1];
        } else {
            list($this->originStartLine, $this->originEndLine) = explode(',', $matches[1]);
        }

        if (!strpos($matches[2], ',')) {
            // one line
            $this->destStartLine = $matches[2];
            $this->destEndLine = $matches[2];
        } else {
            list($this->destStartLine, $this->destEndLine) = explode(',', $matches[2]);
        }
    }
1095080
def find_lines(self, linespec):
        """"""
        res = []
        linespec += ".*"
        for line in self.cfg:
            match = re.search(linespec, line)
            if match:
                res.append(match.group(0))
        return res
548674
private function matchByRegex(string $pattern, string $path): array
    {
        $isPatternMatched = (bool) \preg_match_all("~^$pattern$~", $path, $matches);

        if (!$isPatternMatched) {
            return [$isPatternMatched, []];
        }

        foreach ($matches as $k => $match) {
            $match = \array_shift($match);
            if (\is_int($k) || empty($match)) {
                unset($matches[$k]);
                continue;
            }
            $matches[$k] = $match;
        }

        return [$isPatternMatched, $matches];
    }
481039
protected function match(string $line, int $lineNumber, int $offset) : array
    {
        $restLine = substr($line, $offset);

        foreach ($this->terminals as $pattern => $name) {
            if (preg_match($pattern, $restLine, $matches)) {
                return [
                    $name,
                    $matches,
                ];
            }
        }

        throw new SyntaxErrorException(sprintf('Lexer error: unable to parse "%s" at line %s.', $line, $lineNumber));
    }
615871
public function getMatchStatus($matchId) {
        $endpoint = vsprintf('/match/%s', $matchId);
        $requestData = $this->getDefaultRequestData('query', []);

        return $this->sendRequest($endpoint, $requestData, self::HTTP_METHOD_GET);
    }
135884
private function getMatchArrayFromEnvironment($matchString)
    {
        $matches = array();
        foreach (explode(',', $matchString) as $etag) {
            $matches[] = trim($etag, '" ');
        }

        return $matches;
    }
821266
private function getMatches()
    {

        if (empty($this->urlPart) || !$this->validate($this->urlPart)) {
            return [];
        }

        if (!preg_match($this->_current_pattern, $this->urlPart, $matches)) {
            return [];
        }

        return $matches;
    }
1321843
private function getArgumentsFromDynamicMatch($match = array())
    {
        if (array_key_exists("params", $match["params"])) {
            $params = $match["params"]["params"];
            return is_array($params) ? $params : array($params);
        }

        return array();
    }
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;
    }
426714
public function find($regexpPattern = '.*', $sort = false)
    {
        list(, $files) = $this->read($sort);

        return array_values(preg_grep('/^' . $regexpPattern . '$/i', $files));
    }