Skip to content

Commit f70d71c

Browse files
stefanak-michaltransistive
authored andcommitted
added more bolt versions
1 parent 1f05fae commit f70d71c

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/Bolt/BoltConnection.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
use Bolt\enum\ServerState;
1717
use Bolt\enum\Signature;
1818
use Bolt\protocol\Response;
19-
use Bolt\protocol\V4_4;
20-
use Bolt\protocol\V5;
19+
use Bolt\protocol\{V4_4, V5, V5_3, V5_4};
2120
use Laudis\Neo4j\Common\ConnectionConfiguration;
2221
use Laudis\Neo4j\Contracts\AuthenticateInterface;
2322
use Laudis\Neo4j\Contracts\ConnectionInterface;
@@ -32,7 +31,7 @@
3231
use WeakReference;
3332

3433
/**
35-
* @implements ConnectionInterface<array{0: V4_4|V5, 1: Connection}>
34+
* @implements ConnectionInterface<array{0: V4_4|V5|V5_3|V5_4, 1: Connection}>
3635
*
3736
* @psalm-import-type BoltMeta from FormatterInterface
3837
*/
@@ -54,7 +53,7 @@ class BoltConnection implements ConnectionInterface
5453
private array $subscribedResults = [];
5554

5655
/**
57-
* @return array{0: V4_4|V5, 1: Connection}
56+
* @return array{0: V4_4|V5|V5_3|V5_4, 1: Connection}
5857
*/
5958
public function getImplementation(): array
6059
{
@@ -65,7 +64,7 @@ public function getImplementation(): array
6564
* @psalm-mutation-free
6665
*/
6766
public function __construct(
68-
private V4_4|V5 $boltProtocol,
67+
private V4_4|V5|V5_3|V5_4 $boltProtocol,
6968
private readonly Connection $connection,
7069
private readonly AuthenticateInterface $auth,
7170
private readonly string $userAgent,
@@ -254,7 +253,7 @@ public function rollback(): void
254253
$this->assertNoFailure($response);
255254
}
256255

257-
public function protocol(): V4_4|V5
256+
public function protocol(): V4_4|V5|V5_3|V5_4
258257
{
259258
return $this->boltProtocol;
260259
}

src/Bolt/Connection.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
namespace Laudis\Neo4j\Bolt;
1515

1616
use Bolt\connection\IConnection;
17-
use Bolt\protocol\AProtocol;
1817

1918
class Connection
2019
{
21-
private ?AProtocol $protocol = null;
22-
2320
/**
2421
* @param ''|'s'|'ssc' $ssl
2522
*/

src/Bolt/ProtocolFactory.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,24 @@
1515

1616
use Bolt\Bolt;
1717
use Bolt\connection\IConnection;
18-
use Bolt\protocol\V4_4;
19-
use Bolt\protocol\V5;
18+
use Bolt\protocol\{V4_4, V5, V5_3, V5_4};
2019
use Laudis\Neo4j\Contracts\AuthenticateInterface;
2120
use RuntimeException;
2221

2322
class ProtocolFactory
2423
{
2524
/**
26-
* @return array{0: V4_4|V5, 1: array{server: string, connection_id: string, hints: list}}
25+
* @return array{0: V4_4|V5|V5_3|V5_4, 1: array{server: string, connection_id: string, hints: list}}
2726
*/
2827
public function createProtocol(IConnection $connection, AuthenticateInterface $auth, string $userAgent): array
2928
{
3029
$bolt = new Bolt($connection);
31-
$bolt->setProtocolVersions(5, 4.4);
30+
$bolt->setProtocolVersions(5.4, 5.3, 5, 4.4);
3231

3332
$protocol = $bolt->build();
3433

35-
if (!$protocol instanceof V4_4 && !$protocol instanceof V5) {
36-
throw new RuntimeException('Client only supports bolt version 4.4.* and ^5.0');
34+
if (!($protocol instanceof V4_4 || $protocol instanceof V5 || $protocol instanceof V5_3 || $protocol instanceof V5_4)) {
35+
throw new RuntimeException('Client only supports bolt version 4.4 and ^5.0');
3736
}
3837

3938
$response = $auth->authenticateBolt($protocol, $userAgent);

src/Enum/ConnectionProtocol.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
use Bolt\protocol\V4_3;
2121
use Bolt\protocol\V4_4;
2222
use Bolt\protocol\V5;
23+
use Bolt\protocol\V5_1;
24+
use Bolt\protocol\V5_2;
25+
use Bolt\protocol\V5_3;
26+
use Bolt\protocol\V5_4;
2327
use JsonSerializable;
2428
use Laudis\TypedEnum\TypedEnum;
2529

@@ -33,6 +37,10 @@
3337
* @method static ConnectionProtocol BOLT_V43()
3438
* @method static ConnectionProtocol BOLT_V44()
3539
* @method static ConnectionProtocol BOLT_V5()
40+
* @method static ConnectionProtocol BOLT_V5_1()
41+
* @method static ConnectionProtocol BOLT_V5_2()
42+
* @method static ConnectionProtocol BOLT_V5_3()
43+
* @method static ConnectionProtocol BOLT_V5_4()
3644
* @method static ConnectionProtocol HTTP()
3745
*
3846
* @extends TypedEnum<string>
@@ -50,6 +58,10 @@ final class ConnectionProtocol extends TypedEnum implements JsonSerializable
5058
private const BOLT_V43 = '4.3';
5159
private const BOLT_V44 = '4.4';
5260
private const BOLT_V5 = '5';
61+
private const BOLT_V5_1 = '5.1';
62+
private const BOLT_V5_2 = '5.2';
63+
private const BOLT_V5_3 = '5.3';
64+
private const BOLT_V5_4 = '5.4';
5365
private const HTTP = 'http';
5466

5567
public function isBolt(): bool
@@ -63,7 +75,7 @@ public function isBolt(): bool
6375
*
6476
* @psalm-suppress ImpureMethodCall
6577
*/
66-
public static function determineBoltVersion(V3|V4|V4_1|V4_2|V4_3|V4_4|V5 $bolt): self
78+
public static function determineBoltVersion(V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4 $bolt): self
6779
{
6880
$version = self::resolve($bolt->getVersion());
6981

0 commit comments

Comments
 (0)