Skip to content

Commit

Permalink
Work around legacy HHVM < 3.8 (does not support TLS connections)
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Apr 6, 2017
1 parent 7bcdfde commit 1529ce8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/SecureConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(ConnectorInterface $connector, LoopInterface $loop,
public function connect($uri)
{
if (!function_exists('stream_socket_enable_crypto')) {
return Promise\reject(new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)'));
return Promise\reject(new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)')); // @codeCoverageIgnore
}

if (strpos($uri, '://') === false) {
Expand Down
5 changes: 5 additions & 0 deletions src/SecureServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,16 @@ final class SecureServer extends EventEmitter implements ServerInterface
* @param ServerInterface|Server $tcp
* @param LoopInterface $loop
* @param array $context
* @throws \BadMethodCallException for legacy HHVM < 3.8 due to lack of support
* @see Server
* @link http://php.net/manual/en/context.ssl.php for TLS context options
*/
public function __construct(ServerInterface $tcp, LoopInterface $loop, array $context)
{
if (!function_exists('stream_socket_enable_crypto')) {
throw new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)'); // @codeCoverageIgnore
}

// default to empty passphrase to surpress blocking passphrase prompt
$context += array(
'passphrase' => ''
Expand Down
4 changes: 0 additions & 4 deletions src/StreamEncryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class StreamEncryption

public function __construct(LoopInterface $loop, $server = true)
{
if (!function_exists('stream_socket_enable_crypto')) {
throw new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)');
}

$this->loop = $loop;
$this->server = $server;

Expand Down
2 changes: 1 addition & 1 deletion src/TcpConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function connect($uri)
// HHVM fails to parse URIs with a query but no path, so let's add a dummy path
// See also https://3v4l.org/jEhLF
if (defined('HHVM_VERSION') && isset($parts['query']) && !isset($parts['path'])) {
$uri = str_replace('?', '/?', $uri);
$uri = str_replace('?', '/?', $uri); // @codeCoverageIgnore
}

$socket = @stream_socket_client(
Expand Down

0 comments on commit 1529ce8

Please sign in to comment.