Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout signature for fsockopen is float #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Connection/InetSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class InetSocket implements Connection
/**
* Socket timeout
*
* @var int
* @var float
*/
private $timeout;

Expand All @@ -50,14 +50,14 @@ abstract class InetSocket implements Connection
*
* @param string $host Statsd hostname
* @param int $port Statsd port
* @param ?int $timeout Connection timeout
* @param ?float $timeout Connection timeout
* @param bool $persistent (default FALSE) Use persistent connection or not
* @param int $mtu Maximum Transmission Unit (default: 1500)
*/
public function __construct(
string $host = 'localhost',
int $port = 8125,
?int $timeout = null,
?float $timeout = null,
bool $persistent = false,
int $mtu = 1500
) {
Expand All @@ -70,7 +70,7 @@ public function __construct(
strlen(self::LINE_DELIMITER);

if ($timeout === null) {
$this->timeout = (int) ini_get('default_socket_timeout');
$this->timeout = (float) ini_get('default_socket_timeout');
} else {
$this->timeout = $timeout;
}
Expand All @@ -86,7 +86,7 @@ public function getPort(): int
return $this->port;
}

public function getTimeout(): int
public function getTimeout(): float
{
return $this->timeout;
}
Expand Down Expand Up @@ -174,10 +174,10 @@ private function cutIntoMtuSizedPackets(array $messages): array
*
* @param string $host
* @param int $port
* @param int $timeout
* @param float $timeout
* @param bool $persistent
*/
abstract protected function connect(string $host, int $port, int $timeout, bool $persistent): void;
abstract protected function connect(string $host, int $port, float $timeout, bool $persistent): void;

/*
* checks whether the socket connection is alive
Expand Down
4 changes: 2 additions & 2 deletions src/Connection/TcpSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ protected function writeToSocket(string $message): void
/**
* @param string $host
* @param int $port
* @param int $timeout
* @param float $timeout
* @param bool $persistent
*/
protected function connect(string $host, int $port, int $timeout, bool $persistent): void
protected function connect(string $host, int $port, float $timeout, bool $persistent): void
{
$errorNumber = 0;
$errorMessage = '';
Expand Down
4 changes: 2 additions & 2 deletions src/Connection/UdpSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ protected function writeToSocket(string $message): void
/**
* @param string $host
* @param int $port
* @param int $timeout
* @param float $timeout
* @param bool $persistent
*/
protected function connect(string $host, int $port, int $timeout, bool $persistent = false): void
protected function connect(string $host, int $port, float $timeout, bool $persistent = false): void
{
$errorNumber = 0;
$errorMessage = '';
Expand Down