src/Middleware/Dispatcher.php
protected function callback($middleware, ResponseInterface $response)
    {
        $middleware = is_string($middleware) ? new $middleware : $middleware;

        $callback = function ($request, $next = null) use ($middleware) {
            return $middleware($request, $next);
        };

        if ($this->approach($middleware) == self::SINGLE_PASS) {
            $callback = function ($request, $next = null) use ($middleware, $response) {
                return $middleware($request, $response, $next);
            };
        }

        return $callback;
    }
protected function callback($middleware, ResponseInterface $response)
    {
        $middleware = is_string($middleware) ? new $middleware : $middleware;

        $callback = function ($request, $next = null) use ($middleware) {
            return $middleware($request, $next);
        };

        if ($this->approach($middleware) == self::SINGLE_PASS) {
            $callback = function ($request, $next = null) use ($middleware, $response) {
                return $middleware($request, $response, $next);
            };
        }

        return $callback;
    }
Returns the middleware as a single pass callable.

@param  \Closure|object|string              $middleware
@param  \Psr\Http\Message\ResponseInterface $response
@return \Closure