diff --git a/src/Client.php b/src/Client.php index 095aff0..8266a89 100644 --- a/src/Client.php +++ b/src/Client.php @@ -22,29 +22,17 @@ final class Client { - /** @var Maybe */ - private Maybe $command; - /** @var callable(): Attempt */ - private $load; - private Filesystem $filesystem; - /** @var Maybe */ - private Maybe $signals; - /** * @param Maybe $command - * @param callable(): Attempt $load + * @param \Closure(): Attempt $load * @param Maybe $signals */ private function __construct( - Maybe $command, - callable $load, - Filesystem $filesystem, - Maybe $signals, + private Maybe $command, + private \Closure $load, + private Filesystem $filesystem, + private Maybe $signals, ) { - $this->command = $command; - $this->load = $load; - $this->filesystem = $filesystem; - $this->signals = $signals; } /** @@ -60,7 +48,7 @@ public static function of(callable $load, Filesystem $filesystem): self return new self( $command, - $load, + \Closure::fromCallable($load), $filesystem, $signals, ); diff --git a/src/Client/State.php b/src/Client/State.php index c73ec6a..5a27655 100644 --- a/src/Client/State.php +++ b/src/Client/State.php @@ -5,11 +5,8 @@ final class State { - private mixed $value; - - private function __construct(mixed $value) + private function __construct(private mixed $value) { - $this->value = $value; } public static function of(mixed $value): self diff --git a/src/Command/Bind.php b/src/Command/Bind.php index 8a94029..d3bd8db 100644 --- a/src/Command/Bind.php +++ b/src/Command/Bind.php @@ -21,11 +21,8 @@ final class Bind implements Command { - private Binding $command; - - private function __construct(Binding $command) + private function __construct(private Binding $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/Consume.php b/src/Command/Consume.php index 66b4e5d..7c06cba 100644 --- a/src/Command/Consume.php +++ b/src/Command/Consume.php @@ -29,17 +29,13 @@ final class Consume implements Command { - private Model $command; - /** @var callable(mixed, Message, Continuation, Details): Continuation */ - private $consume; - /** - * @param callable(mixed, Message, Continuation, Details): Continuation $consume + * @param \Closure(mixed, Message, Continuation, Details): Continuation $consume */ - private function __construct(Model $command, callable $consume) - { - $this->command = $command; - $this->consume = $consume; + private function __construct( + private Model $command, + private \Closure $consume, + ) { } #[\Override] @@ -89,7 +85,7 @@ public static function of(string $queue): self #[\NoDiscard] public function handle(callable $consume): self { - return new self($this->command, $consume); + return new self($this->command, \Closure::fromCallable($consume)); } /** diff --git a/src/Command/DeclareExchange.php b/src/Command/DeclareExchange.php index 0606be9..2cc6610 100644 --- a/src/Command/DeclareExchange.php +++ b/src/Command/DeclareExchange.php @@ -22,11 +22,8 @@ final class DeclareExchange implements Command { - private Declaration $command; - - private function __construct(Declaration $command) + private function __construct(private Declaration $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/DeclareQueue.php b/src/Command/DeclareQueue.php index 4f922f6..f2ed83b 100644 --- a/src/Command/DeclareQueue.php +++ b/src/Command/DeclareQueue.php @@ -26,11 +26,8 @@ final class DeclareQueue implements Command { - private Declaration $command; - - private function __construct(Declaration $command) + private function __construct(private Declaration $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/DeleteExchange.php b/src/Command/DeleteExchange.php index 41d0559..73ff965 100644 --- a/src/Command/DeleteExchange.php +++ b/src/Command/DeleteExchange.php @@ -21,11 +21,8 @@ final class DeleteExchange implements Command { - private Deletion $command; - - private function __construct(Deletion $command) + private function __construct(private Deletion $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/DeleteQueue.php b/src/Command/DeleteQueue.php index 12c989f..9bc0c79 100644 --- a/src/Command/DeleteQueue.php +++ b/src/Command/DeleteQueue.php @@ -25,11 +25,8 @@ final class DeleteQueue implements Command { - private Deletion $command; - - private function __construct(Deletion $command) + private function __construct(private Deletion $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/Get.php b/src/Command/Get.php index 810da1b..43e46fd 100644 --- a/src/Command/Get.php +++ b/src/Command/Get.php @@ -29,21 +29,15 @@ final class Get implements Command { - private Model $command; - /** @var callable(mixed, Message, Continuation, Details): Continuation */ - private $consume; - /** @var positive-int */ - private int $take; - /** - * @param callable(mixed, Message, Continuation, Details): Continuation $consume - * @param positive-int $take + * @param \Closure(mixed, Message, Continuation, Details): Continuation $consume + * @param int<1, max> $take */ - private function __construct(Model $command, callable $consume, int $take) - { - $this->command = $command; - $this->consume = $consume; - $this->take = $take; + private function __construct( + private Model $command, + private \Closure $consume, + private int $take, + ) { } #[\Override] @@ -79,11 +73,11 @@ public static function of(string $queue): self #[\NoDiscard] public function handle(callable $consume): self { - return new self($this->command, $consume, $this->take); + return new self($this->command, \Closure::fromCallable($consume), $this->take); } /** - * @param positive-int $take + * @param int<1, max> $take */ #[\NoDiscard] public function take(int $take): self diff --git a/src/Command/Pipe.php b/src/Command/Pipe.php index a13b272..628a4ce 100644 --- a/src/Command/Pipe.php +++ b/src/Command/Pipe.php @@ -17,13 +17,10 @@ */ final class Pipe implements Command { - private Command $first; - private Command $second; - - public function __construct(Command $first, Command $second) - { - $this->first = $first; - $this->second = $second; + public function __construct( + private Command $first, + private Command $second, + ) { } #[\Override] diff --git a/src/Command/Publish.php b/src/Command/Publish.php index 83e330b..197914c 100644 --- a/src/Command/Publish.php +++ b/src/Command/Publish.php @@ -21,15 +21,11 @@ final class Publish implements Command { - /** @var Sequence */ - private Sequence $commands; - /** * @param Sequence $commands */ - private function __construct(Sequence $commands) + private function __construct(private Sequence $commands) { - $this->commands = $commands; } #[\Override] diff --git a/src/Command/Purge.php b/src/Command/Purge.php index 7694181..e9ac028 100644 --- a/src/Command/Purge.php +++ b/src/Command/Purge.php @@ -25,11 +25,8 @@ final class Purge implements Command { - private Model $command; - - private function __construct(Model $command) + private function __construct(private Model $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/Qos.php b/src/Command/Qos.php index 1dbc95a..1db34e8 100644 --- a/src/Command/Qos.php +++ b/src/Command/Qos.php @@ -17,11 +17,8 @@ final class Qos implements Command { - private Model $command; - - private function __construct(Model $command) + private function __construct(private Model $command) { - $this->command = $command; } #[\Override] diff --git a/src/Command/Transaction.php b/src/Command/Transaction.php index b5c78f4..6f2cb6f 100644 --- a/src/Command/Transaction.php +++ b/src/Command/Transaction.php @@ -16,17 +16,13 @@ final class Transaction implements Command { - private Command $command; - /** @var callable(mixed): bool */ - private $predicate; - /** - * @param callable(mixed): bool $predicate + * @param \Closure(mixed): bool $predicate */ - private function __construct(Command $command, callable $predicate) - { - $this->command = $command; - $this->predicate = $predicate; + private function __construct( + private Command $command, + private \Closure $predicate, + ) { } #[\Override] @@ -59,7 +55,7 @@ public static function of( callable $predicate, Command $command, ): self { - return new self($command, $predicate); + return new self($command, \Closure::fromCallable($predicate)); } #[\NoDiscard] diff --git a/src/Command/Unbind.php b/src/Command/Unbind.php index 64ec6b6..23efa80 100644 --- a/src/Command/Unbind.php +++ b/src/Command/Unbind.php @@ -17,11 +17,8 @@ final class Unbind implements Command { - private Unbinding $command; - - private function __construct(Unbinding $command) + private function __construct(private Unbinding $command) { - $this->command = $command; } #[\Override] diff --git a/src/Consumer/Canceled.php b/src/Consumer/Canceled.php index b186a0e..358f4da 100644 --- a/src/Consumer/Canceled.php +++ b/src/Consumer/Canceled.php @@ -10,11 +10,8 @@ */ final class Canceled { - private State $state; - - private function __construct(State $state) + private function __construct(private State $state) { - $this->state = $state; } public static function of(State $state): self diff --git a/src/Consumer/Continuation.php b/src/Consumer/Continuation.php index ed7ddee..ee5d981 100644 --- a/src/Consumer/Continuation.php +++ b/src/Consumer/Continuation.php @@ -23,13 +23,10 @@ final class Continuation { - private Client\State $state; - private State $response; - - private function __construct(Client\State $state, State $response) - { - $this->state = $state; - $this->response = $response; + private function __construct( + private Client\State $state, + private State $response, + ) { } #[\NoDiscard] diff --git a/src/Consumer/Details.php b/src/Consumer/Details.php index 8c32623..8a924c4 100644 --- a/src/Consumer/Details.php +++ b/src/Consumer/Details.php @@ -11,30 +11,17 @@ */ final class Details { - /** @var int<0, max> */ - private int $deliveryTag; - private bool $redelivered; - private string $exchange; - private string $routingKey; - /** @var Maybe */ - private Maybe $messages; - /** * @param int<0, max> $deliveryTag * @param Maybe $messages */ private function __construct( - int $deliveryTag, - bool $redelivered, - string $exchange, - string $routingKey, - Maybe $messages, + private int $deliveryTag, + private bool $redelivered, + private string $exchange, + private string $routingKey, + private Maybe $messages, ) { - $this->deliveryTag = $deliveryTag; - $this->redelivered = $redelivered; - $this->exchange = $exchange; - $this->routingKey = $routingKey; - $this->messages = $messages; } /** diff --git a/src/Factory.php b/src/Factory.php index 6c99f6c..25d7598 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -10,11 +10,8 @@ final class Factory { - private OperatingSystem $os; - - private function __construct(OperatingSystem $os) + private function __construct(private OperatingSystem $os) { - $this->os = $os; } #[\NoDiscard] diff --git a/src/Failure/ClosedByServer.php b/src/Failure/ClosedByServer.php index 7fa8c03..90d5659 100644 --- a/src/Failure/ClosedByServer.php +++ b/src/Failure/ClosedByServer.php @@ -11,23 +11,17 @@ */ final class ClosedByServer { - private string $message; - /** @var int<0, 65535> */ - private int $code; - /** @var Maybe */ - private Maybe $method; - /** * @internal * * @param int<0, 65535> $code * @param Maybe $method */ - public function __construct(string $message, int $code, Maybe $method) - { - $this->message = $message; - $this->code = $code; - $this->method = $method; + public function __construct( + private string $message, + private int $code, + private Maybe $method, + ) { } #[\NoDiscard] diff --git a/src/Failure/ClosedBySignal.php b/src/Failure/ClosedBySignal.php index 0bf97e2..314431a 100644 --- a/src/Failure/ClosedBySignal.php +++ b/src/Failure/ClosedBySignal.php @@ -10,14 +10,11 @@ */ final class ClosedBySignal { - private Signal $signal; - /** * @internal */ - public function __construct(Signal $signal) + public function __construct(private Signal $signal) { - $this->signal = $signal; } #[\NoDiscard] diff --git a/src/Failure/ToAck.php b/src/Failure/ToAck.php index ec61c19..45d60dc 100644 --- a/src/Failure/ToAck.php +++ b/src/Failure/ToAck.php @@ -8,14 +8,11 @@ */ final class ToAck { - private string $queue; - /** * @internal */ - public function __construct(string $queue) + public function __construct(private string $queue) { - $this->queue = $queue; } #[\NoDiscard] diff --git a/src/Failure/ToBind.php b/src/Failure/ToBind.php index 334f9cf..8a824ac 100644 --- a/src/Failure/ToBind.php +++ b/src/Failure/ToBind.php @@ -10,14 +10,11 @@ */ final class ToBind { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToCancel.php b/src/Failure/ToCancel.php index a6230a1..3543177 100644 --- a/src/Failure/ToCancel.php +++ b/src/Failure/ToCancel.php @@ -8,14 +8,11 @@ */ final class ToCancel { - private string $queue; - /** * @internal */ - public function __construct(string $queue) + public function __construct(private string $queue) { - $this->queue = $queue; } #[\NoDiscard] diff --git a/src/Failure/ToConsume.php b/src/Failure/ToConsume.php index a4a5a3e..4c7a44c 100644 --- a/src/Failure/ToConsume.php +++ b/src/Failure/ToConsume.php @@ -10,14 +10,11 @@ */ final class ToConsume { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToDeclareExchange.php b/src/Failure/ToDeclareExchange.php index 624b2c1..071f7be 100644 --- a/src/Failure/ToDeclareExchange.php +++ b/src/Failure/ToDeclareExchange.php @@ -10,14 +10,11 @@ */ final class ToDeclareExchange { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToDeclareQueue.php b/src/Failure/ToDeclareQueue.php index 7343f3c..e45476a 100644 --- a/src/Failure/ToDeclareQueue.php +++ b/src/Failure/ToDeclareQueue.php @@ -10,14 +10,11 @@ */ final class ToDeclareQueue { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToDeleteExchange.php b/src/Failure/ToDeleteExchange.php index 2bd5e17..3fa0fff 100644 --- a/src/Failure/ToDeleteExchange.php +++ b/src/Failure/ToDeleteExchange.php @@ -10,14 +10,11 @@ */ final class ToDeleteExchange { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToDeleteQueue.php b/src/Failure/ToDeleteQueue.php index 0699eea..5c7ac0d 100644 --- a/src/Failure/ToDeleteQueue.php +++ b/src/Failure/ToDeleteQueue.php @@ -10,14 +10,11 @@ */ final class ToDeleteQueue { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToGet.php b/src/Failure/ToGet.php index 0042109..b84b2db 100644 --- a/src/Failure/ToGet.php +++ b/src/Failure/ToGet.php @@ -10,14 +10,11 @@ */ final class ToGet { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToPublish.php b/src/Failure/ToPublish.php index de2e15b..b4f4ca5 100644 --- a/src/Failure/ToPublish.php +++ b/src/Failure/ToPublish.php @@ -10,14 +10,11 @@ */ final class ToPublish { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToPurge.php b/src/Failure/ToPurge.php index df062b7..8c4c787 100644 --- a/src/Failure/ToPurge.php +++ b/src/Failure/ToPurge.php @@ -10,14 +10,11 @@ */ final class ToPurge { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Failure/ToRecover.php b/src/Failure/ToRecover.php index 5b989b1..d2e4aa4 100644 --- a/src/Failure/ToRecover.php +++ b/src/Failure/ToRecover.php @@ -8,14 +8,11 @@ */ final class ToRecover { - private string $queue; - /** * @internal */ - public function __construct(string $queue) + public function __construct(private string $queue) { - $this->queue = $queue; } #[\NoDiscard] diff --git a/src/Failure/ToReject.php b/src/Failure/ToReject.php index fe445a5..030df1a 100644 --- a/src/Failure/ToReject.php +++ b/src/Failure/ToReject.php @@ -8,14 +8,11 @@ */ final class ToReject { - private string $queue; - /** * @internal */ - public function __construct(string $queue) + public function __construct(private string $queue) { - $this->queue = $queue; } #[\NoDiscard] diff --git a/src/Failure/ToUnbind.php b/src/Failure/ToUnbind.php index c05aee9..55b1fc2 100644 --- a/src/Failure/ToUnbind.php +++ b/src/Failure/ToUnbind.php @@ -10,14 +10,11 @@ */ final class ToUnbind { - private Command $command; - /** * @internal */ - public function __construct(Command $command) + public function __construct(private Command $command) { - $this->command = $command; } #[\NoDiscard] diff --git a/src/Model/Basic/Message/AppId.php b/src/Model/Basic/Message/AppId.php index e02b556..e920813 100644 --- a/src/Model/Basic/Message/AppId.php +++ b/src/Model/Basic/Message/AppId.php @@ -12,11 +12,8 @@ */ final class AppId { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Message/ContentEncoding.php b/src/Model/Basic/Message/ContentEncoding.php index fede9e2..1118ca2 100644 --- a/src/Model/Basic/Message/ContentEncoding.php +++ b/src/Model/Basic/Message/ContentEncoding.php @@ -16,11 +16,8 @@ */ final class ContentEncoding { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Message/CorrelationId.php b/src/Model/Basic/Message/CorrelationId.php index 299b2f4..552575e 100644 --- a/src/Model/Basic/Message/CorrelationId.php +++ b/src/Model/Basic/Message/CorrelationId.php @@ -10,11 +10,8 @@ */ final class CorrelationId { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Message/Id.php b/src/Model/Basic/Message/Id.php index f65732f..9f413cf 100644 --- a/src/Model/Basic/Message/Id.php +++ b/src/Model/Basic/Message/Id.php @@ -10,11 +10,8 @@ */ final class Id { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Message/ReplyTo.php b/src/Model/Basic/Message/ReplyTo.php index fa152a3..d7b034f 100644 --- a/src/Model/Basic/Message/ReplyTo.php +++ b/src/Model/Basic/Message/ReplyTo.php @@ -11,11 +11,8 @@ */ final class ReplyTo { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Message/Type.php b/src/Model/Basic/Message/Type.php index 59192be..9645423 100644 --- a/src/Model/Basic/Message/Type.php +++ b/src/Model/Basic/Message/Type.php @@ -8,11 +8,8 @@ */ final class Type { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Message/UserId.php b/src/Model/Basic/Message/UserId.php index 2bf3a5e..e7acd2a 100644 --- a/src/Model/Basic/Message/UserId.php +++ b/src/Model/Basic/Message/UserId.php @@ -10,11 +10,8 @@ */ final class UserId { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Model/Basic/Recover.php b/src/Model/Basic/Recover.php index 8d443b8..2e0aeb6 100644 --- a/src/Model/Basic/Recover.php +++ b/src/Model/Basic/Recover.php @@ -8,11 +8,8 @@ */ final class Recover { - private bool $requeue = false; - - private function __construct(bool $requeue) + private function __construct(private bool $requeue) { - $this->requeue = $requeue; } /** diff --git a/src/Model/Channel/FlowOk.php b/src/Model/Channel/FlowOk.php index e15c555..32ff55d 100644 --- a/src/Model/Channel/FlowOk.php +++ b/src/Model/Channel/FlowOk.php @@ -8,11 +8,8 @@ */ final class FlowOk { - private bool $active; - - private function __construct(bool $active) + private function __construct(private bool $active) { - $this->active = $active; } /** diff --git a/src/Model/Connection/MaxChannels.php b/src/Model/Connection/MaxChannels.php index 0d41b4f..d1f2ed4 100644 --- a/src/Model/Connection/MaxChannels.php +++ b/src/Model/Connection/MaxChannels.php @@ -14,15 +14,11 @@ */ final class MaxChannels { - /** @var int<0, 65535> */ - private int $value; - /** * @param int<0, 65535> $value */ - private function __construct(int $value) + private function __construct(private int $value) { - $this->value = $value; } /** diff --git a/src/Model/Connection/MaxFrameSize.php b/src/Model/Connection/MaxFrameSize.php index 970f293..426cdea 100644 --- a/src/Model/Connection/MaxFrameSize.php +++ b/src/Model/Connection/MaxFrameSize.php @@ -19,15 +19,11 @@ */ final class MaxFrameSize { - /** @var int<0, 4294967295> */ - private int $value; - /** * @param int<0, 4294967295> $value */ - private function __construct(int $value) + private function __construct(private int $value) { - $this->value = $value; } /** @@ -51,8 +47,8 @@ public static function unlimited(): self } /** - * @psalm-assert-if-true positive-int $this->value - * @psalm-assert-if-true positive-int $this->toInt() + * @psalm-assert-if-true int<1, max> $this->value + * @psalm-assert-if-true int<1, max> $this->toInt() */ #[\NoDiscard] public function isLimited(): bool diff --git a/src/Model/Connection/Open.php b/src/Model/Connection/Open.php index 588b85a..db7b166 100644 --- a/src/Model/Connection/Open.php +++ b/src/Model/Connection/Open.php @@ -10,11 +10,8 @@ */ final class Open { - private Path $virtualHost; - - private function __construct(Path $virtualHost) + private function __construct(private Path $virtualHost) { - $this->virtualHost = $virtualHost; } /** diff --git a/src/Model/Connection/SecureOk.php b/src/Model/Connection/SecureOk.php index 161d74f..8572b6c 100644 --- a/src/Model/Connection/SecureOk.php +++ b/src/Model/Connection/SecureOk.php @@ -13,13 +13,10 @@ */ final class SecureOk { - private User $user; - private Password $password; - - private function __construct(User $user, Password $password) - { - $this->user = $user; - $this->password = $password; + private function __construct( + private User $user, + private Password $password, + ) { } /** diff --git a/src/Model/Connection/StartOk.php b/src/Model/Connection/StartOk.php index 5a4f1f5..25db7e0 100644 --- a/src/Model/Connection/StartOk.php +++ b/src/Model/Connection/StartOk.php @@ -13,13 +13,10 @@ */ final class StartOk { - private User $user; - private Password $password; - - private function __construct(User $user, Password $password) - { - $this->user = $user; - $this->password = $password; + private function __construct( + private User $user, + private Password $password, + ) { } /** diff --git a/src/Model/Connection/TuneOk.php b/src/Model/Connection/TuneOk.php index 4a8494a..20c428e 100644 --- a/src/Model/Connection/TuneOk.php +++ b/src/Model/Connection/TuneOk.php @@ -10,18 +10,11 @@ */ final class TuneOk { - private MaxChannels $maxChannels; - private MaxFrameSize $maxFrameSize; - private Period $heartbeat; - private function __construct( - MaxChannels $maxChannels, - MaxFrameSize $maxFrameSize, - Period $heartbeat, + private MaxChannels $maxChannels, + private MaxFrameSize $maxFrameSize, + private Period $heartbeat, ) { - $this->maxChannels = $maxChannels; - $this->maxFrameSize = $maxFrameSize; - $this->heartbeat = $heartbeat; } /** diff --git a/src/Model/Count.php b/src/Model/Count.php index 3ad9506..f0f88b2 100644 --- a/src/Model/Count.php +++ b/src/Model/Count.php @@ -8,15 +8,11 @@ */ final class Count { - /** @var int<0, max> */ - private int $value; - /** * @param int<0, max> $value */ - private function __construct(int $value) + private function __construct(private int $value) { - $this->value = $value; } /** diff --git a/src/Model/Queue/DeclareOk.php b/src/Model/Queue/DeclareOk.php index ca47686..089ad60 100644 --- a/src/Model/Queue/DeclareOk.php +++ b/src/Model/Queue/DeclareOk.php @@ -10,15 +10,11 @@ */ final class DeclareOk { - private string $name; - private Count $message; - private Count $consumer; - - private function __construct(string $name, Count $message, Count $consumer) - { - $this->name = $name; - $this->message = $message; - $this->consumer = $consumer; + private function __construct( + private string $name, + private Count $message, + private Count $consumer, + ) { } /** diff --git a/src/Model/Queue/DeleteOk.php b/src/Model/Queue/DeleteOk.php index eb789d8..45ed939 100644 --- a/src/Model/Queue/DeleteOk.php +++ b/src/Model/Queue/DeleteOk.php @@ -10,11 +10,8 @@ */ final class DeleteOk { - private Count $message; - - private function __construct(Count $message) + private function __construct(private Count $message) { - $this->message = $message; } /** diff --git a/src/Model/Queue/PurgeOk.php b/src/Model/Queue/PurgeOk.php index 3e5925f..18ed6ce 100644 --- a/src/Model/Queue/PurgeOk.php +++ b/src/Model/Queue/PurgeOk.php @@ -10,11 +10,8 @@ */ final class PurgeOk { - private Count $message; - - private function __construct(Count $message) + private function __construct(private Count $message) { - $this->message = $message; } /** diff --git a/src/Transport/Connection.php b/src/Transport/Connection.php index 8d868f4..a27b110 100644 --- a/src/Transport/Connection.php +++ b/src/Transport/Connection.php @@ -46,35 +46,19 @@ */ final class Connection { - private Protocol $protocol; - private Client $socket; - /** @var IOFrame */ - private IOFrame $frame; - private MaxChannels $maxChannels; - private MaxFrameSize $maxFrameSize; - private Heartbeat $heartbeat; - private SignalListener $signals; - private bool $closed = false; - /** * @param IOFrame $frame */ private function __construct( - Protocol $protocol, - Heartbeat $heartbeat, - Client $socket, - MaxChannels $maxChannels, - MaxFrameSize $maxFrameSize, - IOFrame $frame, - SignalListener $signals, + private Protocol $protocol, + private Heartbeat $heartbeat, + private Client $socket, + private MaxChannels $maxChannels, + private MaxFrameSize $maxFrameSize, + private IOFrame $frame, + private SignalListener $signals, + private bool $closed = false, ) { - $this->protocol = $protocol; - $this->socket = $socket; - $this->frame = $frame; - $this->maxChannels = $maxChannels; - $this->maxFrameSize = $maxFrameSize; - $this->heartbeat = $heartbeat; - $this->signals = $signals; } /** @@ -197,7 +181,7 @@ public function close(): Attempt Method::connectionCloseOk, ) ->flatMap(fn() => $this->socket->close()) - ->map(static fn() => new SideEffect); + ->map(SideEffect::identity(...)); } /** @@ -270,7 +254,7 @@ private function sendFrames(callable $frames): Attempt ->abortWhen($this->signals->notified(...)) ->sinkAttempts($data) ->eitherWay( - static fn() => Attempt::result(new SideEffect), + static fn() => Attempt::result(SideEffect::identity()), fn() => $this->signals->close( $this, static fn() => Attempt::error(Failure::toSendFrame()), diff --git a/src/Transport/Connection/Handshake.php b/src/Transport/Connection/Handshake.php index d2b1d99..c975852 100644 --- a/src/Transport/Connection/Handshake.php +++ b/src/Transport/Connection/Handshake.php @@ -26,11 +26,8 @@ */ final class Handshake { - private Authority $authority; - - public function __construct(Authority $authority) + public function __construct(private Authority $authority) { - $this->authority = $authority; } /** diff --git a/src/Transport/Connection/Heartbeat.php b/src/Transport/Connection/Heartbeat.php index 8892885..732ac79 100644 --- a/src/Transport/Connection/Heartbeat.php +++ b/src/Transport/Connection/Heartbeat.php @@ -18,18 +18,11 @@ */ final class Heartbeat { - private Clock $clock; - private Period $threshold; - private PointInTime $lastReceivedData; - private function __construct( - Clock $clock, - Period $threshold, - PointInTime $lastReceivedData, + private Clock $clock, + private Period $threshold, + private PointInTime $lastReceivedData, ) { - $this->clock = $clock; - $this->threshold = $threshold; - $this->lastReceivedData = $lastReceivedData; } public static function start(Clock $clock, Period $threshold): self diff --git a/src/Transport/Connection/MessageReader.php b/src/Transport/Connection/MessageReader.php index a18d3c5..e2e6888 100644 --- a/src/Transport/Connection/MessageReader.php +++ b/src/Transport/Connection/MessageReader.php @@ -38,11 +38,8 @@ */ final class MessageReader { - private Filesystem $filesystem; - - private function __construct(Filesystem $filesystem) + private function __construct(private Filesystem $filesystem) { - $this->filesystem = $filesystem; } /** diff --git a/src/Transport/Connection/OpenVHost.php b/src/Transport/Connection/OpenVHost.php index b6285fa..7fdb167 100644 --- a/src/Transport/Connection/OpenVHost.php +++ b/src/Transport/Connection/OpenVHost.php @@ -16,11 +16,8 @@ */ final class OpenVHost { - private Path $vhost; - - public function __construct(Path $vhost) + public function __construct(private Path $vhost) { - $this->vhost = $vhost; } /** diff --git a/src/Transport/Connection/Start.php b/src/Transport/Connection/Start.php index 7625c4e..a32a0e7 100644 --- a/src/Transport/Connection/Start.php +++ b/src/Transport/Connection/Start.php @@ -16,11 +16,8 @@ */ final class Start { - private Authority $authority; - - public function __construct(Authority $authority) + public function __construct(private Authority $authority) { - $this->authority = $authority; } /** diff --git a/src/Transport/Frame/Channel.php b/src/Transport/Frame/Channel.php index 0fecaae..602b657 100644 --- a/src/Transport/Frame/Channel.php +++ b/src/Transport/Frame/Channel.php @@ -9,15 +9,11 @@ */ final class Channel { - /** @var int<0, 65535> */ - private int $value; - /** * @param int<0, 65535> $value */ - public function __construct(int $value) + public function __construct(private int $value) { - $this->value = $value; } /** diff --git a/src/Transport/Frame/Value/Bits.php b/src/Transport/Frame/Value/Bits.php index 2ab2473..7479f15 100644 --- a/src/Transport/Frame/Value/Bits.php +++ b/src/Transport/Frame/Value/Bits.php @@ -17,15 +17,11 @@ */ final class Bits implements Value { - /** @var Sequence */ - private Sequence $original; - /** * @param Sequence $original */ - private function __construct(Sequence $original) + private function __construct(private Sequence $original) { - $this->original = $original; } /** diff --git a/src/Transport/Frame/Value/Decimal.php b/src/Transport/Frame/Value/Decimal.php index bf8ad27..d3f3436 100644 --- a/src/Transport/Frame/Value/Decimal.php +++ b/src/Transport/Frame/Value/Decimal.php @@ -13,13 +13,10 @@ */ final class Decimal implements Value { - private SignedLongInteger $value; - private UnsignedOctet $scale; - - private function __construct(SignedLongInteger $value, UnsignedOctet $scale) - { - $this->scale = $scale; - $this->value = $value; + private function __construct( + private SignedLongInteger $value, + private UnsignedOctet $scale, + ) { } /** diff --git a/src/Transport/Frame/Value/LongString.php b/src/Transport/Frame/Value/LongString.php index 7d96785..1e71c9e 100644 --- a/src/Transport/Frame/Value/LongString.php +++ b/src/Transport/Frame/Value/LongString.php @@ -17,11 +17,8 @@ */ final class LongString implements Value { - private Str $original; - - private function __construct(Str $string) + private function __construct(private Str $original) { - $this->original = $string; } /** diff --git a/src/Transport/Frame/Value/Sequence.php b/src/Transport/Frame/Value/Sequence.php index a50b476..66a6dad 100644 --- a/src/Transport/Frame/Value/Sequence.php +++ b/src/Transport/Frame/Value/Sequence.php @@ -26,15 +26,11 @@ */ final class Sequence implements Value { - /** @var Seq */ - private Seq $original; - /** - * @param Seq $values + * @param Seq $original */ - private function __construct(Seq $values) + private function __construct(private Seq $original) { - $this->original = $values; } /** diff --git a/src/Transport/Frame/Value/ShortString.php b/src/Transport/Frame/Value/ShortString.php index 4e60d34..407d9c2 100644 --- a/src/Transport/Frame/Value/ShortString.php +++ b/src/Transport/Frame/Value/ShortString.php @@ -17,11 +17,8 @@ */ final class ShortString implements Value { - private Str $original; - - private function __construct(Str $string) + private function __construct(private Str $original) { - $this->original = $string; } /** diff --git a/src/Transport/Frame/Value/SignedLongInteger.php b/src/Transport/Frame/Value/SignedLongInteger.php index 62e543a..91c894b 100644 --- a/src/Transport/Frame/Value/SignedLongInteger.php +++ b/src/Transport/Frame/Value/SignedLongInteger.php @@ -22,15 +22,11 @@ */ final class SignedLongInteger implements Value { - /** @var int<-2147483648, 2147483647> */ - private int $original; - /** - * @param int<-2147483648, 2147483647> $value + * @param int<-2147483648, 2147483647> $original */ - private function __construct(int $value) + private function __construct(private int $original) { - $this->original = $value; } /** diff --git a/src/Transport/Frame/Value/SignedLongLongInteger.php b/src/Transport/Frame/Value/SignedLongLongInteger.php index ced5057..83f79ba 100644 --- a/src/Transport/Frame/Value/SignedLongLongInteger.php +++ b/src/Transport/Frame/Value/SignedLongLongInteger.php @@ -17,11 +17,8 @@ */ final class SignedLongLongInteger implements Value { - private int $original; - - private function __construct(int $value) + private function __construct(private int $original) { - $this->original = $value; } /** diff --git a/src/Transport/Frame/Value/SignedOctet.php b/src/Transport/Frame/Value/SignedOctet.php index 3a53076..da4aa68 100644 --- a/src/Transport/Frame/Value/SignedOctet.php +++ b/src/Transport/Frame/Value/SignedOctet.php @@ -24,15 +24,11 @@ */ final class SignedOctet implements Value { - /** @var int<-128, 127> */ - private int $original; - /** - * @param int<-128, 127> $octet + * @param int<-128, 127> $original */ - private function __construct(int $octet) + private function __construct(private int $original) { - $this->original = $octet; } /** diff --git a/src/Transport/Frame/Value/SignedShortInteger.php b/src/Transport/Frame/Value/SignedShortInteger.php index 435ce86..308771b 100644 --- a/src/Transport/Frame/Value/SignedShortInteger.php +++ b/src/Transport/Frame/Value/SignedShortInteger.php @@ -22,15 +22,11 @@ */ final class SignedShortInteger implements Value { - /** @var int<-32768, 32767> */ - private int $original; - /** - * @param int<-32768, 32767> $value + * @param int<-32768, 32767> $original */ - private function __construct(int $value) + private function __construct(private int $original) { - $this->original = $value; } /** diff --git a/src/Transport/Frame/Value/Table.php b/src/Transport/Frame/Value/Table.php index 4a65536..4ad4de2 100644 --- a/src/Transport/Frame/Value/Table.php +++ b/src/Transport/Frame/Value/Table.php @@ -25,15 +25,11 @@ */ final class Table implements Value { - /** @var Map */ - private Map $original; - /** - * @param Map $map + * @param Map $original */ - private function __construct(Map $map) + private function __construct(private Map $original) { - $this->original = $map; } /** diff --git a/src/Transport/Frame/Value/Timestamp.php b/src/Transport/Frame/Value/Timestamp.php index 89ff54d..a018fe3 100644 --- a/src/Transport/Frame/Value/Timestamp.php +++ b/src/Transport/Frame/Value/Timestamp.php @@ -25,11 +25,8 @@ */ final class Timestamp implements Value { - private PointInTime $original; - - private function __construct(PointInTime $point) + private function __construct(private PointInTime $original) { - $this->original = $point; } /** diff --git a/src/Transport/Frame/Value/Unpacked.php b/src/Transport/Frame/Value/Unpacked.php index fe28b26..28ca182 100644 --- a/src/Transport/Frame/Value/Unpacked.php +++ b/src/Transport/Frame/Value/Unpacked.php @@ -12,26 +12,21 @@ */ final class Unpacked { - /** @var 0|positive-int */ - private int $read; - /** @var T */ - private Value $value; - /** - * @param 0|positive-int $read + * @param int<0, max> $read * @param T $value */ - private function __construct(int $read, Value $value) - { - $this->read = $read; - $this->value = $value; + private function __construct( + private int $read, + private Value $value, + ) { } /** * @psalm-pure * @template V of Value * - * @param 0|positive-int $read + * @param int<0, max> $read * @param V $value * * @return self @@ -42,7 +37,7 @@ public static function of(int $read, Value $value): self } /** - * @return 0|positive-int + * @return int<0, max> */ public function read(): int { diff --git a/src/Transport/Frame/Value/UnsignedLongInteger.php b/src/Transport/Frame/Value/UnsignedLongInteger.php index e546346..9c327c4 100644 --- a/src/Transport/Frame/Value/UnsignedLongInteger.php +++ b/src/Transport/Frame/Value/UnsignedLongInteger.php @@ -22,15 +22,11 @@ */ final class UnsignedLongInteger implements Value { - /** @var int<0, 4294967295> */ - private int $original; - /** - * @param int<0, 4294967295> $value + * @param int<0, 4294967295> $original */ - private function __construct(int $value) + private function __construct(private int $original) { - $this->original = $value; } /** diff --git a/src/Transport/Frame/Value/UnsignedLongLongInteger.php b/src/Transport/Frame/Value/UnsignedLongLongInteger.php index 197337a..daf130b 100644 --- a/src/Transport/Frame/Value/UnsignedLongLongInteger.php +++ b/src/Transport/Frame/Value/UnsignedLongLongInteger.php @@ -23,15 +23,11 @@ */ final class UnsignedLongLongInteger implements Value { - /** @var int<0, max> */ - private int $original; - /** - * @param int<0, max> $value + * @param int<0, max> $original */ - private function __construct(int $value) + private function __construct(private int $original) { - $this->original = $value; } /** diff --git a/src/Transport/Frame/Value/UnsignedOctet.php b/src/Transport/Frame/Value/UnsignedOctet.php index 6c5e0aa..dd64ee2 100644 --- a/src/Transport/Frame/Value/UnsignedOctet.php +++ b/src/Transport/Frame/Value/UnsignedOctet.php @@ -24,15 +24,11 @@ */ final class UnsignedOctet implements Value { - /** @var int<0, 255> */ - private int $original; - /** - * @param int<0, 255> $octet + * @param int<0, 255> $original */ - private function __construct(int $octet) + private function __construct(private int $original) { - $this->original = $octet; } /** diff --git a/src/Transport/Frame/Value/UnsignedShortInteger.php b/src/Transport/Frame/Value/UnsignedShortInteger.php index f64b0fa..5fdade1 100644 --- a/src/Transport/Frame/Value/UnsignedShortInteger.php +++ b/src/Transport/Frame/Value/UnsignedShortInteger.php @@ -22,15 +22,11 @@ */ final class UnsignedShortInteger implements Value { - /** @var int<0, 65535> */ - private int $original; - /** - * @param int<0, 65535> $value + * @param int<0, 65535> $original */ - private function __construct(int $value) + private function __construct(private int $original) { - $this->original = $value; } /** diff --git a/src/Transport/Protocol/Basic.php b/src/Transport/Protocol/Basic.php index 43245ee..885a0b8 100644 --- a/src/Transport/Protocol/Basic.php +++ b/src/Transport/Protocol/Basic.php @@ -39,11 +39,8 @@ */ final class Basic { - private ArgumentTranslator $translate; - - public function __construct(ArgumentTranslator $translator) + public function __construct(private ArgumentTranslator $translate) { - $this->translate = $translator; } /** diff --git a/src/Transport/Protocol/Exchange.php b/src/Transport/Protocol/Exchange.php index 8916851..a2d49f9 100644 --- a/src/Transport/Protocol/Exchange.php +++ b/src/Transport/Protocol/Exchange.php @@ -24,11 +24,8 @@ */ final class Exchange { - private ArgumentTranslator $translate; - - public function __construct(ArgumentTranslator $translator) + public function __construct(private ArgumentTranslator $translate) { - $this->translate = $translator; } /** diff --git a/src/Transport/Protocol/Queue.php b/src/Transport/Protocol/Queue.php index 1f6edaf..544026e 100644 --- a/src/Transport/Protocol/Queue.php +++ b/src/Transport/Protocol/Queue.php @@ -28,11 +28,8 @@ */ final class Queue { - private ArgumentTranslator $translate; - - public function __construct(ArgumentTranslator $translator) + public function __construct(private ArgumentTranslator $translate) { - $this->translate = $translator; } /** diff --git a/src/Transport/ReceivedFrame.php b/src/Transport/ReceivedFrame.php index 281d667..aa0f8f7 100644 --- a/src/Transport/ReceivedFrame.php +++ b/src/Transport/ReceivedFrame.php @@ -8,11 +8,8 @@ */ final class ReceivedFrame { - private Frame $frame; - - private function __construct(Frame $frame) + private function __construct(private Frame $frame) { - $this->frame = $frame; } public static function of(Frame $frame): self