@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * @license http://www.apache.org/licenses/ Apache License 2.0 |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | private function pkbdf2Hmac(string $password, string $salt, int $iterations): string |
147 | 147 | { |
148 | - $t = hash_hmac('sha256', $salt . "\x00\x00\x00\x01", $password, true); |
|
148 | + $t = hash_hmac('sha256', $salt."\x00\x00\x00\x01", $password, true); |
|
149 | 149 | $u = $t; |
150 | 150 | for ($i = 0; $i < $iterations - 1; ++$i) { |
151 | 151 | $t = hash_hmac('sha256', $t, $password, true); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $response === null or die('Illegal handshake state'); |
165 | 165 | |
166 | 166 | $this->myR = base64_encode(openssl_random_pseudo_bytes(18)); |
167 | - $this->clientFirstMessage = 'n=' . $this->username . ',r=' . $this->myR; |
|
167 | + $this->clientFirstMessage = 'n='.$this->username.',r='.$this->myR; |
|
168 | 168 | |
169 | 169 | $binaryVersion = pack('V', $this->version); |
170 | 170 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | [ |
177 | 177 | 'protocol_version' => $this->protocolVersion, |
178 | 178 | 'authentication_method' => 'SCRAM-SHA-256', |
179 | - 'authentication' => 'n,,' . $this->clientFirstMessage, |
|
179 | + 'authentication' => 'n,,'.$this->clientFirstMessage, |
|
180 | 180 | ] |
181 | 181 | ) |
182 | 182 | . \chr(0); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | $json = json_decode($response, true); |
201 | 201 | if ($json['success'] === false) { |
202 | - throw new Exception('Handshake failed: ' . $json["error"]); |
|
202 | + throw new Exception('Handshake failed: '.$json["error"]); |
|
203 | 203 | } |
204 | 204 | if ($this->protocolVersion > $json['max_protocol_version'] |
205 | 205 | || $this->protocolVersion < $json['min_protocol_version']) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | $json = json_decode($response, true); |
222 | 222 | if ($json['success'] === false) { |
223 | - throw new Exception('Handshake failed: ' . $json['error']); |
|
223 | + throw new Exception('Handshake failed: '.$json['error']); |
|
224 | 224 | } |
225 | 225 | $serverFirstMessage = $json['authentication']; |
226 | 226 | $authentication = []; |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | throw new Exception('Invalid nonce from server.'); |
234 | 234 | } |
235 | 235 | $salt = base64_decode($authentication['s']); |
236 | - $iterations = (int)$authentication['i']; |
|
236 | + $iterations = (int) $authentication['i']; |
|
237 | 237 | |
238 | - $clientFinalMessageWithoutProof = 'c=biws,r=' . $serverR; |
|
238 | + $clientFinalMessageWithoutProof = 'c=biws,r='.$serverR; |
|
239 | 239 | $saltedPassword = $this->pkbdf2Hmac($this->password, $salt, $iterations); |
240 | 240 | $clientKey = hash_hmac('sha256', 'Client Key', $saltedPassword, true); |
241 | 241 | $storedKey = hash('sha256', $clientKey, true); |
242 | 242 | |
243 | 243 | $authMessage = |
244 | - $this->clientFirstMessage . ',' . $serverFirstMessage . ',' . $clientFinalMessageWithoutProof; |
|
244 | + $this->clientFirstMessage.','.$serverFirstMessage.','.$clientFinalMessageWithoutProof; |
|
245 | 245 | |
246 | 246 | $clientSignature = hash_hmac('sha256', $authMessage, $storedKey, true); |
247 | 247 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | return |
257 | 257 | json_encode( |
258 | 258 | [ |
259 | - 'authentication' => $clientFinalMessageWithoutProof . ',p=' . base64_encode($clientProof), |
|
259 | + 'authentication' => $clientFinalMessageWithoutProof.',p='.base64_encode($clientProof), |
|
260 | 260 | ] |
261 | 261 | ) |
262 | 262 | . \chr(0); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | { |
272 | 272 | $json = json_decode($response, true); |
273 | 273 | if ($json['success'] === false) { |
274 | - throw new Exception('Handshake failed: ' . $json['error']); |
|
274 | + throw new Exception('Handshake failed: '.$json['error']); |
|
275 | 275 | } |
276 | 276 | $authentication = []; |
277 | 277 | foreach (explode(',', $json['authentication']) as $var) { |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Connection\Socket; |
5 | 5 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Connection\Socket; |
5 | 5 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function __construct(OptionsInterface $options) |
30 | 30 | { |
31 | 31 | $this->openStream( |
32 | - ($options->isSsl() ? 'ssl' : 'tcp') . '://' . $options->getHostname() . ':' . $options->getPort(), |
|
32 | + ($options->isSsl() ? 'ssl' : 'tcp').'://'.$options->getHostname().':'.$options->getPort(), |
|
33 | 33 | $options->getTimeout(), |
34 | 34 | $options->getTimeoutStream() |
35 | 35 | ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Connection; |
5 | 5 | |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | $requestSize = pack('V', \strlen($request)); |
280 | - $binaryToken = pack('V', $token) . pack('V', 0); |
|
280 | + $binaryToken = pack('V', $token).pack('V', 0); |
|
281 | 281 | |
282 | - return $this->stream->write($binaryToken . $requestSize . $request); |
|
282 | + return $this->stream->write($binaryToken.$requestSize.$request); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -390,22 +390,22 @@ discard block |
||
390 | 390 | } |
391 | 391 | |
392 | 392 | if ($response->getType() === ResponseType::CLIENT_ERROR) { |
393 | - throw new ConnectionException('Client error: ' . $response->getData()[0] . ' jsonQuery: ' . json_encode($message)); |
|
393 | + throw new ConnectionException('Client error: '.$response->getData()[0].' jsonQuery: '.json_encode($message)); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | if ($responseToken !== $token) { |
397 | 397 | throw new ConnectionException( |
398 | 398 | 'Received wrong token. Response does not match the request. ' |
399 | - . 'Expected ' . $token . ', received ' . $responseToken |
|
399 | + . 'Expected '.$token.', received '.$responseToken |
|
400 | 400 | ); |
401 | 401 | } |
402 | 402 | |
403 | 403 | if ($response->getType() === ResponseType::COMPILE_ERROR) { |
404 | - throw new ConnectionException('Compile error: ' . $response->getData()[0] . ', jsonQuery: ' . json_encode($message)); |
|
404 | + throw new ConnectionException('Compile error: '.$response->getData()[0].', jsonQuery: '.json_encode($message)); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | if ($response->getType() === ResponseType::RUNTIME_ERROR) { |
408 | - throw new ConnectionException('Runtime error: ' . $response->getData()[0] . ', jsonQuery: ' . json_encode($message)); |
|
408 | + throw new ConnectionException('Runtime error: '.$response->getData()[0].', jsonQuery: '.json_encode($message)); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Response; |
5 | 5 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Message; |
5 | 5 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Message; |
5 | 5 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return [ |
91 | 91 | $this->queryType, |
92 | 92 | $this->query, |
93 | - (object)$this->getOptions() |
|
93 | + (object) $this->getOptions() |
|
94 | 94 | ]; |
95 | 95 | } |
96 | 96 |
@@ -89,7 +89,7 @@ |
||
89 | 89 | return [ |
90 | 90 | $this->queryType, |
91 | 91 | $this->query, |
92 | - (object)$this->getOptions(), |
|
92 | + (object) $this->getOptions(), |
|
93 | 93 | ]; |
94 | 94 | } |
95 | 95 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TBolier\RethinkQL\Serializer; |
5 | 5 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!$object instanceof \JsonSerializable && !$object instanceof \stdClass) { |
24 | - throw new InvalidArgumentException(sprintf('The ' . get_class($object) . ' must implement "%s".', \JsonSerializable::class)); |
|
24 | + throw new InvalidArgumentException(sprintf('The '.get_class($object).' must implement "%s".', \JsonSerializable::class)); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | if (!$this->serializer instanceof NormalizerInterface) { |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | if ($object instanceof \stdClass) { |
32 | - return (array)$object; |
|
32 | + return (array) $object; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if ($object instanceof OptionsInterface) { |
36 | - return (object)$object->jsonSerialize(); |
|
36 | + return (object) $object->jsonSerialize(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $this->serializer->normalize($object->jsonSerialize(), $format, $context); |