Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Bolt/BoltConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Bolt\protocol\Response;
use Bolt\protocol\V4_4;
use Bolt\protocol\V5;
use Bolt\protocol\V5_1;
use Bolt\protocol\V5_2;
use Bolt\protocol\V5_3;
use Bolt\protocol\V5_4;
use Laudis\Neo4j\Common\ConnectionConfiguration;
Expand All @@ -35,7 +37,7 @@
use WeakReference;

/**
* @implements ConnectionInterface<array{0: V4_4|V5|V5_3|V5_4, 1: Connection}>
* @implements ConnectionInterface<array{0: V4_4|V5|V5_1|V5_2|V5_3|V5_4, 1: Connection}>
*
* @psalm-import-type BoltMeta from FormatterInterface
*/
Expand All @@ -57,7 +59,7 @@ class BoltConnection implements ConnectionInterface
private array $subscribedResults = [];

/**
* @return array{0: V4_4|V5|V5_3|V5_4, 1: Connection}
* @return array{0: V4_4|V5|V5_1|V5_2|V5_3|V5_4, 1: Connection}
*/
public function getImplementation(): array
{
Expand All @@ -68,7 +70,7 @@ public function getImplementation(): array
* @psalm-mutation-free
*/
public function __construct(
private V4_4|V5|V5_3|V5_4 $boltProtocol,
private V4_4|V5|V5_1|V5_2|V5_3|V5_4 $boltProtocol,
private readonly Connection $connection,
private readonly AuthenticateInterface $auth,
private readonly string $userAgent,
Expand Down Expand Up @@ -268,7 +270,7 @@ public function rollback(): void
$this->assertNoFailure($response);
}

public function protocol(): V4_4|V5|V5_3|V5_4
public function protocol(): V4_4|V5|V5_1|V5_2|V5_3|V5_4
{
return $this->boltProtocol;
}
Expand Down
15 changes: 12 additions & 3 deletions src/Bolt/ProtocolFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

use Bolt\Bolt;
use Bolt\connection\IConnection;
use Bolt\error\ConnectException;
use Bolt\protocol\V4_4;
use Bolt\protocol\V5;
use Bolt\protocol\V5_1;
use Bolt\protocol\V5_2;
use Bolt\protocol\V5_3;
use Bolt\protocol\V5_4;
use Laudis\Neo4j\Contracts\AuthenticateInterface;
Expand All @@ -25,16 +28,22 @@
class ProtocolFactory
{
/**
* @return array{0: V4_4|V5|V5_3|V5_4, 1: array{server: string, connection_id: string, hints: list}}
* @return array{0: V4_4|V5|V5_1|V5_2|V5_3|V5_4, 1: array{server: string, connection_id: string, hints: list}}
*/
public function createProtocol(IConnection $connection, AuthenticateInterface $auth, string $userAgent): array
{
$bolt = new Bolt($connection);
$bolt->setProtocolVersions(5.4, 5.3, 5, 4.4);

$protocol = $bolt->build();
try {
$protocol = $bolt->build();
} catch (ConnectException $e) {
// Assume incorrect protocol version
$bolt->setProtocolVersions(5.2, 5.1);
$protocol = $bolt->build();
}

if (!($protocol instanceof V4_4 || $protocol instanceof V5 || $protocol instanceof V5_3 || $protocol instanceof V5_4)) {
if (!($protocol instanceof V4_4 || $protocol instanceof V5 || $protocol instanceof V5_1 || $protocol instanceof V5_2 || $protocol instanceof V5_3 || $protocol instanceof V5_4)) {
throw new RuntimeException('Client only supports bolt version 4.4 and ^5.0');
}

Expand Down
Loading