Gets the possible additional arguments from the route match.
@param  array $match An AltoRouter answer
@return array
420921
private function getArgumentsFromMatch($match = array())
    {
        if (is_array($match['params']) && count($match['params'])) {
            $params = $match['params'];
            return is_array($params) ? $params : array($params);
        }

        return array();
    }
729114
private function match(string $url): ?array
    {
        $path = \trim(\explode('?', $url, 2)[0], self::SEPARATOR_TRIM);

        $key = $this->prefix . '_' . $path;
        $result = self::optimizeGet($key);
        if (!empty($result)) {
            return $result;
        }

        $parts = \explode('/', $path);
        if (!isset($parts[1]) && $parts[0] === '') {
            $parts = [];
        }

        $params = [];
        $current = $this->routes;
        foreach ($parts as $v) {
            if (isset($current['children'][$v])) {
                $current = $current['children'][$v];
                continue;
            }

            if ($current['regexps'] !== []) {
                foreach ($current['regexps'] as $regexp => $route) {
                    if (\preg_match($regexp, $v)) {
                        $current = $route;
                        $params[$current['name']] = $v;
                        continue 2;
                    }
                }
            }

            if (!isset($current['others'])) {
                return null;
            }

            $current = $current['others'];
            $params[$current['name']] = $v;
        }

        $result = [
            'methods' => $current['methods'],
            'route' => $current['route'],
            'params' => $params,
        ];

        self::optimizeSet($key, $result);

        return $result;
    }
467742
public function get($match = [], $except = [])
    {
        foreach ($this->repositories as $repository) {

            foreach ($repository->get($match, $except) as $route) {
                $this->routes->push($route);
            }
        }

        return $this->routes;
    }
1080957
public static function identifier(array $match)
    {
        $name = $match[1]; // this should be the matched name.
        if($name === '*') {
            return '(?P<pathInfo>.*)';
        }
        $type = '[-_0-9a-zA-Z]';
        if (strpos($name, ':') !== false) {
            list($name, $type) = explode(':', $name, 2);
            if(isset(self::$types[$type])) {
                $type = self::$types[$type];
            }
        }
        return "(?P<{$name}>{$type}+)";
    }
1169992
public function getArgs($path)
    {
        if (!$this->isParsed()) $this->parse();
        
        $data = [];
        $args = [];
        preg_match('#'.$this->parsedRoute.'$#', $path, $data);


        foreach ($data as $name => $value) {
            if (is_int($name)) continue;
            $args[$name] = $value;
        }

        return $args;
    }
1311040
private function generateNegation($match)
    {
        $match = str_split($match);
        $chars = str_split($this->getChars());
        foreach ($match as $negVal) {
            if (($key = array_search($negVal, $chars)) !== false) {
                if ($negVal == '\\') {
                    continue;
                }
                unset($chars[$key]);
            }
        }

        return implode('', $chars);
    }
852430
protected function replace(array $match): string
    {
        $character = $this->getOption('character');
        $mention = Str::title(str_replace($character, '', trim($match[0])));

        $route = config('mentions.pools.' . $this->getOption('pool') . '.route');

        $link = $route . $mention;

        return " [{$character}{$mention}]($link)";
    }
284920
private function orElseMatch(Match $match)
    {
        return array_key_exists($this->subject->getName(), $this->matches)
            ? $this->matches[$this->subject->getName()]->get()
            : $match->get();
    }
368393
private function getControllerFromMatch($match = array())
    {
        try {
            $target = explode("#", $match["target"]);
            return Controller::factory($target[0]);
        } catch (Exception $e) {
            // The controller did not exist, we don't care at this point.
            // We'll just ignore the route.
        }

        return Controller::factory("App");
    }
