src/Application/HttpApplication.php
public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
    {
        /** @var Route $route */
        $route = $this->router->find(
            $request->getMethod(),
            $request->getUri()->getPath()
        );

        $controller = $route->getController();

        if ($request instanceof ServerRequest) {
            $request = $request->withAttributes($route->getAttributes());
        }

        if (is_string($controller) &&
            class_exists($controller) &&
            is_subclass_of($controller, Controller::class)
        ) {
            /** @var Controller $instance */
            $instance = $this->resolver->resolve($controller);
            return $instance($request);
        }

        if (is_callable($controller)) {
            $response = $controller($request);
            if (!$response instanceof ResponseInterface) {
                throw ControllerException::forInvalidReturnValue();
            }

            return $response;
        }

        throw ControllerException::forMissingController($route->getPath());
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
    {
        /** @var Route $route */
        $route = $this->router->find(
            $request->getMethod(),
            $request->getUri()->getPath()
        );

        $controller = $route->getController();

        if ($request instanceof ServerRequest) {
            $request = $request->withAttributes($route->getAttributes());
        }

        if (is_string($controller) &&
            class_exists($controller) &&
            is_subclass_of($controller, Controller::class)
        ) {
            /** @var Controller $instance */
            $instance = $this->resolver->resolve($controller);
            return $instance($request);
        }

        if (is_callable($controller)) {
            $response = $controller($request);
            if (!$response instanceof ResponseInterface) {
                throw ControllerException::forInvalidReturnValue();
            }

            return $response;
        }

        throw ControllerException::forMissingController($route->getPath());
    }
Handles request flow process.

@see MiddlewareInterface::process()

@param ServerRequestInterface $request
@param RequestHandlerInterface $next
@return ResponseInterface