protected function matchDynamicRoute(string $path, string $method): array
    {
        $first = \strstr(\ltrim($path, '/'), '/', true);
        $fKey  = $first ? $method . ' ' . $first : '';

        // It is a regular dynamic route(the first node is 1th level index key).
        if ($fKey && isset($this->regularRoutes[$fKey])) {
            /** @var Route $route */
            foreach ($this->regularRoutes[$fKey] as $route) {
                // Check path start string
                $pathStart = $route->getPathStart();
                if (\strpos($path, $pathStart) !== 0) {
                    continue;
                }

                $result = $route->matchRegex($path);
                if ($result[0]) {
                    return [self::FOUND, $path, $route->copyWithParams($result[1])];
                }
            }
        }

        // It is a irregular dynamic route
        // if ($routeList = $this->vagueRoutes[$method] ?? false) {
        if (isset($this->vagueRoutes[$method])) {
            foreach ($this->vagueRoutes[$method] as $route) {
                $result = $route->matchRegex($path);
                if ($result[0]) {
                    return [self::FOUND, $path, $route->copyWithParams($result[1])];
                }
            }
        }

        return [self::NOT_FOUND, $path, null];
    }
protected function matchDynamicRoute(string $path, string $method): array
    {
        $first = \strstr(\ltrim($path, '/'), '/', true);
        $fKey  = $first ? $method . ' ' . $first : '';

        // It is a regular dynamic route(the first node is 1th level index key).
        if ($fKey && isset($this->regularRoutes[$fKey])) {
            /** @var Route $route */
            foreach ($this->regularRoutes[$fKey] as $route) {
                // Check path start string
                $pathStart = $route->getPathStart();
                if (\strpos($path, $pathStart) !== 0) {
                    continue;
                }

                $result = $route->matchRegex($path);
                if ($result[0]) {
                    return [self::FOUND, $path, $route->copyWithParams($result[1])];
                }
            }
        }

        // It is a irregular dynamic route
        // if ($routeList = $this->vagueRoutes[$method] ?? false) {
        if (isset($this->vagueRoutes[$method])) {
            foreach ($this->vagueRoutes[$method] as $route) {
                $result = $route->matchRegex($path);
                if ($result[0]) {
                    return [self::FOUND, $path, $route->copyWithParams($result[1])];
                }
            }
        }

        return [self::NOT_FOUND, $path, null];
    }
protected function matchDynamicRoute ( string $ path , string $ method ) : array { $ first = \ strstr ( \ ltrim ( $ path , '/' ) , '/' , true ) ; $ fKey = $ first ? $ method . ' ' . $ first : '' ; // It is a regular dynamic route(the first node is 1th level index key). if ( $ fKey && isset ( $ this -> regularRoutes [ $ fKey ] ) ) { /** @var Route $route */ foreach ( $ this -> regularRoutes [ $ fKey ] as $ route ) { // Check path start string $ pathStart = $ route -> getPathStart ( ) ; if ( \ strpos ( $ path , $ pathStart ) !== 0 ) { continue ; } $ result = $ route -> matchRegex ( $ path ) ; if ( $ result [ 0 ] ) { return [ self :: FOUND , $ path , $ route -> copyWithParams ( $ result [ 1 ] ) ] ; } } } // It is a irregular dynamic route // if ($routeList = $this->vagueRoutes[$method] ?? false) { if ( isset ( $ this -> vagueRoutes [ $ method ] ) ) { foreach ( $ this -> vagueRoutes [ $ method ] as $ route ) { $ result = $ route -> matchRegex ( $ path ) ; if ( $ result [ 0 ] ) { return [ self :: FOUND , $ path , $ route -> copyWithParams ( $ result [ 1 ] ) ] ; } } } return [ self :: NOT_FOUND , $ path , null ] ; }
is a dynamic route, match by regexp
@param string $path
@param string $method
@return array
[
status,
path,
Route(object) -> it's a raw Route clone.
]
is a dynamic route match by regexp