Bump dependencies

This commit is contained in:
2022-09-11 22:05:17 +03:00
parent 3bf8444e06
commit c88fdb6354
12 changed files with 41 additions and 26 deletions

View File

@ -17,24 +17,27 @@
"amphp/socket": "^1.1",
"composer/semver": "^3.2",
"phpinnacle/buffer": "^1.2",
"psr/log": "^1.1"
"psr/log": "^3.0"
},
"require-dev": {
"amphp/log": "^1.1",
"dg/bypass-finals": "^1.3",
"ergebnis/composer-normalize": "^2.15",
"friendsofphp/php-cs-fixer": "^3.0",
"infection/infection": "^0.23.0",
"friendsofphp/php-cs-fixer": "^3.4",
"infection/infection": "^0.26.13",
"nyholm/nsa": "^1.2",
"phpstan/phpstan": "^0.12.68",
"phpstan/phpstan-phpunit": "^0.12.17",
"phpstan/phpstan-strict-rules": "^0.12.9",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^9.5",
"symfony/var-dumper": "^5.3",
"symfony/var-dumper": "^6.1",
"vimeo/psalm": "^4.4"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"ergebnis/composer-normalize": true,
"infection/extension-installer": true
}
},
"autoload": {
"psr-4": {

View File

@ -14,6 +14,7 @@ use Nsq\Config\ClientConfig;
use Nsq\Config\LookupConfig;
use Nsq\Lookup;
use Nsq\Producer;
use function Amp\asyncCall;
use function Amp\delay;
@ -55,7 +56,7 @@ Loop::run(static function () {
unset($producers[$address]);
})
->connect()
;
;
});
}

View File

@ -14,6 +14,7 @@ use Monolog\Processor\PsrLogMessageProcessor;
use Nsq\Config\ClientConfig;
use Nsq\Consumer;
use Nsq\Message;
use function Amp\call;
Loop::run(static function () {

View File

@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
allowPhpStormGenerics="true"
ignoreInternalFunctionFalseReturn="false"
ignoreInternalFunctionNullReturn="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

View File

@ -17,6 +17,7 @@ use Nsq\Stream\NullStream;
use Nsq\Stream\SnappyStream;
use Nsq\Stream\SocketStream;
use Psr\Log\LoggerInterface;
use function Amp\asyncCall;
use function Amp\call;

View File

@ -12,9 +12,13 @@ use Nsq\Exception\ConsumerException;
use Nsq\Frame\Response;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use function Amp\asyncCall;
use function Amp\call;
/**
* @internal
*/
final class Consumer extends Connection
{
private int $rdy = 0;

View File

@ -6,10 +6,9 @@ namespace Nsq;
abstract class Frame
{
public const TYPE_RESPONSE = 0,
TYPE_ERROR = 1,
TYPE_MESSAGE = 2
;
public const TYPE_RESPONSE = 0;
public const TYPE_ERROR = 1;
public const TYPE_MESSAGE = 2;
public function __construct(public int $type)
{

View File

@ -17,6 +17,7 @@ use Nsq\Config\LookupConfig;
use Nsq\Exception\LookupException;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use function Amp\asyncCall;
use function Amp\call;
use function Amp\delay;

View File

@ -10,6 +10,7 @@ use Nsq\Config\ClientConfig;
use Nsq\Exception\NsqException;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use function Amp\asyncCall;
use function Amp\call;

View File

@ -8,17 +8,18 @@ use Amp\Promise;
use Nsq\Buffer;
use Nsq\Exception\StreamException;
use Nsq\Stream;
use function Amp\call;
class GzipStream implements Stream
{
/**
* @var resource
* @var null|\InflateContext
*/
private $inflate;
/**
* @var resource
* @var null|\DeflateContext
*/
private $deflate;
@ -26,17 +27,19 @@ class GzipStream implements Stream
public function __construct(private Stream $stream, private int $level, string $bytes = '')
{
$this->inflate = @inflate_init(ZLIB_ENCODING_RAW, ['level' => $this->level]);
$this->deflate = @deflate_init(ZLIB_ENCODING_RAW, ['level' => $this->level]);
$inflate = @inflate_init(ZLIB_ENCODING_RAW, ['level' => $this->level]);
$deflate = @deflate_init(ZLIB_ENCODING_RAW, ['level' => $this->level]);
if (false === $this->inflate) {
if (false === $inflate) {
throw new StreamException('Failed initializing inflate context');
}
if (false === $this->deflate) {
if (false === $deflate) {
throw new StreamException('Failed initializing deflate context');
}
$this->inflate = $inflate;
$this->deflate = $deflate;
$this->buffer = new Buffer($bytes);
}

View File

@ -8,18 +8,19 @@ use Amp\Promise;
use Nsq\Buffer;
use Nsq\Exception\SnappyException;
use Nsq\Stream;
use function Amp\call;
class SnappyStream implements Stream
{
private const IDENTIFIER = [0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59];
private const IDENTIFIER = [0xFF, 0x06, 0x00, 0x00, 0x73, 0x4E, 0x61, 0x50, 0x70, 0x59];
private const SIZE_HEADER = 4;
private const SIZE_CHECKSUM = 4;
private const SIZE_CHUNK = 65536;
private const TYPE_IDENTIFIER = 0xff;
private const TYPE_IDENTIFIER = 0xFF;
private const TYPE_COMPRESSED = 0x00;
private const TYPE_UNCOMPRESSED = 0x01;
private const TYPE_PADDING = 0xfe;
private const TYPE_PADDING = 0xFE;
private Buffer $buffer;
@ -45,7 +46,7 @@ class SnappyStream implements Stream
$type = $this->buffer->readUInt32LE();
$size = $type >> 8;
$type &= 0xff;
$type &= 0xFF;
while ($this->buffer->size() < $size && null !== ($chunk = yield $this->stream->read())) {
$this->buffer->append($chunk);
@ -106,7 +107,7 @@ class SnappyStream implements Stream
/** @phpstan-ignore-next-line */
$checksum = unpack('N', hash('crc32c', $uncompressed, true))[1];
$checksum = (($checksum >> 15) | ($checksum << 17)) + 0xa282ead8 & 0xffffffff;
$checksum = (($checksum >> 15) | ($checksum << 17)) + 0xA282EAD8 & 0xFFFFFFFF;
$size = (\strlen($data) + 4) << 8;

View File

@ -9,6 +9,7 @@ use Amp\Socket\ClientTlsContext;
use Amp\Socket\ConnectContext;
use Amp\Socket\EncryptableSocket;
use Nsq\Stream;
use function Amp\call;
use function Amp\Socket\connect;