title: Passing variables between Middlewares using zend-mvc
body: <p>I'm trying to decipher how to properly blend variables between ZF3 Middleware under the latest release of zend-mvc.</p>
  
  <p>Imagine a route like this:</p>
  
  <pre><code>'sandwich-test' =&gt; [
      'type' =&gt; \Zend\Router\Http\Literal::class,
      'options' =&gt; [
          'route' =&gt; '/events/sandwich',
          'defaults' =&gt; [
              'middleware' =&gt; [
                  \Foo\Middleware\JsonWrappingMiddleware::class,
                  \Foo\Middleware\TestMiddleware::class,
              ],
          ],
      ],
  ],
  </code></pre>
  
  <p>In my simple test, I'd like for JsonWrappingMiddleware to simply return in a JsonResponse, the variables returned by TestMiddleware.</p>
  
  <p>Individually, this works:</p>
  
  <pre><code>use Interop\Http\ServerMiddleware\DelegateInterface;
  use Interop\Http\ServerMiddleware\MiddlewareInterface;
  use Psr\Http\Message\ServerRequestInterface;
  use Zend\Diactoros\Response\JsonResponse;
  
  class JsonWrappingMiddleware implements MiddlewareInterface
  {
      public function process(ServerRequestInterface $request, DelegateInterface $delegate)
      {
  
          return new JsonResponse(['c' =&gt; 'd']);
      }
  }
  </code></pre>
  
  <p>...and...</p>
  
  <pre><code>use Interop\Http\ServerMiddleware\DelegateInterface;
  use Interop\Http\ServerMiddleware\MiddlewareInterface;
  use Psr\Http\Message\ServerRequestInterface;
  use Zend\Diactoros\Response\JsonResponse;
  
  class TestMiddleware implements MiddlewareInterface
  {
      public function process(ServerRequestInterface $request, DelegateInterface $delegate)
      {
          return new JsonResponse(['a' =&gt; 'b']);
      }
  }
  </code></pre>
  
  <p>But then, how to make them work together to return</p>
  
  <pre><code>[ 'a' =&gt; 'b', 'c' =&gt; 'd', ]
  </code></pre>