public function resolve($middlewares)
    {
        $last = function ($request, $response) {
            // no op
        };
        while ($middleware = array_pop($middlewares)) {
            if (is_object($middleware)) {
                if (method_exists($middleware, '__invoke')) {
                    $middleware = [$middleware, '__invoke'];
                }
            }

            if (!is_callable($middleware)) {
                throw new \InvalidArgumentException('Middle needs to be callable');
            }

            $last = function () use ($middleware, $last) {
                $args = func_get_args();
                $args[] = $last;
                return call_user_func_array($middleware, $args);
            };
        }
        return $last;
    }
public function resolve($middlewares)
    {
        $last = function ($request, $response) {
            // no op
        };
        while ($middleware = array_pop($middlewares)) {
            if (is_object($middleware)) {
                if (method_exists($middleware, '__invoke')) {
                    $middleware = [$middleware, '__invoke'];
                }
            }

            if (!is_callable($middleware)) {
                throw new \InvalidArgumentException('Middle needs to be callable');
            }

            $last = function () use ($middleware, $last) {
                $args = func_get_args();
                $args[] = $last;
                return call_user_func_array($middleware, $args);
            };
        }
        return $last;
    }
public function resolve ( $ middlewares ) { $ last = function ( $ request , $ response ) { // no op } ; while ( $ middleware = array_pop ( $ middlewares ) ) { if ( is_object ( $ middleware ) ) { if ( method_exists ( $ middleware , '__invoke' ) ) { $ middleware = [ $ middleware , '__invoke' ] ; } } if ( ! is_callable ( $ middleware ) ) { throw new \ InvalidArgumentException ( 'Middle needs to be callable' ) ; } $ last = function ( ) use ( $ middleware , $ last ) { $ args = func_get_args ( ) ; $ args [ ] = $ last ; return call_user_func_array ( $ middleware , $ args ) ; } ; } return $ last ; }
Resolve middleware queue

@param $middlewares
@return \Closure
Resolve middleware queue