diff --git a/README.md b/README.md index 6aa9c59..05cb060 100644 --- a/README.md +++ b/README.md @@ -860,8 +860,8 @@ The interface only offers a single method: #### connect() -The `connect(string $uri): PromiseInterface` method -can be used to create a streaming connection to the given remote address. +The `connect(string $uri): PromiseInterface` method can be used to +create a streaming connection to the given remote address. It returns a [Promise](https://github.com/reactphp/promise) which either fulfills with a stream implementing [`ConnectionInterface`](#connectioninterface) diff --git a/composer.json b/composer.json index 5d3240f..6ee124f 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", "react/async": "^4 || ^3 || ^2", "react/promise-stream": "^1.4", - "react/promise-timer": "^1.9" + "react/promise-timer": "^1.10" }, "autoload": { "psr-4": { diff --git a/src/ConnectorInterface.php b/src/ConnectorInterface.php index 3dd78f1..1f07b75 100644 --- a/src/ConnectorInterface.php +++ b/src/ConnectorInterface.php @@ -51,7 +51,8 @@ interface ConnectorInterface * ``` * * @param string $uri - * @return \React\Promise\PromiseInterface resolves with a stream implementing ConnectionInterface on success or rejects with an Exception on error + * @return \React\Promise\PromiseInterface + * Resolves with a `ConnectionInterface` on success or rejects with an `Exception` on error. * @see ConnectionInterface */ public function connect($uri); diff --git a/src/SecureConnector.php b/src/SecureConnector.php index 6ec0383..17c229d 100644 --- a/src/SecureConnector.php +++ b/src/SecureConnector.php @@ -43,7 +43,7 @@ public function connect($uri) $context = $this->context; $encryption = $this->streamEncryption; $connected = false; - /** @var \React\Promise\PromiseInterface $promise */ + /** @var \React\Promise\PromiseInterface $promise */ $promise = $this->connector->connect( \str_replace('tls://', '', $uri) )->then(function (ConnectionInterface $connection) use ($context, $encryption, $uri, &$promise, &$connected) { diff --git a/src/StreamEncryption.php b/src/StreamEncryption.php index b7aa3f2..f91a359 100644 --- a/src/StreamEncryption.php +++ b/src/StreamEncryption.php @@ -44,11 +44,20 @@ public function __construct(LoopInterface $loop, $server = true) } } + /** + * @param Connection $stream + * @return \React\Promise\PromiseInterface + */ public function enable(Connection $stream) { return $this->toggle($stream, true); } + /** + * @param Connection $stream + * @param bool $toggle + * @return \React\Promise\PromiseInterface + */ public function toggle(Connection $stream, $toggle) { // pause actual stream instance to continue operation on raw stream socket @@ -98,6 +107,14 @@ public function toggle(Connection $stream, $toggle) }); } + /** + * @internal + * @param resource $socket + * @param Deferred $deferred + * @param bool $toggle + * @param int $method + * @return void + */ public function toggleCrypto($socket, Deferred $deferred, $toggle, $method) { $error = null;