Skip to content

Commit 8686875

Browse files
committed
Amendments to operations to the upport the ReQL API argument expected type
1 parent 2f6a1ea commit 8686875

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+361
-477
lines changed

src/Connection/Connection.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

@@ -155,7 +155,13 @@ public function continueQuery(int $token): ResponseInterface
155155
*/
156156
public function expr(string $string): ResponseInterface
157157
{
158-
return $this->run(new ExprMessage(QueryType::START, 'foo'));
158+
$response = $this->run(new ExprMessage(QueryType::START, 'foo'));
159+
160+
if ($response instanceof ResponseInterface) {
161+
return $response;
162+
}
163+
164+
return new Response();
159165
}
160166

161167
/**
@@ -179,7 +185,7 @@ public function run(MessageInterface $message, $raw = false)
179185
$this->writeQuery($token, $message);
180186

181187
if ($this->noReply) {
182-
return null;
188+
return new Response();
183189
}
184190

185191
$response = $this->receiveResponse($token, $message);
@@ -277,9 +283,9 @@ public function writeQuery(int $token, MessageInterface $message): int
277283
}
278284

279285
$requestSize = pack('V', \strlen($request));
280-
$binaryToken = pack('V', $token) . pack('V', 0);
286+
$binaryToken = pack('V', $token).pack('V', 0);
281287

282-
return $this->stream->write($binaryToken . $requestSize . $request);
288+
return $this->stream->write($binaryToken.$requestSize.$request);
283289
}
284290

285291
/**
@@ -385,27 +391,27 @@ private function validateResponse(
385391
int $token,
386392
MessageInterface $message
387393
): void {
388-
if (!$response->getType()) {
394+
if ($response->getType() === null) {
389395
throw new ConnectionException('Response message has no type.');
390396
}
391397

392398
if ($response->getType() === ResponseType::CLIENT_ERROR) {
393-
throw new ConnectionException('Client error: ' . $response->getData()[0] . ' jsonQuery: ' . json_encode($message));
399+
throw new ConnectionException('Client error: '.$response->getData()[0].' jsonQuery: '.json_encode($message));
394400
}
395401

396402
if ($responseToken !== $token) {
397403
throw new ConnectionException(
398404
'Received wrong token. Response does not match the request. '
399-
. 'Expected ' . $token . ', received ' . $responseToken
405+
. 'Expected '.$token.', received '.$responseToken
400406
);
401407
}
402408

403409
if ($response->getType() === ResponseType::COMPILE_ERROR) {
404-
throw new ConnectionException('Compile error: ' . $response->getData()[0] . ', jsonQuery: ' . json_encode($message));
410+
throw new ConnectionException('Compile error: '.$response->getData()[0].', jsonQuery: '.json_encode($message));
405411
}
406412

407413
if ($response->getType() === ResponseType::RUNTIME_ERROR) {
408-
throw new ConnectionException('Runtime error: ' . $response->getData()[0] . ', jsonQuery: ' . json_encode($message));
414+
throw new ConnectionException('Runtime error: '.$response->getData()[0].', jsonQuery: '.json_encode($message));
409415
}
410416
}
411417
}

src/Connection/ConnectionCursorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

@@ -10,7 +10,7 @@ interface ConnectionCursorInterface extends ConnectionQueryInterface
1010
{
1111
/**
1212
* @param MessageInterface $message
13-
* @return ResponseInterface
13+
* @return Iterable|ResponseInterface
1414
* @throws ConnectionException
1515
*/
1616
public function rewindFromCursor(MessageInterface $message): ResponseInterface;

src/Connection/ConnectionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/ConnectionQueryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/OptionsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/Registry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/RegistryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection;
55

src/Connection/Socket/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
declare(strict_types=1);
2+
declare(strict_types = 1);
33

44
namespace TBolier\RethinkQL\Connection\Socket;
55

0 commit comments

Comments
 (0)