Skip to content

Commit

Permalink
Fix VarIntCompactArray and consumer not found headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Sep 9, 2021
1 parent 018ed24 commit 2d497bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Protocol/Type/VarIntCompactArray.php
Expand Up @@ -18,7 +18,7 @@ public static function pack(?array $array, ?string $elementType = null, int $api
if (null === $array) {
$result = VarInt::pack(0);
} else {
$length = \count($array) + 1;
$length = \count($array);
$result = VarInt::pack($length);
foreach ($array as $item) {
if (null === $elementType) {
Expand Down Expand Up @@ -46,7 +46,7 @@ public static function pack(?array $array, ?string $elementType = null, int $api

public static function unpack(string $value, ?int &$size, string $elementType, int $apiVersion = 0): ?array
{
$length = VarInt::unpack($value, $tmpSize) - 1;
$length = VarInt::unpack($value, $tmpSize);
if ($length > 0) {
$array = [];
$size = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/TypeTest.php
Expand Up @@ -240,7 +240,7 @@ public function testVarIntCompactArray(): void
{
$exceptedArray = [1, 2, 3];
$encodeResult = VarIntCompactArray::pack($exceptedArray, Int32::class);
$this->assertEquals('08000000010000000200000003', bin2hex($encodeResult));
$this->assertEquals('06000000010000000200000003', bin2hex($encodeResult));
$this->assertEquals($exceptedArray, VarIntCompactArray::unpack($encodeResult, $size, Int32::class));
$this->assertEquals(13, $size);
}
Expand Down

0 comments on commit 2d497bf

Please sign in to comment.