Skip to content

Commit 41580db

Browse files
authored
Merge pull request #309 from clue-labs/template-types
Use Promise v3 template types
2 parents 5603979 + fd252bd commit 41580db

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,8 @@ The interface only offers a single method:
860860

861861
#### connect()
862862

863-
The `connect(string $uri): PromiseInterface<ConnectionInterface,Exception>` method
864-
can be used to create a streaming connection to the given remote address.
863+
The `connect(string $uri): PromiseInterface<ConnectionInterface>` method can be used to
864+
create a streaming connection to the given remote address.
865865

866866
It returns a [Promise](https://github.com/reactphp/promise) which either
867867
fulfills with a stream implementing [`ConnectionInterface`](#connectioninterface)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35",
3838
"react/async": "^4 || ^3 || ^2",
3939
"react/promise-stream": "^1.4",
40-
"react/promise-timer": "^1.9"
40+
"react/promise-timer": "^1.10"
4141
},
4242
"autoload": {
4343
"psr-4": {

src/ConnectorInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ interface ConnectorInterface
5151
* ```
5252
*
5353
* @param string $uri
54-
* @return \React\Promise\PromiseInterface resolves with a stream implementing ConnectionInterface on success or rejects with an Exception on error
54+
* @return \React\Promise\PromiseInterface<ConnectionInterface>
55+
* Resolves with a `ConnectionInterface` on success or rejects with an `Exception` on error.
5556
* @see ConnectionInterface
5657
*/
5758
public function connect($uri);

src/SecureConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function connect($uri)
4343
$context = $this->context;
4444
$encryption = $this->streamEncryption;
4545
$connected = false;
46-
/** @var \React\Promise\PromiseInterface $promise */
46+
/** @var \React\Promise\PromiseInterface<ConnectionInterface> $promise */
4747
$promise = $this->connector->connect(
4848
\str_replace('tls://', '', $uri)
4949
)->then(function (ConnectionInterface $connection) use ($context, $encryption, $uri, &$promise, &$connected) {

src/StreamEncryption.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,20 @@ public function __construct(LoopInterface $loop, $server = true)
4444
}
4545
}
4646

47+
/**
48+
* @param Connection $stream
49+
* @return \React\Promise\PromiseInterface<Connection>
50+
*/
4751
public function enable(Connection $stream)
4852
{
4953
return $this->toggle($stream, true);
5054
}
5155

56+
/**
57+
* @param Connection $stream
58+
* @param bool $toggle
59+
* @return \React\Promise\PromiseInterface<Connection>
60+
*/
5261
public function toggle(Connection $stream, $toggle)
5362
{
5463
// pause actual stream instance to continue operation on raw stream socket
@@ -98,6 +107,14 @@ public function toggle(Connection $stream, $toggle)
98107
});
99108
}
100109

110+
/**
111+
* @internal
112+
* @param resource $socket
113+
* @param Deferred<null> $deferred
114+
* @param bool $toggle
115+
* @param int $method
116+
* @return void
117+
*/
101118
public function toggleCrypto($socket, Deferred $deferred, $toggle, $method)
102119
{
103120
$error = null;

0 commit comments

Comments
 (0)