Skip to content

Commit 81987c3

Browse files
Merge branch 'master' of https://github.com/stefanak-michal/Bolt
2 parents b813f19 + 69d765f commit 81987c3

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

PackStream/v1/Packer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ private function p($param): string
7272
$output .= $this->packString($param);
7373
} elseif (is_array($param)) {
7474
$keys = array_keys($param);
75-
if (count($keys) > 0 && count(array_filter($keys, 'is_int')) == count($keys)) {
75+
if (count($param) == 0 || count(array_filter($keys, 'is_int')) == count($keys)) {
7676
$output .= $this->packList($param);
7777
} else {
7878
$output .= $this->packMap($param);
7979
}
80+
} elseif (is_object($param)) {
81+
$output .= $this->packMap((array)$param);
8082
} else {
8183
throw new Exception('Not recognized type of parameter');
8284
}

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ extensions:
2323
- sockets https://www.php.net/manual/en/book.sockets.php
2424
- mbstring https://www.php.net/manual/en/book.mbstring.php
2525

26+
## Installation via composer
27+
Run the following command to install the latest applicable version of the package:
28+
29+
``composer require stefanak-michal/bolt``
30+
2631
## Usage
2732
See ``index.php`` file. It contains few examples how you can use this library. Of course you need to set up your username and password. This repository contains simple `autoload.php` file.
2833

@@ -60,6 +65,9 @@ Throwing exceptions is default behaviour. If you want, you can assign own callab
6065
## Author note
6166
I really like Neo4j and I wanted to use it with PHP. But after I looked on official php library, I was really disappointed. Too much dependencies. I don't like if I need to install 10 things because of one. First I decided to use HTTP API for communication, but it wasn't fast enough. I went through bolt protocol documentation and I said to myself, why not to create own simpler library?
6267

68+
## Another solutions
69+
https://neo4j.com/developer/php/
70+
6371
## Support
6472
If you like this project and you want to support me, buy me a tea :)
6573

autoload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22

3-
define('BASE_PATH', dirname(__DIR__));
43
define('DS', DIRECTORY_SEPARATOR);
54

65
spl_autoload_register(function ($name) {
76
$parts = explode("\\", $name);
87
$parts = array_filter($parts);
8+
array_shift($parts);
99

1010
/*
1111
* namespace calls
1212
*/
1313

1414
//compose standart namespaced path to file
15-
$path = BASE_PATH . DS . implode(DS, $parts) . '.php';
15+
$path = '.' . DS . implode(DS, $parts) . '.php';
1616
if (file_exists($path)) {
1717
require_once $path;
1818
return;

protocol/V3.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function run(...$args)
6666
}
6767

6868
try {
69-
$msg = $this->packer->pack(0x10, $args[0], $args[1] ?? [], $args[2] ?? []);
69+
$msg = $this->packer->pack(0x10, $args[0], (object)($args[1] ?? []), (object)($args[2] ?? []));
7070
} catch (Exception $ex) {
7171
Bolt::error($ex->getMessage());
7272
return false;
@@ -97,7 +97,7 @@ public function reset(...$args)
9797
public function begin(...$args): bool
9898
{
9999
try {
100-
$msg = $this->packer->pack(0x11, $args[0] ?? []);
100+
$msg = $this->packer->pack(0x11, (object)($args[0] ?? []));
101101
} catch (Exception $ex) {
102102
Bolt::error($ex->getMessage());
103103
return false;

protocol/V4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function pull(...$args)
2828
}
2929

3030
try {
31-
$msg = $this->packer->pack(0x3F, $args[0] ?? []);
31+
$msg = $this->packer->pack(0x3F, (object)($args[0] ?? []));
3232
} catch (Exception $ex) {
3333
Bolt::error($ex->getMessage());
3434
return false;

protocol/V4_1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function hello(...$args): bool
2929
'scheme' => $args[1],
3030
'principal' => $args[2],
3131
'credentials' => $args[3],
32-
'routing' => $args[4] ?? []
32+
'routing' => (object)($args[4] ?? [])
3333
]);
3434
} catch (Exception $ex) {
3535
Bolt::error($ex->getMessage());

0 commit comments

Comments
 (0)