Skip to content

Commit 8dcbbb9

Browse files
added extra parameter to required places
1 parent 81987c3 commit 8dcbbb9

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

Bolt.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,19 @@ private function packProtocolVersions(): string
191191
* @param string $name
192192
* @param string $user
193193
* @param string $password
194+
* @param array $extra
194195
* @return bool
195196
* @throws Exception
196197
*/
197-
public function init(string $name, string $user, string $password): bool
198+
public function init(string $name, string $user, string $password, array $extra = []): bool
198199
{
199200
if (!$this->handshake())
200201
return false;
201202

202203
if (self::$debug)
203204
echo 'INIT';
204205

205-
return $this->protocol->init($name, Bolt::$scheme, $user, $password);
206+
return $this->protocol->init($name, Bolt::$scheme, $user, $password, $extra);
206207
}
207208

208209
/**
@@ -212,12 +213,13 @@ public function init(string $name, string $user, string $password): bool
212213
* @param string $name
213214
* @param string $user
214215
* @param string $password
216+
* @param array $extra
215217
* @return bool
216218
* @throws Exception
217219
*/
218-
public function hello(string $name, string $user, string $password): bool
220+
public function hello(string $name, string $user, string $password, array $extra = []): bool
219221
{
220-
return $this->init($name, $user, $password);
222+
return $this->init($name, $user, $password, $extra);
221223
}
222224

223225
/**
@@ -237,47 +239,51 @@ public function run(string $statement, array $parameters = [], array $extra = []
237239
/**
238240
* Send PULL_ALL message
239241
* @version <4
242+
* @param array $extra
240243
* @return mixed Array of records or false on error. Last array element is success message.
241244
*/
242-
public function pullAll()
245+
public function pullAll(array $extra = [])
243246
{
244247
if (self::$debug)
245248
echo 'PULL';
246-
return $this->protocol->pullAll();
249+
return $this->protocol->pullAll($extra);
247250
}
248251

249252
/**
250253
* Send PULL message
251254
* @version >=4
252255
* @internal PULL_ALL alias
256+
* @param array $extra
253257
* @return mixed Array of records or false on error. Last array element is success message.
254258
*/
255-
public function pull()
259+
public function pull(array $extra = [])
256260
{
257-
return $this->pullAll();
261+
return $this->pullAll($extra);
258262
}
259263

260264
/**
261265
* Send DISCARD_ALL message
262266
* @version <4
267+
* @param array $extra
263268
* @return bool
264269
*/
265-
public function discardAll()
270+
public function discardAll(array $extra = [])
266271
{
267272
if (self::$debug)
268273
echo 'DISCARD';
269-
return $this->protocol->discardAll();
274+
return $this->protocol->discardAll($extra);
270275
}
271276

272277
/**
273278
* Send DISCARD message
274279
* @version >=4
275280
* @internal DISCARD_ALL alias
281+
* @param array $extra
276282
* @return bool
277283
*/
278-
public function discard(): bool
284+
public function discard(array $extra = []): bool
279285
{
280-
return $this->discardAll();
286+
return $this->discardAll($extra);
281287
}
282288

283289
/**

protocol/V4.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ public function pullAll(...$args)
2323

2424
public function pull(...$args)
2525
{
26-
if (empty($args)) {
27-
$args[0]['n'] = -1;
28-
}
26+
// The n specifies how many records to fetch. n=-1 will fetch all records.
27+
$args[0]['n'] = $args[0]['n'] ?? -1;
2928

3029
try {
3130
$msg = $this->packer->pack(0x3F, (object)($args[0] ?? []));
@@ -59,7 +58,7 @@ public function discardAll(...$args): bool
5958
public function discard(...$args): bool
6059
{
6160
try {
62-
$msg = $this->packer->pack(0x2F, $args[0] ?? []);
61+
$msg = $this->packer->pack(0x2F, (object)($args[0] ?? []));
6362
} catch (Exception $ex) {
6463
Bolt::error($ex->getMessage());
6564
return false;

0 commit comments

Comments
 (0)