@@ -54,7 +54,7 @@ final class HappyEyeBallsConnectionBuilder
5454 public $ lastError6 ;
5555 public $ lastError4 ;
5656
57- public function __construct (LoopInterface $ loop , ConnectorInterface $ connector , ResolverInterface $ resolver , $ uri , $ host , $ parts )
57+ public function __construct (LoopInterface $ loop , ConnectorInterface $ connector , ResolverInterface $ resolver , string $ uri , string $ host , array $ parts )
5858 {
5959 $ this ->loop = $ loop ;
6060 $ this ->connector = $ connector ;
@@ -64,7 +64,7 @@ public function __construct(LoopInterface $loop, ConnectorInterface $connector,
6464 $ this ->parts = $ parts ;
6565 }
6666
67- public function connect ()
67+ public function connect (): PromiseInterface
6868 {
6969 return new Promise (function ($ resolve , $ reject ) {
7070 $ lookupResolve = function ($ type ) use ($ resolve , $ reject ) {
@@ -123,7 +123,7 @@ public function connect()
123123 * always resolves with a list of IP addresses on success or an empty
124124 * list on error.
125125 */
126- public function resolve ($ type , $ reject )
126+ public function resolve (int $ type , callable $ reject ): PromiseInterface
127127 {
128128 return $ this ->resolver ->resolveAll ($ this ->host , $ type )->then (null , function (\Exception $ e ) use ($ type , $ reject ) {
129129 unset($ this ->resolverPromises [$ type ]);
@@ -159,7 +159,7 @@ public function resolve($type, $reject)
159159 /**
160160 * @internal
161161 */
162- public function check ($ resolve , $ reject )
162+ public function check (callable $ resolve , callable $ reject )
163163 {
164164 $ ip = \array_shift ($ this ->connectQueue );
165165
@@ -168,13 +168,13 @@ public function check($resolve, $reject)
168168 \end ($ this ->connectionPromises );
169169 $ index = \key ($ this ->connectionPromises );
170170
171- $ this ->connectionPromises [$ index ]->then (function ($ connection ) use ($ index , $ resolve ) {
171+ $ this ->connectionPromises [$ index ]->then (function ($ connection ) use ($ index , $ resolve ): void {
172172 unset($ this ->connectionPromises [$ index ]);
173173
174174 $ this ->cleanUp ();
175175
176176 $ resolve ($ connection );
177- }, function (\Exception $ e ) use ($ index , $ ip , $ resolve , $ reject ) {
177+ }, function (\Exception $ e ) use ($ index , $ ip , $ resolve , $ reject ): void {
178178 unset($ this ->connectionPromises [$ index ]);
179179
180180 $ this ->failureCount ++;
@@ -228,8 +228,9 @@ public function check($resolve, $reject)
228228
229229 /**
230230 * @internal
231+ * @return PromiseInterface<ConnectionInterface>
231232 */
232- public function attemptConnection ($ ip )
233+ public function attemptConnection ($ ip ): PromiseInterface
233234 {
234235 $ uri = Connector::uri ($ this ->parts , $ this ->host , $ ip );
235236
@@ -239,7 +240,7 @@ public function attemptConnection($ip)
239240 /**
240241 * @internal
241242 */
242- public function cleanUp ()
243+ public function cleanUp (): void
243244 {
244245 // clear list of outstanding IPs to avoid creating new connections
245246 $ this ->connectQueue = [];
@@ -267,7 +268,7 @@ public function cleanUp()
267268 /**
268269 * @internal
269270 */
270- public function hasBeenResolved ()
271+ public function hasBeenResolved (): bool
271272 {
272273 foreach ($ this ->resolved as $ typeHasBeenResolved ) {
273274 if ($ typeHasBeenResolved === false ) {
@@ -286,6 +287,8 @@ public function hasBeenResolved()
286287 * @link https://tools.ietf.org/html/rfc8305#section-4
287288 *
288289 * @internal
290+ *
291+ * @param array<string> $ips
289292 */
290293 public function mixIpsIntoConnectQueue (array $ ips )
291294 {
@@ -307,7 +310,7 @@ public function mixIpsIntoConnectQueue(array $ips)
307310 * @internal
308311 * @return string
309312 */
310- public function error ()
313+ public function error (): string
311314 {
312315 if ($ this ->lastError4 === $ this ->lastError6 ) {
313316 $ message = $ this ->lastError6 ;
0 commit comments