src/Leevel/Router/MiddlewareParser.php
protected function normalizeMiddleware(array $middlewares, string $method): array
    {
        $middlewares = array_map(function ($item) use ($method) {
            if (false === strpos($item, ':')) {
                $realClass = $item;
            } else {
                list($realClass) = explode(':', $item);
            }

            // ignore group like `web` or `api`
            if (false !== strpos($realClass, '\\') && !class_exists($realClass)) {
                throw new InvalidArgumentException(
                    sprintf('Middleware %s was not found.', $realClass)
                );
            }

            if (!method_exists($realClass, $method)) {
                return false;
            }

            if (false === strpos($item, ':')) {
                return $item.'@'.$method;
            }

            return str_replace(':', '@'.$method.':', $item);
        }, $middlewares);

        $middlewares = array_values(array_unique(array_filter($middlewares)));

        return $middlewares;
    }
protected function normalizeMiddleware(array $middlewares, string $method): array
    {
        $middlewares = array_map(function ($item) use ($method) {
            if (false === strpos($item, ':')) {
                $realClass = $item;
            } else {
                list($realClass) = explode(':', $item);
            }

            // ignore group like `web` or `api`
            if (false !== strpos($realClass, '\\') && !class_exists($realClass)) {
                throw new InvalidArgumentException(
                    sprintf('Middleware %s was not found.', $realClass)
                );
            }

            if (!method_exists($realClass, $method)) {
                return false;
            }

            if (false === strpos($item, ':')) {
                return $item.'@'.$method;
            }

            return str_replace(':', '@'.$method.':', $item);
        }, $middlewares);

        $middlewares = array_values(array_unique(array_filter($middlewares)));

        return $middlewares;
    }
格式化中间件.

@param array  $middlewares
@param string $method

@return array