When a rute matches, save matched query string and matched query array.

@param array $matches    Matches coming from regex compare matched rule to url
@param string $query     Query part of the matched rule
430525
private function setMatchedQuery( $matches = [ ], $query = '' ) {
        if ( ! is_null( $this->matched_rule ) ) {
            $mathed = \WP_MatchesMapRegex::apply( preg_replace( "!^.+\?!", '', $query ), $matches );
            $this->matched_query = addslashes( $mathed );
            parse_str( $this->matched_query, $this->perma_q_vars );
            if ( '404' === $this->error ) $this->error = NULL;
        }
    }
555890
private function setQueryParameters($query)
    {
        // escaping
        $query = addslashes($query);

        $queryParameters = array_filter(explode('&', $query));

        array_map([$this, 'appendQueryParameter'], $queryParameters);
    }
208090
private function _interpolateCallback($matches)
	{
		$key = $matches[1];

		if (!isset($this->_interpolate[$key]))
		{
			throw new Exception(sprintf(
				"%s route needs '%s' value for '%s'",
				$this->_name,
				$key,
				$this->_template
			));
		}

		// percent encoding as per section 3.2 of URI Templates draft 9 July 2007,
		// and section 2.1 of http://www.faqs.org/rfcs/rfc3986
		return rawurlencode($this->_interpolate[$key]);
	}
221723
public function withQueryParams(array $query)
    {
        $params = $this->getQueryParams();

        foreach ($query as $key => $value) {
            $params[$key] = $value;
        }

        $this->queryParams = $params;
    }
191035
public function matches($request, $queries = [])
    {
        $this->setQueries($queries);

        if (! $request && $this->isHomePath()) {
            return true;
        }

        if ($matches = preg_match("@^{$this->getPathMock($queries)}$@", $request)) {
            if ($this->rulesNotPassed()) {
                return false;
            }
        }

        return (bool) $matches;
    }
307332
protected function countBindingsFromQuery(string $query)
    {
        preg_match_all($this->getBindingPattern(), $query, $matches);

        return count($matches[0] ?? []);
    }
140718
protected function decodeMatches(array $matches): string
    {
        if (1 === preg_match(static::REGEXP_PREVENTS_DECODING, $matches[0])) {
            return strtoupper($matches[0]);
        }

        return rawurldecode($matches[0]);
    }
386246
private function _filter(array $matches)
    {
        $filters = explode('|', $matches[0]);
        $var = $filters[0];
        unset($filters[0]);
        foreach ($filters as $filter) {
            $params = explode(':', $filter);
            $filterName = $params[0];
            unset($params[0]);
            $array = 'array(';
            foreach ($params as $param) {
                $array .= $param . ',';
            }
            $array = trim($array, ',') . ')';
            $var = 'getFilter(\'' . $filterName . '\')->setOptions(' . $array . ')->filter(' . $var . ')';
        }
        return $var;
    }
747301
private function applyConditions($matches)
    {
        foreach ($this->conditions as $condition) {
            $matches = $this->filter($matches, $condition);
        }

        return $matches;
    }
942726
public function scopeWithTags($query, $tags)
    {
        $tags = $this->makeTagsArray($tags);

        foreach ($tags as $tag)
            $this->scopeWithTag($query, $tag);

        return $query;
    }
1328041
private function applyOrdering($matches)
    {
        foreach ($this->ordering as $ordering) {
            usort(
                $matches,
                function ($aRow, $bRow) use ($ordering) {
                    $a = $aRow[$ordering['column']];
                    $b = $bRow[$ordering['column']];

                    return $ordering['direction'] * ($a == $b ? 0 : ($a < $b ? -1 : 1));
                }
            );
        }

        return $matches;
    }
642475
public function match(string $query, string $method = null)
    {
        $this->arguments = [];
        $this->methodMatched = null;
        $this->pathMatched = null;

        $matcher = new RouteMatcher();
        $res = $matcher->match(
            $this->mount,
            $this->path,
            $this->getAbsolutePath(),
            $query,
            $this->method,
            $method
        );
        $this->arguments = $matcher->arguments;
        $this->methodMatched = $matcher->methodMatched;
        $this->pathMatched = $matcher->pathMatched;

        return $res;
    }
138511
public function addFilterMatch($match)
    {
        $match = (!is_array($match)) ? array($match) : $match;
        foreach ($match as $filter) {
            $this->filterMatches[] = $filter;
        }
    }
908671
private function handleMatchedRouterAnswer($match)
    {
        $this->controller   = $this->getControllerFromMatch($match);
        $this->action       = $this->getActionFromMatch($match);
        $this->arguments    = $this->getArgumentsFromMatch($match);
    }
234847
public function addMatchers(array $matchers)
    {
        $this->matchers = \array_merge($this->matchers, $matchers);

        if (isset($this->autoCompleter)) {
            $this->addMatchersToAutoCompleter($matchers);
        }
    }
1120140
protected function query($query, ...$params)
    {
        $saveParams = array_map([$this, 'quote'], $params);

        $baseSql = str_replace('{table}', $this->table, $query);
        $sql = vsprintf($baseSql, $saveParams);

        $ret = $this->server->query($sql);

        if ($ret === false) {
            trigger_error($this->server->error . " $sql", E_USER_NOTICE);
        }

        return $ret;
    }
887173
function onQuery( $query, $params = array() ) {

        if ( is_callable( $this->queryCallback ) ) {

            call_user_func( $this->queryCallback, $query, $params );

        }

    }