Skip to content

Commit

Permalink
added support for new bolt version 5.6 (#147)
Browse files Browse the repository at this point in the history
* added support for new bolt version 5.6

* added missing tests for new bolt version

* added missing possible return type

* extended return type of used trait
  • Loading branch information
stefanak-michal authored Sep 29, 2024
1 parent 2fb8ed8 commit eb9bd8c
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/db.50.2204.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
neo4j-version: ['5.4', '5.6', '5.8', '5.12', '5.13']
neo4j-version: ['5.4', '5.6', '5.8', '5.12', '5.13', '5.23']
php-version: ['8.1', '8.2', '8.3']

services:
Expand Down
37 changes: 37 additions & 0 deletions src/protocol/V5_6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Bolt\protocol;

/**
* Class Protocol version 5.4
*
* @author Michal Stefanak
* @link https://github.com/neo4j-php/Bolt
* @see https://www.neo4j.com/docs/bolt/current/bolt/message/
* @package Bolt\protocol
*/
class V5_6 extends AProtocol
{
use \Bolt\protocol\v5\AvailableStructures;
use \Bolt\protocol\v5_1\ServerStateTransition;

use \Bolt\protocol\v1\ResetMessage;

use \Bolt\protocol\v3\RunMessage;
use \Bolt\protocol\v3\BeginMessage;
use \Bolt\protocol\v3\CommitMessage;
use \Bolt\protocol\v3\RollbackMessage;
use \Bolt\protocol\v3\GoodbyeMessage;

use \Bolt\protocol\v4\PullMessage;
use \Bolt\protocol\v4\DiscardMessage;

use \Bolt\protocol\v4_4\RouteMessage;

use \Bolt\protocol\v5_1\LogonMessage;
use \Bolt\protocol\v5_1\LogoffMessage;

use \Bolt\protocol\v5_3\HelloMessage;

use \Bolt\protocol\v5_4\TelemetryMessage;
}
4 changes: 2 additions & 2 deletions src/protocol/v1/ResetMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v1;

use Bolt\enum\Message;
use Bolt\protocol\{V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait ResetMessage
Expand All @@ -15,7 +15,7 @@ trait ResetMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-reset
* @throws BoltException
*/
public function reset(): V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function reset(): V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x0F));
$this->pipelinedMessages[] = Message::RESET;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v3/BeginMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v3;

use Bolt\enum\Message;
use Bolt\protocol\{V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait BeginMessage
Expand All @@ -15,7 +15,7 @@ trait BeginMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-begin
* @throws BoltException
*/
public function begin(array $extra = []): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function begin(array $extra = []): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x11, (object)$extra));
$this->pipelinedMessages[] = Message::BEGIN;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v3/CommitMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v3;

use Bolt\enum\Message;
use Bolt\protocol\{Response, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{Response, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait CommitMessage
Expand All @@ -15,7 +15,7 @@ trait CommitMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-commit
* @throws BoltException
*/
public function commit(): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function commit(): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x12));
$this->pipelinedMessages[] = Message::COMMIT;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v3/RollbackMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v3;

use Bolt\enum\Message;
use Bolt\protocol\{Response, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{Response, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait RollbackMessage
Expand All @@ -15,7 +15,7 @@ trait RollbackMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-rollback
* @throws BoltException
*/
public function rollback(): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function rollback(): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x13));
$this->pipelinedMessages[] = Message::ROLLBACK;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v3/RunMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v3;

