66use Clue \React \Redis \Io \StreamingClient ;
77use Evenement \EventEmitter ;
88use React \EventLoop \Loop ;
9- use React \EventLoop \LoopInterface ;
109use React \Promise \PromiseInterface ;
1110use React \Socket \ConnectorInterface ;
1211use React \Stream \Util ;
@@ -40,9 +39,6 @@ class RedisClient extends EventEmitter
4039 /** @var ?PromiseInterface<StreamingClient> */
4140 private $ promise = null ;
4241
43- /** @var LoopInterface */
44- private $ loop ;
45-
4642 /** @var float */
4743 private $ idlePeriod = 0.001 ;
4844
@@ -58,12 +54,7 @@ class RedisClient extends EventEmitter
5854 /** @var array<string,bool> */
5955 private $ psubscribed = [];
6056
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 )
6758 {
6859 $ args = [];
6960 \parse_str ((string ) \parse_url ($ url , \PHP_URL_QUERY ), $ args );
@@ -72,8 +63,7 @@ public function __construct($url, ConnectorInterface $connector = null, LoopInte
7263 }
7364
7465 $ this ->target = $ url ;
75- $ this ->loop = $ loop ?: Loop::get ();
76- $ this ->factory = new Factory ($ this ->loop , $ connector );
66+ $ this ->factory = new Factory ($ connector );
7767 }
7868
7969 /**
@@ -102,7 +92,7 @@ private function client(): PromiseInterface
10292 $ this ->subscribed = $ this ->psubscribed = [];
10393
10494 if ($ this ->idleTimer !== null ) {
105- $ this -> loop -> cancelTimer ($ this ->idleTimer );
95+ Loop:: cancelTimer ($ this ->idleTimer );
10696 $ this ->idleTimer = null ;
10797 }
10898 });
@@ -235,7 +225,7 @@ public function close(): void
235225 }
236226
237227 if ($ this ->idleTimer !== null ) {
238- $ this -> loop -> cancelTimer ($ this ->idleTimer );
228+ Loop:: cancelTimer ($ this ->idleTimer );
239229 $ this ->idleTimer = null ;
240230 }
241231
@@ -248,7 +238,7 @@ private function awake(): void
248238 ++$ this ->pending ;
249239
250240 if ($ this ->idleTimer !== null ) {
251- $ this -> loop -> cancelTimer ($ this ->idleTimer );
241+ Loop:: cancelTimer ($ this ->idleTimer );
252242 $ this ->idleTimer = null ;
253243 }
254244 }
@@ -258,7 +248,7 @@ private function idle(): void
258248 --$ this ->pending ;
259249
260250 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 () {
262252 assert ($ this ->promise instanceof PromiseInterface);
263253 $ this ->promise ->then (function (StreamingClient $ redis ) {
264254 $ redis ->close ();
0 commit comments