Skip to content

Commit 9dabf7d

Browse files
Updated annotations. Added v4.4 support. Added missing return types. Fixed inheritance.
1 parent fa468e2 commit 9dabf7d

File tree

11 files changed

+77
-16
lines changed

11 files changed

+77
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Bolt
22
Bolt protocol library over TCP socket. Bolt protocol is created and in use for communication with [Neo4j](https://neo4j.com/) Graph database. The documentation is available at [https://7687.org/](https://7687.org/). This library is aimed to be low level and keep up with protocol messages architecture and specifications.
33

4-
![](https://img.shields.io/badge/phpunit-passed-success) ![](https://img.shields.io/badge/coverage-87%25-green) ![](https://img.shields.io/github/stars/stefanak-michal/Bolt) ![](https://img.shields.io/packagist/dt/stefanak-michal/bolt) ![](https://img.shields.io/github/v/release/stefanak-michal/bolt) ![](https://img.shields.io/github/commits-since/stefanak-michal/bolt/latest)
4+
![](https://img.shields.io/badge/phpunit-passed-success) ![](https://img.shields.io/badge/coverage-86%25-green) ![](https://img.shields.io/github/stars/stefanak-michal/Bolt) ![](https://img.shields.io/packagist/dt/stefanak-michal/bolt) ![](https://img.shields.io/github/v/release/stefanak-michal/bolt) ![](https://img.shields.io/github/commits-since/stefanak-michal/bolt/latest)
55

66
## [Version support](https://github.com/stefanak-michal/Bolt/wiki/Version-support)
77
## [Requirements](https://github.com/stefanak-michal/Bolt/wiki/Requirements)

src/Bolt.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,17 +389,17 @@ public function __destruct()
389389
}
390390

391391
/**
392-
* fetch the current routing table, if the message specification allows it.
393-
*
392+
* Fetch the current routing table, if the message specification allows it.
394393
* @param array|null $routing
395-
*
396-
* @return array{rt: array{servers: list<array{addresses: list<string>, role: 'WRITE'|'READ'|'ROUTE'}>, ttl: int}}|null
394+
* @return array|null
397395
*/
398396
public function route(?array $routing = null): ?array
399397
{
400-
if (!method_exists($this->protocol, 'route')) {
398+
if (self::$debug)
399+
echo 'ROUTE';
400+
401+
if (!method_exists($this->protocol, 'route'))
401402
return null;
402-
}
403403

404404
$routing = $routing ?? ['address' => $this->connection->getIp() . ':' . $this->connection->getPort()];
405405
return $this->protocol->route($routing);

src/protocol/V1.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
* @author Michal Stefanak
1313
* @link https://github.com/stefanak-michal/Bolt
14+
* @see https://7687.org/bolt/bolt-protocol-message-specification-1.html
1415
* @package Bolt\protocol
1516
*/
1617
class V1 extends AProtocol
@@ -48,7 +49,7 @@ public function init(...$args): array
4849
* @return array
4950
* @throws Exception
5051
*/
51-
public function run(...$args)
52+
public function run(...$args): array
5253
{
5354
if (empty($args)) {
5455
throw new PackException('Wrong arguments count');
@@ -70,7 +71,7 @@ public function run(...$args)
7071
* @return array
7172
* @throws Exception
7273
*/
73-
public function pullAll(...$args)
74+
public function pullAll(...$args): array
7475
{
7576
$this->write($this->packer->pack(0x3F));
7677

src/protocol/V2.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @author Michal Stefanak
99
* @link https://github.com/stefanak-michal/Bolt
10+
* @see https://7687.org/bolt/bolt-protocol-message-specification-2.html
1011
* @package Bolt\protocol
1112
*/
1213
class V2 extends V1

src/protocol/V3.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
* @author Michal Stefanak
1313
* @link https://github.com/stefanak-michal/Bolt
14+
* @see https://7687.org/bolt/bolt-protocol-message-specification-3.html
1415
* @package Bolt\protocol
1516
*/
1617
class V3 extends V2
@@ -53,11 +54,11 @@ public function hello(...$args): array
5354
}
5455

5556
/**
56-
* @param mixed ...$args
57+
* @param string|array ...$args query, parameters, extra
5758
* @return array
5859
* @throws Exception
5960
*/
60-
public function run(...$args)
61+
public function run(...$args): array
6162
{
6263
if (empty($args)) {
6364
throw new PackException('Wrong arguments count');

src/protocol/V4.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,28 @@
1010
*
1111
* @author Michal Stefanak
1212
* @link https://github.com/stefanak-michal/Bolt
13+
* @see https://7687.org/bolt/bolt-protocol-message-specification-4.html
1314
* @package Bolt\protocol
1415
*/
1516
class V4 extends V3
1617
{
1718

1819
/**
19-
* @param mixed ...$args
20+
* @param array ...$args
2021
* @return array
2122
* @throws Exception
2223
*/
23-
public function pullAll(...$args)
24+
public function pullAll(...$args): array
2425
{
2526
return $this->pull(...$args);
2627
}
2728

2829
/**
29-
* @param mixed ...$args
30+
* @param array ...$args
3031
* @return array
3132
* @throws Exception
3233
*/
33-
public function pull(...$args)
34+
public function pull(...$args): array
3435
{
3536
$this->write($this->packer->pack(0x3F, $args[0]));
3637

src/protocol/V4_1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
* @author Michal Stefanak
1313
* @link https://github.com/stefanak-michal/Bolt
14+
* @see https://7687.org/bolt/bolt-protocol-message-specification-4.html#version-41
1415
* @package Bolt\protocol
1516
*/
1617
class V4_1 extends V4

src/protocol/V4_2.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @author Michal Stefanak
99
* @link https://github.com/stefanak-michal/Bolt
10+
* @see https://7687.org/bolt/bolt-protocol-message-specification-4.html#version-42
1011
* @package Bolt\protocol
1112
*/
1213
class V4_2 extends V4_1

src/protocol/V4_3.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
*
1111
* @author Michal Stefanak
1212
* @link https://github.com/neo4j-php/Bolt
13+
* @see https://7687.org/bolt/bolt-protocol-message-specification-4.html#version-43
1314
* @package Bolt\protocol
1415
*/
15-
class V4_3 extends V4_1
16+
class V4_3 extends V4_2
1617
{
18+
/**
19+
* @param array|string|null ...$args
20+
* @return array
21+
* @throws MessageException
22+
* @throws PackException
23+
*/
1724
public function route(...$args): array
1825
{
1926
if (count($args) < 1) {

src/protocol/V4_4.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Bolt\protocol;
4+
5+
/**
6+
* Class Protocol version 4.4
7+
*
8+
* @author Michal Stefanak
9+
* @link https://github.com/neo4j-php/Bolt
10+
* @see https://7687.org/bolt/bolt-protocol-message-specification-4.html#version-44
11+
* @package Bolt\protocol
12+
*/
13+
class V4_4 extends V4_3
14+
{
15+
16+
}

0 commit comments

Comments
 (0)