|
|
@@ -63,7 +63,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
$this->validateTimeout($connectionTimeout);
|
|
|
}
|
|
|
|
|
|
- $this->connectionTimeout = $connectionTimeout ?? (float) ini_get('default_socket_timeout');
|
|
|
+ $this->connectionTimeout = $connectionTimeout ?? (float) \ini_get('default_socket_timeout');
|
|
|
$this->persistent = $persistent;
|
|
|
$this->validateTimeout($timeout);
|
|
|
$this->timeout = $timeout;
|
|
|
@@ -102,7 +102,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
*/
|
|
|
public function closeSocket(): void
|
|
|
{
|
|
|
- if (is_resource($this->resource)) {
|
|
|
+ if (\is_resource($this->resource)) {
|
|
|
fclose($this->resource);
|
|
|
$this->resource = null;
|
|
|
}
|
|
|
@@ -229,7 +229,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
*/
|
|
|
public function isConnected(): bool
|
|
|
{
|
|
|
- return is_resource($this->resource)
|
|
|
+ return \is_resource($this->resource)
|
|
|
&& !feof($this->resource); // on TCP - other party can close connection.
|
|
|
}
|
|
|
|
|
|
@@ -263,7 +263,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
$seconds = floor($this->timeout);
|
|
|
$microseconds = round(($this->timeout - $seconds) * 1e6);
|
|
|
|
|
|
- if (!is_resource($this->resource)) {
|
|
|
+ if (!\is_resource($this->resource)) {
|
|
|
throw new \LogicException('streamSetTimeout called but $this->resource is not a resource');
|
|
|
}
|
|
|
|
|
|
@@ -279,7 +279,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
*/
|
|
|
protected function streamSetChunkSize(): int|bool
|
|
|
{
|
|
|
- if (!is_resource($this->resource)) {
|
|
|
+ if (!\is_resource($this->resource)) {
|
|
|
throw new \LogicException('streamSetChunkSize called but $this->resource is not a resource');
|
|
|
}
|
|
|
|
|
|
@@ -297,7 +297,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
*/
|
|
|
protected function fwrite(string $data): int|bool
|
|
|
{
|
|
|
- if (!is_resource($this->resource)) {
|
|
|
+ if (!\is_resource($this->resource)) {
|
|
|
throw new \LogicException('fwrite called but $this->resource is not a resource');
|
|
|
}
|
|
|
|
|
|
@@ -311,7 +311,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
*/
|
|
|
protected function streamGetMetadata(): array|bool
|
|
|
{
|
|
|
- if (!is_resource($this->resource)) {
|
|
|
+ if (!\is_resource($this->resource)) {
|
|
|
throw new \LogicException('streamGetMetadata called but $this->resource is not a resource');
|
|
|
}
|
|
|
|
|
|
@@ -360,7 +360,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
} else {
|
|
|
$resource = $this->fsockopen();
|
|
|
}
|
|
|
- if (is_bool($resource)) {
|
|
|
+ if (\is_bool($resource)) {
|
|
|
throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)");
|
|
|
}
|
|
|
$this->resource = $resource;
|
|
|
@@ -382,7 +382,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
|
|
|
private function writeToSocket(string $data): void
|
|
|
{
|
|
|
- $length = strlen($data);
|
|
|
+ $length = \strlen($data);
|
|
|
$sent = 0;
|
|
|
$this->lastSentBytes = $sent;
|
|
|
while ($this->isConnected() && $sent < $length) {
|
|
|
@@ -396,7 +396,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|
|
}
|
|
|
$sent += $chunk;
|
|
|
$socketInfo = $this->streamGetMetadata();
|
|
|
- if (is_array($socketInfo) && (bool) $socketInfo['timed_out']) {
|
|
|
+ if (\is_array($socketInfo) && (bool) $socketInfo['timed_out']) {
|
|
|
throw new \RuntimeException("Write timed-out");
|
|
|
}
|
|
|
|