Skip to content

Commit 3254553

Browse files
Merge pull request #169 from stefanak-michal/bolt_v6
New bolt version 6
2 parents c3e7e1c + 8d17f53 commit 3254553

File tree

18 files changed

+460
-26
lines changed

18 files changed

+460
-26
lines changed

.github/workflows/neo4j.2025.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests with Neo4j^2025 on PHP^8
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
jobs:
8+
db-tests-2025-2204:
9+
runs-on: ubuntu-22.04
10+
name: "Running Integration tests for PHP ${{ matrix.php-version }} on Neo4j ${{ matrix.neo4j-version }}"
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
neo4j-version: ['2025.09', '2025']
15+
php-version: ['8.1', '8.2', '8.3', '8.4']
16+
17+
services:
18+
neo4j:
19+
image: neo4j:${{ matrix.neo4j-version }}
20+
env:
21+
NEO4J_AUTH: neo4j/nothing123
22+
NEO4J_PLUGINS: '["apoc"]'
23+
ports:
24+
- 7687:7687
25+
- 7474:7474
26+
options: >-
27+
--health-cmd "wget http://localhost:7474 || exit 1"
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php-version }}
37+
extensions: mbstring, sockets
38+
coverage: xdebug
39+
ini-values: max_execution_time=0
40+
41+
- name: Install dependencies
42+
run: composer install --no-progress
43+
44+
- name: Test with phpunit
45+
env:
46+
GDB_USERNAME: neo4j
47+
GDB_PASSWORD: nothing123
48+
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite "Database"
File renamed without changes.

.github/workflows/db.50.2204.yml renamed to .github/workflows/neo4j.5.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
neo4j-version: ['5.4', '5.6', '5.8', '5.12', '5.13', '5.23', '5.26', '2025']
14+
neo4j-version: ['5.4', '5.6', '5.8', '5.12', '5.22', '5.25', '5.26']
1515
php-version: ['8.1', '8.2', '8.3', '8.4']
1616

1717
services:
File renamed without changes.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Website: https://stefanak.serv00.net/
3030

3131
## :label: Version support
3232

33-
We are trying to keep up and this library supports **Bolt <= 5.8**.
33+
We are trying to keep up and this library supports **Bolt <= 6**.
3434

3535
## :books: Supported ecosystems
3636

@@ -199,7 +199,7 @@ foreach ($protocol->getResponses() as $response) {
199199
}
200200
```
201201

202-
:information_source: Default settings for bolt protocol version is 4.3, 4.4 and 5.0 to 5.8. If you are within this list you can ommit calling `$bolt->setProtocolVersions();`.
202+
:information_source: Default settings for bolt protocol version is 4.3, 4.4, 5.0 to 5.8 and 6. If you are within this list you can ommit calling `$bolt->setProtocolVersions();`.
203203

204204
### Autoload
205205

src/Bolt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(private IConnection $connection)
3434
$this->track();
3535
}
3636

37-
$this->setProtocolVersions('5.8.8', '4.4.4');
37+
$this->setProtocolVersions(6, '5.8.8', '4.4.4');
3838
}
3939

4040
private function track(): void

src/packstream/v1/Packer.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ private function packString(string $str): iterable
131131

132132
private function packFloat(float $value): iterable
133133
{
134-
$packed = pack('d', $value);
135-
yield chr(0xC1) . ($this->littleEndian ? strrev($packed) : $packed);
134+
yield chr(0xC1) . pack('E', $value);
136135
}
137136

138137
/**
@@ -227,13 +226,7 @@ private function packStructure(IStructure $structure): iterable
227226
throw new PackException('Undefined parameter type in structure ' . $structure);
228227
}
229228

230-
$packerMethod = $type->getName();
231-
if ($packerMethod === 'int') {
232-
$packerMethod = 'integer';
233-
}
234-
$packerMethod = 'pack' . ucfirst($packerMethod);
235-
236-
yield from [$this, $packerMethod]($structure->{$parameter->getName()});
229+
yield from $this->p($structure->{$parameter->getName()});
237230
}
238231
}
239232

@@ -242,7 +235,7 @@ private function packStructure(IStructure $structure): iterable
242235
*/
243236
private function packByteArray(Bytes $bytes): iterable
244237
{
245-
$size = count($bytes);
238+
$size = mb_strlen($bytes, '8bit');
246239
if ($size < self::MEDIUM) {
247240
yield chr(0xCC) . pack('C', $size) . $bytes;
248241
} elseif ($size < self::LARGE) {

src/packstream/v1/Unpacker.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function u(): mixed
103103
if ($output !== null) {
104104
return $output;
105105
}
106-
$output = $this->unpackStruct($marker);
106+
$output = $this->unpackStructure($marker);
107107
if ($output !== null) {
108108
return $output;
109109
}
@@ -120,7 +120,7 @@ private function u(): mixed
120120
* @return array|IStructure|null
121121
* @throws UnpackException
122122
*/
123-
private function unpackStruct(int $marker): array|IStructure|null
123+
private function unpackStructure(int $marker): array|IStructure|null
124124
{
125125
if ($marker >> 4 == 0b1011) { //TINY_STRUCT
126126
$size = 0b10110000 ^ $marker;
@@ -238,7 +238,7 @@ private function unpackFloat(int $marker): ?float
238238
{
239239
if ($marker == 0xC1) {
240240
$value = $this->next(8);
241-
return (float)unpack('d', $this->littleEndian ? strrev($value) : $value)[1];
241+
return (float)unpack('E', $value)[1];
242242
} else {
243243
return null;
244244
}

src/protocol/V6.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Bolt\protocol;
4+
5+
/**
6+
* Class Protocol version 6
7+
*
8+
* @author Michal Stefanak
9+
* @link https://github.com/neo4j-php/Bolt
10+
* @see https://www.neo4j.com/docs/bolt/current/bolt/message/
11+
* @package Bolt\protocol
12+
*/
13+
class V6 extends AProtocol
14+
{
15+
use \Bolt\protocol\v6\AvailableStructures;
16+
use \Bolt\protocol\v5_1\ServerStateTransition;
17+
18+
use \Bolt\protocol\v1\ResetMessage;
19+
20+
use \Bolt\protocol\v3\RunMessage;
21+
use \Bolt\protocol\v3\BeginMessage;
22+
use \Bolt\protocol\v3\CommitMessage;
23+
use \Bolt\protocol\v3\RollbackMessage;
24+
use \Bolt\protocol\v3\GoodbyeMessage;
25+
26+
use \Bolt\protocol\v4\PullMessage;
27+
use \Bolt\protocol\v4\DiscardMessage;
28+
29+
use \Bolt\protocol\v4_4\RouteMessage;
30+
31+
use \Bolt\protocol\v5_1\LogonMessage;
32+
use \Bolt\protocol\v5_1\LogoffMessage;
33+
34+
use \Bolt\protocol\v5_3\HelloMessage;
35+
36+
use \Bolt\protocol\v5_4\TelemetryMessage;
37+
}

src/protocol/v3/HelloMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait HelloMessage
1212
* The HELLO message request the connection to be authorized for use with the remote database.
1313
*
1414
* @link https://www.neo4j.com/docs/bolt/current/bolt/message/#messages-hello
15-
* @param array $extra Use \Bolt\helpers\Auth to generate appropriate array
15+
* @param array $extra
1616
* @throws BoltException
1717
*/
1818
public function hello(array $extra): static

0 commit comments

Comments
 (0)