33namespace React \Socket ;
44
55use React \EventLoop \LoopInterface ;
6- use React \Stream \Stream ;
76use React \Promise ;
7+ use InvalidArgumentException ;
8+ use RuntimeException ;
89
910final class TcpConnector implements ConnectorInterface
1011{
@@ -25,12 +26,12 @@ public function connect($uri)
2526
2627 $ parts = parse_url ($ uri );
2728 if (!$ parts || !isset ($ parts ['scheme ' ], $ parts ['host ' ], $ parts ['port ' ]) || $ parts ['scheme ' ] !== 'tcp ' ) {
28- return Promise \reject (new \ InvalidArgumentException ('Given URI " ' . $ uri . '" is invalid ' ));
29+ return Promise \reject (new InvalidArgumentException ('Given URI " ' . $ uri . '" is invalid ' ));
2930 }
3031
3132 $ ip = trim ($ parts ['host ' ], '[] ' );
3233 if (false === filter_var ($ ip , FILTER_VALIDATE_IP )) {
33- return Promise \reject (new \ InvalidArgumentException ('Given URI " ' . $ ip . '" does not contain a valid host IP ' ));
34+ return Promise \reject (new InvalidArgumentException ('Given URI " ' . $ ip . '" does not contain a valid host IP ' ));
3435 }
3536
3637 // use context given in constructor
@@ -80,7 +81,7 @@ public function connect($uri)
8081 );
8182
8283 if (false === $ socket ) {
83- return Promise \reject (new \ RuntimeException (
84+ return Promise \reject (new RuntimeException (
8485 sprintf ("Connection to %s failed: %s " , $ uri , $ errstr ),
8586 $ errno
8687 ));
@@ -106,7 +107,7 @@ private function waitForStreamOnce($stream)
106107 if (false === stream_socket_get_name ($ stream , true )) {
107108 fclose ($ stream );
108109
109- $ reject (new \ RuntimeException ('Connection refused ' ));
110+ $ reject (new RuntimeException ('Connection refused ' ));
110111 } else {
111112 $ resolve (new Connection ($ stream , $ loop ));
112113 }
@@ -115,7 +116,7 @@ private function waitForStreamOnce($stream)
115116 $ loop ->removeWriteStream ($ stream );
116117 fclose ($ stream );
117118
118- throw new \ RuntimeException ('Cancelled while waiting for TCP/IP connection to be established ' );
119+ throw new RuntimeException ('Cancelled while waiting for TCP/IP connection to be established ' );
119120 });
120121 }
121122}
0 commit comments