@@ -143,7 +143,23 @@ public function getAuthentication(): AuthenticateInterface
143
143
*/
144
144
public function isOpen (): bool
145
145
{
146
- return !in_array ($ this ->protocol ()->serverState , [ServerState::DISCONNECTED , ServerState::DEFUNCT ], true );
146
+ return !in_array (
147
+ $ this ->protocol ()->serverState ,
148
+ [ServerState::DISCONNECTED , ServerState::DEFUNCT ],
149
+ true
150
+ );
151
+ }
152
+
153
+ /**
154
+ * @psalm-mutation-free
155
+ */
156
+ public function isStreaming (): bool
157
+ {
158
+ return in_array (
159
+ $ this ->protocol ()->serverState ,
160
+ [ServerState::STREAMING , ServerState::TX_STREAMING ],
161
+ true
162
+ );
147
163
}
148
164
149
165
public function setTimeout (float $ timeout ): void
@@ -154,7 +170,8 @@ public function setTimeout(float $timeout): void
154
170
public function consumeResults (): void
155
171
{
156
172
$ this ->logger ?->log(LogLevel::DEBUG , 'Consuming results ' );
157
- if ($ this ->protocol ()->serverState !== ServerState::STREAMING && $ this ->protocol ()->serverState !== ServerState::TX_STREAMING ) {
173
+ if ($ this ->protocol ()->serverState !== ServerState::STREAMING && $ this ->protocol (
174
+ )->serverState !== ServerState::TX_STREAMING ) {
158
175
$ this ->subscribedResults = [];
159
176
160
177
return ;
@@ -225,8 +242,14 @@ public function discard(?int $qid): void
225
242
*
226
243
* @return BoltMeta
227
244
*/
228
- public function run (string $ text , array $ parameters , ?string $ database , ?float $ timeout , BookmarkHolder $ holder , ?AccessMode $ mode ): array
229
- {
245
+ public function run (
246
+ string $ text ,
247
+ array $ parameters ,
248
+ ?string $ database ,
249
+ ?float $ timeout ,
250
+ BookmarkHolder $ holder ,
251
+ ?AccessMode $ mode
252
+ ): array {
230
253
$ extra = $ this ->buildRunExtra ($ database , $ timeout , $ holder , $ mode );
231
254
$ this ->logger ?->log(LogLevel::DEBUG , 'RUN ' , $ extra );
232
255
$ response = $ this ->protocol ()
@@ -298,10 +321,15 @@ public function pull(?int $qid, ?int $fetchSize): array
298
321
}
299
322
300
323
public function __destruct ()
324
+ {
325
+ $ this ->close ();
326
+ }
327
+
328
+ public function close (): void
301
329
{
302
330
try {
303
331
if ($ this ->isOpen ()) {
304
- if ($ this ->protocol ()-> serverState === ServerState:: STREAMING || $ this -> protocol ()-> serverState === ServerState:: TX_STREAMING ) {
332
+ if ($ this ->isStreaming () ) {
305
333
$ this ->consumeResults ();
306
334
}
307
335
0 commit comments