946687
private function expandMatch(array $matches)
    {
        static $rfc1738to3986 = array(
            '+'   => '%20',
            '%7e' => '~'
        );

        $parsed = self::parseExpression($matches[1]);
        $replacements = array();

        $prefix = $parsed['operator'];
        $joiner = $parsed['operator'];
        $useQueryString = false;
        if ($parsed['operator'] == '?') {
            $joiner = '&';
            $useQueryString = true;
        } elseif ($parsed['operator'] == '&') {
            $useQueryString = true;
        } elseif ($parsed['operator'] == '#') {
            $joiner = ',';
        } elseif ($parsed['operator'] == ';') {
            $useQueryString = true;
        } elseif ($parsed['operator'] == '' || $parsed['operator'] == '+') {
            $joiner = ',';
            $prefix = '';
        }

        foreach ($parsed['values'] as $value) {

            if (!array_key_exists($value['value'], $this->variables) || $this->variables[$value['value']] === null) {
                continue;
            }

            $variable = $this->variables[$value['value']];
            $actuallyUseQueryString = $useQueryString;
            $expanded = '';

            if (is_array($variable)) {

                $isAssoc = $this->isAssoc($variable);
                $kvp = array();
                foreach ($variable as $key => $var) {

                    if ($isAssoc) {
                        $key = rawurlencode($key);
                        $isNestedArray = is_array($var);
                    } else {
                        $isNestedArray = false;
                    }

                    if (!$isNestedArray) {
                        $var = rawurlencode($var);
                        if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
                            $var = $this->decodeReserved($var);
                        }
                    }

                    if ($value['modifier'] == '*') {
                        if ($isAssoc) {
                            if ($isNestedArray) {
                                // Nested arrays must allow for deeply nested structures
                                $var = strtr(http_build_query(array($key => $var)), $rfc1738to3986);
                            } else {
                                $var = $key . '=' . $var;
                            }
                        } elseif ($key > 0 && $actuallyUseQueryString) {
                            $var = $value['value'] . '=' . $var;
                        }
                    }

                    $kvp[$key] = $var;
                }

                if (empty($variable)) {
                    $actuallyUseQueryString = false;
                } elseif ($value['modifier'] == '*') {
                    $expanded = implode($joiner, $kvp);
                    if ($isAssoc) {
                        // Don't prepend the value name when using the explode modifier with an associative array
                        $actuallyUseQueryString = false;
                    }
                } else {
                    if ($isAssoc) {
                        // When an associative array is encountered and the explode modifier is not set, then the
                        // result must be a comma separated list of keys followed by their respective values.
                        foreach ($kvp as $k => &$v) {
                            $v = $k . ',' . $v;
                        }
                    }
                    $expanded = implode(',', $kvp);
                }

            } else {
                if ($value['modifier'] == ':') {
                    $variable = substr($variable, 0, $value['position']);
                }
                $expanded = rawurlencode($variable);
                if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
                    $expanded = $this->decodeReserved($expanded);
                }
            }

            if ($actuallyUseQueryString) {
                if (!$expanded && $joiner != '&') {
                    $expanded = $value['value'];
                } else {
                    $expanded = $value['value'] . '=' . $expanded;
                }
            }

            $replacements[] = $expanded;
        }

        $ret = implode($joiner, $replacements);
        if ($ret && $prefix) {
            return $prefix . $ret;
        }

        return $ret;
    }
470109
protected function getParameter($matches)
    {
        $params = $this->parseAttr($matches[3]);

        if( ! is_array($params))
        {
            $params = [$params];
        }

        return $params;
    }
219808
public function getRequiredParams(): array
	{
		$regex = '/\[[^\[]+?\]/';
		$path = $this->getPath();

		while (preg_match($regex, $path)) {
			$path = preg_replace($regex, '', $path);
		}

		$required = [];

		preg_replace_callback('/<(\w+)>/', function ($item) use (&$required) {
			$required[] = end($item);
		}, $path);

		return $required;
	}
37013
public function getArguments(string $uri, $callback = null): array
    {
        $values = [];
        $pattern = '/^' . $this->regex . '$/';
        preg_match_all($pattern, $uri, $matches);
        $matchCount = count($matches);
        for ($i = 1; $i < $matchCount; ++$i) {
            $values[] = (!is_null($callback))
                ? (new Callback($callback))->execute($matches[$i][0])
                : $matches[$i][0];
        }
        $arguments = [];
        $i = 0;
        foreach ($this->parameters as $parameter) {
            $arguments[$parameter] = $values[$i];
            ++$i;
        }
        return $arguments;
    }
1147484
protected function _replaceUrlCallback(array $match)
    {
        $assetPath = str_replace(Router::fullBaseUrl(), '', $match[2]);
        $assetPath = trim(FS::clean($assetPath, '/'), '/');
        $appDir    = trim(FS::clean(APP_ROOT, '/'), '/');

        list ($isPlugin, $assetPath) = $this->_getPlgAssetUrl($assetPath);

        if (!$isPlugin) {
            $assetPath = str_replace($appDir, '', $assetPath);
        }

        $assetPath = str_replace(Configure::read('App.webroot'), '', $assetPath);
        $assetPath = FS::clean($assetPath, '/');

        if ($isPlugin) {
            return $this->_normalizePlgAssetUrl($assetPath);
        }

        return $this->_getAssetUrl($assetPath);
    }
59010
private function getControllerFromDynamicMatch($match = array())
    {
        try {
            if (array_key_exists("controller", $match["params"])) {
                return Controller::factory($match["params"]["controller"]);
            }
        } catch (Exception $e) {
            // The controller did not exist, we don't care at this point.
            // We'll just ignore the route.
        }

        return Controller::factory("App");
    }
502186
protected function buildRequirements(array $matches)
    {
        $result = [];
        foreach ($matches as $match) {
            list($key, $regexp) = $this->splitSegment($match[3]);
            $result[$key] = $regexp . ($match[1] == '(' ? '*' : '+');
        }

        return $result;
    }
349847
public function get($match = [], $except = [])
    {
        return $this->routes->filterMatch($match)
            ->filterExcept($except)
            ->values();
    }