original_string: public static function history(&$container)
      {
          if (!is_array($container) && !$container instanceof \ArrayAccess) {
              throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
          }
  
          return function (callable $handler) use (&$container) {
              return function ($request, array $options) use ($handler, &$container) {
                  return $handler($request, $options)->then(
                      function ($value) use ($request, &$container, $options) {
                          $container[] = [
                              'request'  => $request,
                              'response' => $value,
                              'error'    => null,
                              'options'  => $options
                          ];
                          return $value;
                      },
                      function ($reason) use ($request, &$container, $options) {
                          $container[] = [
                              'request'  => $request,
                              'response' => null,
                              'error'    => $reason,
                              'options'  => $options
                          ];
                          return \GuzzleHttp\Promise\rejection_for($reason);
                      }
                  );
              };
          };
      }
code: public static function history(&$container)
      {
          if (!is_array($container) && !$container instanceof \ArrayAccess) {
              throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
          }
  
          return function (callable $handler) use (&$container) {
              return function ($request, array $options) use ($handler, &$container) {
                  return $handler($request, $options)->then(
                      function ($value) use ($request, &$container, $options) {
                          $container[] = [
                              'request'  => $request,
                              'response' => $value,
                              'error'    => null,
                              'options'  => $options
                          ];
                          return $value;
                      },
                      function ($reason) use ($request, &$container, $options) {
                          $container[] = [
                              'request'  => $request,
                              'response' => null,
                              'error'    => $reason,
                              'options'  => $options
                          ];
                          return \GuzzleHttp\Promise\rejection_for($reason);
                      }
                  );
              };
          };
      }
code_tokens: public static function history ( & $ container ) { if ( ! is_array ( $ container ) && ! $ container instanceof \ ArrayAccess ) { throw new \ InvalidArgumentException ( 'history container must be an array or object implementing ArrayAccess' ) ; } return function ( callable $ handler ) use ( & $ container ) { return function ( $ request , array $ options ) use ( $ handler , & $ container ) { return $ handler ( $ request , $ options ) -> then ( function ( $ value ) use ( $ request , & $ container , $ options ) { $ container [ ] = [ 'request' => $ request , 'response' => $ value , 'error' => null , 'options' => $ options ] ; return $ value ; } , function ( $ reason ) use ( $ request , & $ container , $ options ) { $ container [ ] = [ 'request' => $ request , 'response' => null , 'error' => $ reason , 'options' => $ options ] ; return \ GuzzleHttp \ Promise \ rejection_for ( $ reason ) ; } ) ; } ; } ; }
docstring: Middleware that pushes history data to an ArrayAccess container.
  
  @param array|\ArrayAccess $container Container to hold the history (by reference).
  
  @return callable Returns a function that accepts the next handler.
  @throws \InvalidArgumentException if container is not an array or ArrayAccess.
docstring_tokens: Middleware that pushes history data to an ArrayAccess container .