1616use React \EventLoop \Loop ;
1717use React \EventLoop \TimerInterface ;
1818use React \Promise \Deferred ;
19- use React \Promise \ExtendedPromiseInterface ;
19+ use React \Promise \PromiseInterface ;
2020use RuntimeException ;
2121use SplObjectStorage ;
2222
@@ -50,9 +50,7 @@ class DaemonDb
5050 protected ?array $ dbConfig ;
5151
5252 protected ?RetryUnless $ pendingReconnection = null ;
53-
54- /** @var ExtendedPromiseInterface|null */
55- protected $ pendingDisconnect ;
53+ protected ?PromiseInterface $ pendingDisconnect = null ;
5654 protected ?TimerInterface $ refreshTimer = null ;
5755 protected ?TimerInterface $ schemaCheckTimer = null ;
5856
@@ -117,7 +115,7 @@ protected function onNewConfig($config)
117115 }
118116 }
119117
120- protected function establishConnection ($ config ): ExtendedPromiseInterface
118+ protected function establishConnection ($ config ): PromiseInterface
121119 {
122120 if ($ this ->db !== null ) {
123121 $ this ->logger ->error ('Trying to establish a connection while being connected ' );
@@ -227,7 +225,7 @@ protected function onConnected()
227225 }
228226 }
229227
230- protected function reconnect (): ExtendedPromiseInterface
228+ protected function reconnect (): PromiseInterface
231229 {
232230 $ promise = $ this ->disconnect ()->then (function () {
233231 return $ this ->connect ();
@@ -236,14 +234,10 @@ protected function reconnect(): ExtendedPromiseInterface
236234 exit (1 );
237235 });
238236
239- assert ($ promise instanceof ExtendedPromiseInterface);
240237 return $ promise ;
241238 }
242239
243- /**
244- * @return \React\Promise\ExtendedPromiseInterface
245- */
246- public function connect ()
240+ public function connect (): PromiseInterface
247241 {
248242 if ($ this ->db === null ) {
249243 if ($ this ->dbConfig ) {
@@ -254,7 +248,7 @@ public function connect()
254248 return resolve (null );
255249 }
256250
257- protected function stopRegisteredComponents (): ExtendedPromiseInterface
251+ protected function stopRegisteredComponents (): PromiseInterface
258252 {
259253 $ pending = new Deferred ();
260254 $ pendingComponents = new SplObjectStorage ();
@@ -273,12 +267,12 @@ protected function stopRegisteredComponents(): ExtendedPromiseInterface
273267 return $ pending ->promise ();
274268 }
275269
276- public function disconnect (): ExtendedPromiseInterface
270+ public function disconnect (): PromiseInterface
277271 {
278272 if (! $ this ->db ) {
279273 return resolve (null );
280274 }
281- if ($ this ->pendingDisconnect instanceof ExtendedPromiseInterface ) {
275+ if ($ this ->pendingDisconnect instanceof PromiseInterface ) {
282276 return $ this ->pendingDisconnect ;
283277 }
284278
@@ -297,7 +291,6 @@ public function disconnect(): ExtendedPromiseInterface
297291 $ this ->db = null ;
298292 $ this ->pendingDisconnect = null ;
299293 });
300- assert ($ pending instanceof ExtendedPromiseInterface);
301294
302295 return $ pending ;
303296 }
0 commit comments