Skip to content

Commit

Permalink
chore: implemented some hints from CI
Browse files Browse the repository at this point in the history
  • Loading branch information
petrknap committed Oct 27, 2024
1 parent e9423d6 commit 3627d27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/BinariableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

namespace PetrKnap\Binary;

/**
* @psalm-require-implements BinariableInterface
*/
trait BinariableTrait
{
/**
* Unfortunately PHP uses string for binary data, so the magic clashes.
*/
public function __toString(): string
{
/** @var BinariableInterface $this */
$binary = $this->toBinary();
trigger_error(
'Returned binary string',
Expand Down
8 changes: 4 additions & 4 deletions src/Coder/Zlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ final class Zlib extends Coder
public const LEVEL = -1;
public const MAX_LENGTH = 0;

private int $encoding;
private int $level;
private int $maxLength;

public function __construct()
{
self::checkRequirements(
Expand All @@ -31,10 +35,6 @@ functions: [
);
}

private int $encoding;
private int $level;
private int $maxLength;

public function encode(string $decoded, ?int $encoding = null, ?int $level = null): string
{
$this->encoding = $encoding ?? self::ENCODING;
Expand Down
2 changes: 2 additions & 0 deletions src/Serializer/SelfSerializerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/**
* If your {@see self::__construct()} argument is an instance of {@see SelfSerializerInterface} then
* accept it as a union type `YourClass|string` and call {@see SelfSerializerInterface::fromBinary()} if it is a string.
*
* @psalm-require-implements SelfSerializerInterface
*/
trait SelfSerializerTrait
{
Expand Down

0 comments on commit 3627d27

Please sign in to comment.