Skip to content

Commit b90a165

Browse files
Merge pull request #15 from stefanak-michal/list_map_diff
From some version neo4j care about difference between empty list and map
2 parents 85a0b53 + 4a06df2 commit b90a165

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
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
}

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)