updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -29,9 +29,9 @@ class Connection
* @param string $host The server host
* @param ContextProviderInterface[] $contextProviders Context providers indexed by context name
*/
public function __construct(string $host, array $contextProviders = array())
public function __construct(string $host, array $contextProviders = [])
{
if (false === strpos($host, '://')) {
if (!str_contains($host, '://')) {
$host = 'tcp://'.$host;
}
@@ -51,20 +51,20 @@ class Connection
return false;
}
$context = array('timestamp' => microtime(true));
$context = ['timestamp' => microtime(true)];
foreach ($this->contextProviders as $name => $provider) {
$context[$name] = $provider->getContext();
}
$context = array_filter($context);
$encodedPayload = base64_encode(serialize(array($data, $context)))."\n";
$encodedPayload = base64_encode(serialize([$data, $context]))."\n";
set_error_handler(array(self::class, 'nullErrorHandler'));
set_error_handler([self::class, 'nullErrorHandler']);
try {
if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) {
return true;
}
if (!$socketIsFresh) {
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
stream_socket_shutdown($this->socket, \STREAM_SHUT_RDWR);
fclose($this->socket);
$this->socket = $this->createSocket();
}
@@ -78,20 +78,18 @@ class Connection
return false;
}
private static function nullErrorHandler($t, $m)
private static function nullErrorHandler(int $t, string $m)
{
// no-op
}
private function createSocket()
{
set_error_handler(array(self::class, 'nullErrorHandler'));
set_error_handler([self::class, 'nullErrorHandler']);
try {
return stream_socket_client($this->host, $errno, $errstr, 3, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
return stream_socket_client($this->host, $errno, $errstr, 3, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT);
} finally {
restore_error_handler();
}
return $socket;
}
}

View File

@@ -30,7 +30,7 @@ class DumpServer
public function __construct(string $host, LoggerInterface $logger = null)
{
if (false === strpos($host, '://')) {
if (!str_contains($host, '://')) {
$host = 'tcp://'.$host;
}
@@ -41,7 +41,7 @@ class DumpServer
public function start(): void
{
if (!$this->socket = stream_socket_server($this->host, $errno, $errstr)) {
throw new \RuntimeException(sprintf('Server start failed on "%s": %s %s.', $this->host, $errstr, $errno));
throw new \RuntimeException(sprintf('Server start failed on "%s": ', $this->host).$errstr.' '.$errno);
}
}
@@ -52,12 +52,12 @@ class DumpServer
}
foreach ($this->getMessages() as $clientId => $message) {
$payload = @unserialize(base64_decode($message), array('allowed_classes' => array(Data::class, Stub::class)));
$payload = @unserialize(base64_decode($message), ['allowed_classes' => [Data::class, Stub::class]]);
// Impossible to decode the message, give up.
if (false === $payload) {
if ($this->logger) {
$this->logger->warning('Unable to decode a message from {clientId} client.', array('clientId' => $clientId));
$this->logger->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]);
}
continue;
@@ -65,13 +65,13 @@ class DumpServer
if (!\is_array($payload) || \count($payload) < 2 || !$payload[0] instanceof Data || !\is_array($payload[1])) {
if ($this->logger) {
$this->logger->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', array('clientId' => $clientId));
$this->logger->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]);
}
continue;
}
list($data, $context) = $payload;
[$data, $context] = $payload;
$callback($data, $context, $clientId);
}
@@ -84,8 +84,8 @@ class DumpServer
private function getMessages(): iterable
{
$sockets = array((int) $this->socket => $this->socket);
$write = array();
$sockets = [(int) $this->socket => $this->socket];
$write = [];
while (true) {
$read = $sockets;