From cf5b0bb93194012a436bb24702c786cf3bf153df Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Mon, 2 Nov 2020 09:12:56 +0100 Subject: [PATCH] [FIX] Use `a` instead of `A` binary decoding in `Protocol.php` (#45) * Use `a` instead of `A` binary decoding in `Protocol.php` * Fix `SchemaAttribute` failure for PHPStan --- src/Objects/Schema/Generation/AnnotationReader.php | 2 ++ src/Protocol.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Objects/Schema/Generation/AnnotationReader.php b/src/Objects/Schema/Generation/AnnotationReader.php index 17bbdf3..dbdbc46 100644 --- a/src/Objects/Schema/Generation/AnnotationReader.php +++ b/src/Objects/Schema/Generation/AnnotationReader.php @@ -25,6 +25,7 @@ public function __construct(DoctrineAnnotationReader $reader) */ public function readClassAttributes(ReflectionClass $class): SchemaAttributes { + /** @var SchemaAttribute[] $annotations */ $annotations = $this->reader->getClassAnnotations($class); $attributes = \array_filter($annotations, [$this, 'onlySchemaAttributes']); @@ -33,6 +34,7 @@ public function readClassAttributes(ReflectionClass $class): SchemaAttributes public function readPropertyAttributes(ReflectionProperty $property): SchemaAttributes { + /** @var SchemaAttribute[] $annotations */ $annotations = $this->reader->getPropertyAnnotations($property); $attributes = \array_filter($annotations, [$this, 'onlySchemaAttributes']); diff --git a/src/Protocol.php b/src/Protocol.php index 17ce63e..0ceb18a 100644 --- a/src/Protocol.php +++ b/src/Protocol.php @@ -30,7 +30,7 @@ function version(): int function encode(int $protocolVersion, int $schemaId, string $avroEncodedBinaryString): Either { /** @var bool|string $packed */ - $packed = @\pack('CNA*', $protocolVersion, $schemaId, $avroEncodedBinaryString); + $packed = @\pack('CNa*', $protocolVersion, $schemaId, $avroEncodedBinaryString); return false !== $packed ? Right::of($packed) @@ -38,7 +38,7 @@ function encode(int $protocolVersion, int $schemaId, string $avroEncodedBinarySt : Left::of( new AvroEncodingException( \sprintf( - 'Could not pack message with format "CNA*", protocol version "%d" and schema id "%d"', + 'Could not pack message with format "CNa*", protocol version "%d" and schema id "%d"', $protocolVersion, $schemaId )