6
6
use Clue \React \Redis \Io \StreamingClient ;
7
7
use Evenement \EventEmitter ;
8
8
use React \EventLoop \Loop ;
9
- use React \EventLoop \LoopInterface ;
10
9
use React \Promise \PromiseInterface ;
11
10
use React \Socket \ConnectorInterface ;
12
11
use React \Stream \Util ;
@@ -40,9 +39,6 @@ class RedisClient extends EventEmitter
40
39
/** @var ?PromiseInterface<StreamingClient> */
41
40
private $ promise = null ;
42
41
43
- /** @var LoopInterface */
44
- private $ loop ;
45
-
46
42
/** @var float */
47
43
private $ idlePeriod = 0.001 ;
48
44
@@ -58,12 +54,7 @@ class RedisClient extends EventEmitter
58
54
/** @var array<string,bool> */
59
55
private $ psubscribed = [];
60
56
61
- /**
62
- * @param string $url
63
- * @param ?ConnectorInterface $connector
64
- * @param ?LoopInterface $loop
65
- */
66
- public function __construct ($ url , ConnectorInterface $ connector = null , LoopInterface $ loop = null )
57
+ public function __construct (string $ url , ConnectorInterface $ connector = null )
67
58
{
68
59
$ args = [];
69
60
\parse_str ((string ) \parse_url ($ url , \PHP_URL_QUERY ), $ args );
@@ -72,8 +63,7 @@ public function __construct($url, ConnectorInterface $connector = null, LoopInte
72
63
}
73
64
74
65
$ this ->target = $ url ;
75
- $ this ->loop = $ loop ?: Loop::get ();
76
- $ this ->factory = new Factory ($ this ->loop , $ connector );
66
+ $ this ->factory = new Factory ($ connector );
77
67
}
78
68
79
69
/**
@@ -102,7 +92,7 @@ private function client(): PromiseInterface
102
92
$ this ->subscribed = $ this ->psubscribed = [];
103
93
104
94
if ($ this ->idleTimer !== null ) {
105
- $ this -> loop -> cancelTimer ($ this ->idleTimer );
95
+ Loop:: cancelTimer ($ this ->idleTimer );
106
96
$ this ->idleTimer = null ;
107
97
}
108
98
});
@@ -235,7 +225,7 @@ public function close(): void
235
225
}
236
226
237
227
if ($ this ->idleTimer !== null ) {
238
- $ this -> loop -> cancelTimer ($ this ->idleTimer );
228
+ Loop:: cancelTimer ($ this ->idleTimer );
239
229
$ this ->idleTimer = null ;
240
230
}
241
231
@@ -248,7 +238,7 @@ private function awake(): void
248
238
++$ this ->pending ;
249
239
250
240
if ($ this ->idleTimer !== null ) {
251
- $ this -> loop -> cancelTimer ($ this ->idleTimer );
241
+ Loop:: cancelTimer ($ this ->idleTimer );
252
242
$ this ->idleTimer = null ;
253
243
}
254
244
}
@@ -258,7 +248,7 @@ private function idle(): void
258
248
--$ this ->pending ;
259
249
260
250
if ($ this ->pending < 1 && $ this ->idlePeriod >= 0 && !$ this ->subscribed && !$ this ->psubscribed && $ this ->promise !== null ) {
261
- $ this ->idleTimer = $ this -> loop -> addTimer ($ this ->idlePeriod , function () {
251
+ $ this ->idleTimer = Loop:: addTimer ($ this ->idlePeriod , function () {
262
252
assert ($ this ->promise instanceof PromiseInterface);
263
253
$ this ->promise ->then (function (StreamingClient $ redis ) {
264
254
$ redis ->close ();
0 commit comments