@@ -12,6 +12,6 @@ |
||
12 | 12 | * @link http://github.com/graze/guzzle-jsonrpc |
13 | 13 | */ |
14 | 14 | |
15 | -if (! function_exists('Graze\GuzzleHttp\JsonRpc\json_encode')) { |
|
15 | +if ( ! function_exists('Graze\GuzzleHttp\JsonRpc\json_encode')) { |
|
16 | 16 | require __DIR__ . '/functions.php'; |
17 | 17 | } |
@@ -21,9 +21,9 @@ |
||
21 | 21 | { |
22 | 22 | public function __invoke(callable $fn) |
23 | 23 | { |
24 | - return function (HttpRequestInterface $request, array $options) use ($fn) { |
|
24 | + return function(HttpRequestInterface $request, array $options) use ($fn) { |
|
25 | 25 | return $fn(call_user_func([$this, 'applyRequest'], $request, $options), $options)->then( |
26 | - function (HttpResponseInterface $response) use ($request, $options) { |
|
26 | + function(HttpResponseInterface $response) use ($request, $options) { |
|
27 | 27 | return call_user_func([$this, 'applyResponse'], $request, $response, $options); |
28 | 28 | } |
29 | 29 | ); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function sendAsync(RequestInterface $request) |
116 | 116 | { |
117 | 117 | return $this->httpClient->sendAsync($request)->then( |
118 | - function (ResponseInterface $response) use ($request) { |
|
118 | + function(ResponseInterface $response) use ($request) { |
|
119 | 119 | return $request->getRpcId() ? $response : null; |
120 | 120 | } |
121 | 121 | ); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | return $this->httpClient->sendAsync($this->createRequest( |
140 | 140 | RequestInterface::BATCH, |
141 | 141 | $this->getBatchRequestOptions($requests) |
142 | - ))->then(function (ResponseInterface $response) { |
|
142 | + ))->then(function(ResponseInterface $response) { |
|
143 | 143 | return $this->getBatchResponses($response); |
144 | 144 | }); |
145 | 145 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function getBatchRequestOptions(array $requests) |
168 | 168 | { |
169 | - return array_map(function (RequestInterface $request) { |
|
169 | + return array_map(function(RequestInterface $request) { |
|
170 | 170 | return JsonRpc\json_decode((string) $request->getBody()); |
171 | 171 | }, $requests); |
172 | 172 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $results = JsonRpc\json_decode((string) $response->getBody(), true); |
182 | 182 | |
183 | - return array_map(function (array $result) use ($response) { |
|
183 | + return array_map(function(array $result) use ($response) { |
|
184 | 184 | return $this->messageFactory->createResponse( |
185 | 185 | $response->getStatusCode(), |
186 | 186 | $response->getHeaders(), |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | function json_decode($json, $assoc = false, $depth = 512, $options = 0) |
39 | 39 | { |
40 | 40 | static $jsonErrors = [ |
41 | - JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', |
|
42 | - JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch', |
|
43 | - JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found', |
|
44 | - JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON', |
|
45 | - JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded', |
|
41 | + JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', |
|
42 | + JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch', |
|
43 | + JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found', |
|
44 | + JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON', |
|
45 | + JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded', |
|
46 | 46 | ]; |
47 | 47 | |
48 | 48 | // Patched support for decoding empty strings for PHP 7+ |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | if (JSON_ERROR_NONE !== json_last_error()) { |
52 | 52 | $last = json_last_error(); |
53 | 53 | throw new InvalidArgumentException( |
54 | - 'Unable to parse JSON data: ' |
|
55 | - . (isset($jsonErrors[$last]) |
|
54 | + 'Unable to parse JSON data: ' |
|
55 | + . (isset($jsonErrors[$last]) |
|
56 | 56 | ? $jsonErrors[$last] |
57 | 57 | : 'Unknown error') |
58 | - ); |
|
58 | + ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $data; |
@@ -72,10 +72,10 @@ |
||
72 | 72 | function json_encode($data, $escapeChars = true) |
73 | 73 | { |
74 | 74 | $options = |
75 | - JSON_HEX_AMP | |
|
75 | + JSON_HEX_AMP | |
|
76 | 76 | JSON_HEX_APOS | |
77 | 77 | JSON_HEX_QUOT | |
78 | - JSON_HEX_TAG | |
|
78 | + JSON_HEX_TAG | |
|
79 | 79 | JSON_UNESCAPED_UNICODE | |
80 | 80 | JSON_UNESCAPED_SLASHES; |
81 | 81 |