Skip to content

Commit f5610cd

Browse files
Merge pull request #5 from stefanak-michal/4_bolt_v7
updated to newest version
2 parents ae5ebfe + ef412fe commit f5610cd

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

.github/workflows/tests.2204.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php-version: ['8.0', '8.1', '8.2']
16+
php-version: ['8.1', '8.2', '8.3']
1717

1818
services:
1919
memgraph:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This library contains wrapper class to cover basic functionality with [Bolt libr
99
## Usage
1010

1111
```php
12-
Memgraph::$auth = \Bolt\helpers\Auth::none();
12+
Memgraph::$auth = ['scheme' => 'none'];
1313
$rows = Memgraph::query('RETURN $n as num', ['n' => 123]);
1414
```
1515

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"license": "MIT",
99
"minimum-stability": "stable",
1010
"require": {
11-
"php": "^8",
12-
"stefanak-michal/bolt": "^6"
11+
"php": "^8.1",
12+
"stefanak-michal/bolt": "^7"
1313
},
1414
"require-dev": {
1515
"phpunit/phpunit": "^9"

src/Memgraph.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Bolt\Bolt;
44
use Bolt\connection\{Socket, StreamSocket};
5-
use Bolt\protocol\{AProtocol, Response, V4_3, V4_1, V4, V3};
5+
use Bolt\protocol\{AProtocol, Response, V5_2, V4_3, V4_1, V4};
66

77
/**
88
* Class Memgraph - adapter for Bolt library
@@ -25,21 +25,21 @@ class Memgraph
2525

2626
/**
2727
* Set your authentification
28-
* @see \Bolt\helpers\Auth
28+
* @link https://github.com/neo4j-php/Bolt?tab=readme-ov-file#authentification
2929
*/
3030
public static array $auth;
3131

3232
public static string $host = '127.0.0.1';
3333
public static int $port = 7687;
3434
public static float $timeout = 15;
3535

36-
private static AProtocol|V4_3|V4_1|V4|V3|null $protocol = null;
36+
private static AProtocol|V5_2|V4_3|V4_1|V4|null $protocol = null;
3737
private static array $statistics;
3838

3939
/**
4040
* Get connection protocol for bolt communication
4141
*/
42-
protected static function getProtocol(): AProtocol|V4_3|V4_1|V4|V3
42+
protected static function getProtocol(): AProtocol|V5_2|V4_3|V4_1|V4
4343
{
4444
if (is_null(self::$protocol)) {
4545
try {
@@ -57,10 +57,10 @@ protected static function getProtocol(): AProtocol|V4_3|V4_1|V4|V3
5757
self::$protocol = $bolt->setProtocolVersions(5.2, 4.3, 4.1, 4.0)->build();
5858

5959
if (version_compare(self::$protocol->getVersion(), '5.2', '>=')) {
60-
self::$protocol->hello();
61-
self::$protocol->logon(self::$auth);
60+
self::$protocol->hello()->getResponse();
61+
self::$protocol->logon(self::$auth)->getResponse();
6262
} else {
63-
self::$protocol->hello(self::$auth);
63+
self::$protocol->hello(self::$auth)->getResponse();
6464
}
6565

6666
register_shutdown_function(function () {
@@ -91,19 +91,19 @@ public static function query(string $query, array $params = [], array $extra = [
9191
$run = $all = null;
9292
try {
9393
$runResponse = self::getProtocol()->run($query, $params, $extra)->getResponse();
94-
if ($runResponse->getSignature() != Response::SIGNATURE_SUCCESS) {
95-
throw new Exception(implode(' ', $runResponse->getContent()));
94+
if ($runResponse->signature != \Bolt\enum\Signature::SUCCESS) {
95+
throw new Exception(implode(' ', $runResponse->content));
9696
}
97-
$run = $runResponse->getContent();
97+
$run = $runResponse->content;
9898

9999
foreach (self::getProtocol()->pull()->getResponses() as $response) {
100-
if ($response->getSignature() == Response::SIGNATURE_IGNORED || $response->getSignature() == Response::SIGNATURE_FAILURE) {
101-
throw new Exception(implode(' ', $runResponse->getContent()));
100+
if ($response->signature == \Bolt\enum\Signature::IGNORED || $response->signature == \Bolt\enum\Signature::FAILURE) {
101+
throw new Exception(implode(' ', $runResponse->content));
102102
}
103-
$all[] = $response->getContent();
103+
$all[] = $response->content;
104104
}
105105
} catch (Exception $e) {
106-
self::getProtocol()->reset();
106+
self::getProtocol()->reset()->getResponse();
107107
self::handleException($e);
108108
return [];
109109
}
@@ -116,7 +116,7 @@ public static function query(string $query, array $params = [], array $extra = [
116116
if (is_callable(self::$logHandler)) {
117117
$time = 0;
118118
foreach ($last as $key => $value) {
119-
if (substr($key, -5) == '_time') {
119+
if (str_ends_with($key, '_time')) {
120120
$time += $value;
121121
}
122122
}
@@ -173,15 +173,15 @@ public static function begin(array $extra = []): bool
173173
{
174174
try {
175175
$response = self::getProtocol()->begin($extra)->getResponse();
176-
if ($response->getSignature() != Response::SIGNATURE_SUCCESS) {
177-
throw new Exception(implode(' ', $response->getContent()));
176+
if ($response->signature != \Bolt\enum\Signature::SUCCESS) {
177+
throw new Exception(implode(' ', $response->content));
178178
}
179179
if (is_callable(self::$logHandler)) {
180180
call_user_func(self::$logHandler, 'BEGIN TRANSACTION');
181181
}
182182
return true;
183183
} catch (Exception $e) {
184-
self::getProtocol()->reset();
184+
self::getProtocol()->reset()->getResponse();
185185
self::handleException($e);
186186
}
187187
return false;
@@ -196,15 +196,15 @@ public static function commit(): bool
196196
{
197197
try {
198198
$response = self::getProtocol()->commit()->getResponse();
199-
if ($response->getSignature() != Response::SIGNATURE_SUCCESS) {
200-
throw new Exception(implode(' ', $response->getContent()));
199+
if ($response->signature != \Bolt\enum\Signature::SUCCESS) {
200+
throw new Exception(implode(' ', $response->content));
201201
}
202202
if (is_callable(self::$logHandler)) {
203203
call_user_func(self::$logHandler, 'COMMIT TRANSACTION');
204204
}
205205
return true;
206206
} catch (Exception $e) {
207-
self::getProtocol()->reset();
207+
self::getProtocol()->reset()->getResponse();
208208
self::handleException($e);
209209
}
210210
return false;
@@ -219,15 +219,15 @@ public static function rollback(): bool
219219
{
220220
try {
221221
$response = self::getProtocol()->rollback()->getResponse();
222-
if ($response->getSignature() != Response::SIGNATURE_SUCCESS) {
223-
throw new Exception(implode(' ', $response->getContent()));
222+
if ($response->signature != \Bolt\enum\Signature::SUCCESS) {
223+
throw new Exception(implode(' ', $response->content));
224224
}
225225
if (is_callable(self::$logHandler)) {
226226
call_user_func(self::$logHandler, 'ROLLBACK TRANSACTION');
227227
}
228228
return true;
229229
} catch (Exception $e) {
230-
self::getProtocol()->reset();
230+
self::getProtocol()->reset()->getResponse();
231231
self::handleException($e);
232232
}
233233
return false;

tests/MemgraphTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Memgraph\tests;
44

55
use Memgraph;
6-
use Bolt\helpers\Auth;
76
use Bolt\protocol\IStructure;
87
use Bolt\protocol\v1\structures\{
98
Date,
@@ -23,7 +22,7 @@ class MemgraphTest extends TestCase
2322
public static function setUpBeforeClass(): void
2423
{
2524
parent::setUpBeforeClass();
26-
Memgraph::$auth = Auth::none();
25+
Memgraph::$auth = ['scheme' => 'none'];
2726
}
2827

2928
/**

0 commit comments

Comments
 (0)