nextHandler = $nextHandler; $this->client = $client; $this->descriptor = $descriptor; } public function __invoke(Call $call, array $options) { $next = $this->nextHandler; return $next( $call, $options )->then(function (Message $response) { $options = $this->descriptor + [ 'lastProtoResponse' => $response ]; return new OperationResponse($response->getName(), $this->client, $options); }); } }