@@ -67,7 +67,6 @@ use GuzzleHttp\Command\Result;
6767use GuzzleHttp\Command\ResultInterface;
6868use GuzzleHttp\Command\ServiceClient;
6969use GuzzleHttp\Psr7\Request;
70- use GuzzleHttp\Utils;
7170use Psr\Http\Message\RequestInterface;
7271use Psr\Http\Message\ResponseInterface;
7372
@@ -78,7 +77,7 @@ $client = new ServiceClient(
7877 'POST',
7978 '/' . rawurlencode($command->getName()),
8079 ['Accept' => 'application/json', 'Content-Type' => 'application/json'],
81- Utils::jsonEncode ($command->toArray())
80+ \json_encode ($command->toArray(), \JSON_THROW_ON_ERROR )
8281 );
8382 },
8483 function (
@@ -87,7 +86,7 @@ $client = new ServiceClient(
8786 CommandInterface $command
8887 ): ResultInterface {
8988 return new Result(
90- Utils::jsonDecode ((string) $response->getBody(), true)
89+ \json_decode ((string) $response->getBody(), true, 512, \JSON_THROW_ON_ERROR )
9190 );
9291 }
9392);
@@ -102,11 +101,10 @@ parameters:
102101``` php
103102use GuzzleHttp\Command\CommandInterface;
104103use GuzzleHttp\Psr7\Request;
105- use GuzzleHttp\Utils;
106104use Psr\Http\Message\RequestInterface;
107105
108106$commandToRequest = function (CommandInterface $command): RequestInterface {
109- $body = Utils::jsonEncode ($command->toArray());
107+ $body = \json_encode ($command->toArray(), \JSON_THROW_ON_ERROR );
110108 $path = '/commands/' . rawurlencode($command->getName());
111109
112110 return new Request(
@@ -125,7 +123,6 @@ shape. It receives the response, request, and original command:
125123use GuzzleHttp\Command\CommandInterface;
126124use GuzzleHttp\Command\Result;
127125use GuzzleHttp\Command\ResultInterface;
128- use GuzzleHttp\Utils;
129126use Psr\Http\Message\RequestInterface;
130127use Psr\Http\Message\ResponseInterface;
131128
@@ -137,7 +134,7 @@ $responseToResult = function (
137134 return new Result([
138135 'operation' => $command->getName(),
139136 'statusCode' => $response->getStatusCode(),
140- 'data' => Utils::jsonDecode ((string) $response->getBody(), true),
137+ 'data' => \json_decode ((string) $response->getBody(), true, 512, \JSON_THROW_ON_ERROR ),
141138 ]);
142139};
143140```
0 commit comments