original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Resolve middleware queue
  
  @param $middlewares
  @return \Closure
docstring_tokens: Resolve middleware queue