use Bolt\enum\Message;
use Bolt\protocol\{Response, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{Response, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait RunMessage
Expand All @@ -15,7 +15,7 @@ trait RunMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-run
* @throws BoltException
*/
public function run(string $query, array $parameters = [], array $extra = []): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function run(string $query, array $parameters = [], array $extra = []): V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(
0x10,
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v4/DiscardMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bolt\enum\Message;
use Bolt\enum\Signature;
use Bolt\protocol\{Response, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{Response, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait DiscardMessage
Expand All @@ -17,7 +17,7 @@ trait DiscardMessage
* @param array $extra [n::Integer, qid::Integer]
* @throws BoltException
*/
public function discard(array $extra = []): V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function discard(array $extra = []): V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
if (!array_key_exists('n', $extra))
$extra['n'] = -1;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v4/PullMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v4;

use Bolt\enum\{Message, Signature};
use Bolt\protocol\{Response, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{Response, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait PullMessage
Expand All @@ -16,7 +16,7 @@ trait PullMessage
* @param array $extra [n::Integer, qid::Integer]
* @throws BoltException
*/
public function pull(array $extra = []): V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function pull(array $extra = []): V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
if (!array_key_exists('n', $extra))
$extra['n'] = -1;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v4_4/RouteMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v4_4;

use Bolt\enum\Message;
use Bolt\protocol\{V4_4, V5, V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V4_4, V5, V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait RouteMessage
Expand All @@ -16,7 +16,7 @@ trait RouteMessage
* @param array $extra [db::String, imp_user::String]
* @throws BoltException
*/
public function route(array $routing, array $bookmarks = [], array $extra = []): V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function route(array $routing, array $bookmarks = [], array $extra = []): V4_4|V5|V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x66, (object)$routing, $bookmarks, (object)$extra));
$this->pipelinedMessages[] = Message::ROUTE;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v5_1/HelloMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\protocol\v5_1;

use Bolt\enum\Message;
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait HelloMessage
Expand All @@ -15,7 +15,7 @@ trait HelloMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-hello
* @throws BoltException
*/
public function hello(array $extra = []): V5_1|V5_2|V5_3|V5_4
public function hello(array $extra = []): V5_1|V5_2|V5_3|V5_4|V5_6
{
if (empty($extra['user_agent']))
$extra['user_agent'] = 'bolt-php';
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v5_1/LogoffMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bolt\enum\Message;
use Bolt\error\BoltException;
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4, V5_6};

trait LogoffMessage
{
Expand All @@ -15,7 +15,7 @@ trait LogoffMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-logoff
* @throws BoltException
*/
public function logoff(): V5_1|V5_2|V5_3|V5_4
public function logoff(): V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x6B));
$this->pipelinedMessages[] = Message::LOGOFF;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v5_1/LogonMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bolt\enum\Message;
use Bolt\error\BoltException;
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4, V5_6};

trait LogonMessage
{
Expand All @@ -15,7 +15,7 @@ trait LogonMessage
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-logon
* @throws BoltException
*/
public function logon(array $auth): V5_1|V5_2|V5_3|V5_4
public function logon(array $auth): V5_1|V5_2|V5_3|V5_4|V5_6
{
$this->write($this->packer->pack(0x6A, (object)$auth));
$this->pipelinedMessages[] = Message::LOGON;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v5_3/HelloMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Bolt\protocol\v5_3;

use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4};
use Bolt\protocol\{V5_1, V5_2, V5_3, V5_4, V5_6};
use Bolt\error\BoltException;

trait HelloMessage
Expand All @@ -19,7 +19,7 @@ trait HelloMessage
* @param array $extra Use \Bolt\helpers\Auth to generate appropiate array
* @throws BoltException
*/
public function hello(array $extra = []): V5_1|V5_2|V5_3|V5_4
public function hello(array $extra = []): V5_1|V5_2|V5_3|V5_4|V5_6
{
$extra['bolt_agent'] = [
'product' => 'php-bolt/' . \Composer\InstalledVersions::getPrettyVersion('stefanak-michal/bolt'),
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/v5_4/TelemetryMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Bolt\protocol\v5_4;

use Bolt\protocol\V5_4;
use Bolt\protocol\{V5_4, V5_6};
use Bolt\enum\Message;
use Bolt\error\BoltException;

Expand All @@ -15,7 +15,7 @@ trait TelemetryMessage
* @link https://neo4j.com/docs/bolt/current/bolt/message/#messages-telemetry
* @throws BoltException
*/
public function telemetry(int $api): V5_4
public function telemetry(int $api): V5_4|V5_6
{
$this->write($this->packer->pack(0x54, $api));
$this->pipelinedMessages[] = Message::TELEMETRY;
Expand Down
2 changes: 2 additions & 0 deletions tests/TestLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ protected function getCompatibleBoltVersion(string $url = null): float|int

$neo4jVersion = $decoded['neo4j_version'];

if (version_compare($neo4jVersion, '5.23', '>='))
return 5.6;
if (version_compare($neo4jVersion, '5.13', '>='))
return 5.4;
if (version_compare($neo4jVersion, '5.9', '>='))
Expand Down
20 changes: 20 additions & 0 deletions tests/protocol/V5_6Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use Bolt\protocol\V5_6;

/**
* Class V5_6Test
*
* @author Michal Stefanak
* @link https://github.com/neo4j-php/Bolt
* @package Bolt\tests\protocol
*/
class V5_6Test extends \Bolt\tests\protocol\ProtocolLayer
{
public function test__construct(): V5_6
{
$cls = new V5_6(1, $this->mockConnection());
$this->assertInstanceOf(V5_6::class, $cls);
return $cls;
}
}

0 comments on commit eb9bd8c

Please sign in to comment.