Skip to content

Commit

Permalink
[FIX] Use a instead of A binary decoding in Protocol.php (#45)
Browse files Browse the repository at this point in the history
* Use `a` instead of `A` binary decoding in `Protocol.php`
* Fix `SchemaAttribute` failure for PHPStan
  • Loading branch information
tPl0ch authored Nov 2, 2020
1 parent 4bfeb36 commit cf5b0bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Objects/Schema/Generation/AnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand All @@ -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']);

Expand Down
4 changes: 2 additions & 2 deletions src/Protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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)
// @codeCoverageIgnoreStart
: 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
)
Expand Down

0 comments on commit cf5b0bb

Please sign in to comment.