Skip to content

Commit

Permalink
Silence warnings to make our exceptions takeover
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Mar 3, 2020
1 parent 8abb4eb commit 24d969b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/SocketClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public function __construct(string $socketUri, int $timeout = 30)

public function connect(): self
{
$fp = stream_socket_client($this->socketUri, $errno, $errstr, $this->timeout);
$fp = @stream_socket_client($this->socketUri, $errno, $errstr, $this->timeout);
if (!is_resource($fp) && false === $fp) {
$message = sprintf("Stream Connection Failed: %s", $errstr);
$message = sprintf("Stream Connection Failed: %s unable to connect to %s", $errstr, $this->socketUri);
throw new SocketClientException($message, $errno);
}

$this->socket = $fp;
$this->connected = true;
return $this;
Expand Down
12 changes: 12 additions & 0 deletions tests/WhoisSocketClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public function testIsThereAnySyntaxError()
unset($var);
}

/**
* Basic test to check client syntax.
*/
public function testIntentionalSyntaxError()
{
$var = new SocketClient("ztcpz://127.0.0.1:43", 10);
$this->assertIsObject($var);
$this->expectException(SocketClientException::class);
$var->connect();
unset($var);
}

/**
* Basic test to check client syntax.
*/
Expand Down

0 comments on commit 24d969b

Please sign in to comment.