diff --git a/psalm.xml b/psalm.xml index 510148d..feccc34 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,4 +14,7 @@ + + + diff --git a/src/Control.php b/src/Control.php index 73ea311..853697e 100644 --- a/src/Control.php +++ b/src/Control.php @@ -19,6 +19,7 @@ private function __construct( ) { } + #[\NoDiscard] public static function of(Server $server): self { return new self( @@ -28,16 +29,19 @@ public static function of(Server $server): self ); } + #[\NoDiscard] public function users(): Users { return $this->users; } + #[\NoDiscard] public function vhosts(): VHosts { return $this->vhosts; } + #[\NoDiscard] public function permissions(): Permissions { return $this->permissions; diff --git a/src/Control/Permissions.php b/src/Control/Permissions.php index 6cc7081..700d43d 100644 --- a/src/Control/Permissions.php +++ b/src/Control/Permissions.php @@ -20,6 +20,7 @@ private function __construct( ) { } + #[\NoDiscard] public static function of(Server $server): self { return new self($server, Command::foreground('rabbitmqadmin')); @@ -28,6 +29,7 @@ public static function of(Server $server): self /** * @return Attempt */ + #[\NoDiscard] public function declare( string $vhost, string $user, @@ -58,6 +60,7 @@ public function declare( /** * @return Attempt */ + #[\NoDiscard] public function delete(string $vhost, string $user): Attempt { return $this diff --git a/src/Control/Users.php b/src/Control/Users.php index 20cc6c4..c674c32 100644 --- a/src/Control/Users.php +++ b/src/Control/Users.php @@ -20,6 +20,7 @@ private function __construct( ) { } + #[\NoDiscard] public static function of(Server $server): self { return new self($server, Command::foreground('rabbitmqadmin')); @@ -28,6 +29,7 @@ public static function of(Server $server): self /** * @return Attempt */ + #[\NoDiscard] public function declare(string $name, string $password, string ...$tags): Attempt { return $this @@ -51,6 +53,7 @@ public function declare(string $name, string $password, string ...$tags): Attemp /** * @return Attempt */ + #[\NoDiscard] public function delete(string $name): Attempt { return $this diff --git a/src/Control/VHosts.php b/src/Control/VHosts.php index 2720c07..3f6e5c9 100644 --- a/src/Control/VHosts.php +++ b/src/Control/VHosts.php @@ -20,6 +20,7 @@ private function __construct( ) { } + #[\NoDiscard] public static function of(Server $server): self { return new self($server, Command::foreground('rabbitmqadmin')); @@ -28,6 +29,7 @@ public static function of(Server $server): self /** * @return Attempt */ + #[\NoDiscard] public function declare(string $name): Attempt { return $this @@ -49,6 +51,7 @@ public function declare(string $name): Attempt /** * @return Attempt */ + #[\NoDiscard] public function delete(string $name): Attempt { return $this diff --git a/src/Model/Channel.php b/src/Model/Channel.php index 12f84e1..1907480 100644 --- a/src/Model/Channel.php +++ b/src/Model/Channel.php @@ -38,6 +38,7 @@ private function __construct( * * @param Maybe $idleSince */ + #[\NoDiscard] public static function of( Name $name, VHost\Name $vhost, @@ -66,51 +67,61 @@ public static function of( ); } + #[\NoDiscard] public function name(): Name { return $this->name; } + #[\NoDiscard] public function vhost(): VHost\Name { return $this->vhost; } + #[\NoDiscard] public function user(): User\Name { return $this->user; } + #[\NoDiscard] public function number(): int { return $this->number; } + #[\NoDiscard] public function node(): Node\Name { return $this->node; } + #[\NoDiscard] public function state(): State { return $this->state; } + #[\NoDiscard] public function messages(): Messages { return $this->messages; } + #[\NoDiscard] public function consumers(): Count { return $this->consumers; } + #[\NoDiscard] public function confirm(): bool { return $this->confirm; } + #[\NoDiscard] public function transactional(): bool { return $this->transactional; @@ -119,6 +130,7 @@ public function transactional(): bool /** * @return Maybe */ + #[\NoDiscard] public function idleSince(): Maybe { return $this->idleSince; diff --git a/src/Model/Channel/Messages.php b/src/Model/Channel/Messages.php index 5f16acd..4bad873 100644 --- a/src/Model/Channel/Messages.php +++ b/src/Model/Channel/Messages.php @@ -20,6 +20,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( Count $uncommitted, Count $unconfirmed, @@ -28,16 +29,19 @@ public static function of( return new self($uncommitted, $unconfirmed, $unacknowledged); } + #[\NoDiscard] public function uncommitted(): Count { return $this->uncommitted; } + #[\NoDiscard] public function unconfirmed(): Count { return $this->unconfirmed; } + #[\NoDiscard] public function unacknowledged(): Count { return $this->unacknowledged; diff --git a/src/Model/Channel/Name.php b/src/Model/Channel/Name.php index 01b35c1..5806f9e 100644 --- a/src/Model/Channel/Name.php +++ b/src/Model/Channel/Name.php @@ -15,11 +15,13 @@ private function __construct(private string $value) /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return new self($value); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Model/Connection.php b/src/Model/Connection.php index 6461eeb..0f172cc 100644 --- a/src/Model/Connection.php +++ b/src/Model/Connection.php @@ -43,6 +43,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( Name $name, PointInTime $connectedAt, @@ -77,71 +78,85 @@ public static function of( ); } + #[\NoDiscard] public function name(): Name { return $this->name; } + #[\NoDiscard] public function connectedAt(): PointInTime { return $this->connectedAt; } + #[\NoDiscard] public function timeout(): Timeout { return $this->timeout; } + #[\NoDiscard] public function vhost(): VHost\Name { return $this->vhost; } + #[\NoDiscard] public function user(): User\Name { return $this->user; } + #[\NoDiscard] public function protocol(): Protocol { return $this->protocol; } + #[\NoDiscard] public function authenticationMechanism(): AuthenticationMechanism { return $this->authenticationMechanism; } + #[\NoDiscard] public function ssl(): bool { return $this->ssl; } + #[\NoDiscard] public function peer(): Peer { return $this->peer; } + #[\NoDiscard] public function host(): Host { return $this->host; } + #[\NoDiscard] public function port(): Port { return $this->port; } + #[\NoDiscard] public function node(): Node\Name { return $this->node; } + #[\NoDiscard] public function type(): Type { return $this->type; } + #[\NoDiscard] public function state(): State { return $this->state; diff --git a/src/Model/Connection/AuthenticationMechanism.php b/src/Model/Connection/AuthenticationMechanism.php index fab5b3c..c6079e6 100644 --- a/src/Model/Connection/AuthenticationMechanism.php +++ b/src/Model/Connection/AuthenticationMechanism.php @@ -15,6 +15,7 @@ enum AuthenticationMechanism /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return match ($value) { @@ -24,6 +25,7 @@ public static function of(string $value): self }; } + #[\NoDiscard] public function toString(): string { return match ($this) { diff --git a/src/Model/Connection/Name.php b/src/Model/Connection/Name.php index 2cdf547..517b617 100644 --- a/src/Model/Connection/Name.php +++ b/src/Model/Connection/Name.php @@ -15,11 +15,13 @@ private function __construct(private string $value) /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return new self($value); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Model/Connection/Peer.php b/src/Model/Connection/Peer.php index a888f40..432237c 100644 --- a/src/Model/Connection/Peer.php +++ b/src/Model/Connection/Peer.php @@ -22,16 +22,19 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of(Host $host, Port $port): self { return new self($host, $port); } + #[\NoDiscard] public function host(): Host { return $this->host; } + #[\NoDiscard] public function port(): Port { return $this->port; diff --git a/src/Model/Connection/Protocol.php b/src/Model/Connection/Protocol.php index 840730a..4f9211f 100644 --- a/src/Model/Connection/Protocol.php +++ b/src/Model/Connection/Protocol.php @@ -16,6 +16,7 @@ enum Protocol /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return match ($value) { diff --git a/src/Model/Connection/Timeout.php b/src/Model/Connection/Timeout.php index e392311..8078520 100644 --- a/src/Model/Connection/Timeout.php +++ b/src/Model/Connection/Timeout.php @@ -20,6 +20,7 @@ private function __construct(private int $value) * * @param int<0, max> $value */ + #[\NoDiscard] public static function of(int $value): self { return new self($value); @@ -28,6 +29,7 @@ public static function of(int $value): self /** * @return int<0, max> */ + #[\NoDiscard] public function toInt(): int { return $this->value; diff --git a/src/Model/Consumer.php b/src/Model/Consumer.php index de27138..56dfb18 100644 --- a/src/Model/Consumer.php +++ b/src/Model/Consumer.php @@ -27,6 +27,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( Tag $tag, Name $channel, @@ -45,31 +46,37 @@ public static function of( ); } + #[\NoDiscard] public function tag(): Tag { return $this->tag; } + #[\NoDiscard] public function channel(): Name { return $this->channel; } + #[\NoDiscard] public function queue(): Identity { return $this->queue; } + #[\NoDiscard] public function connection(): Connection\Name { return $this->connection; } + #[\NoDiscard] public function ackRequired(): bool { return $this->ackRequired; } + #[\NoDiscard] public function exclusive(): bool { return $this->exclusive; diff --git a/src/Model/Consumer/Tag.php b/src/Model/Consumer/Tag.php index 0c1b9f8..40a0fd9 100644 --- a/src/Model/Consumer/Tag.php +++ b/src/Model/Consumer/Tag.php @@ -15,11 +15,13 @@ private function __construct(private string $value) /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return new self($value); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Model/Count.php b/src/Model/Count.php index 25e9be2..ff4c061 100644 --- a/src/Model/Count.php +++ b/src/Model/Count.php @@ -18,6 +18,7 @@ private function __construct(private int $value) /** * @param int<0, max> $value */ + #[\NoDiscard] public static function of(int $value): self { return new self($value); @@ -26,6 +27,7 @@ public static function of(int $value): self /** * @return int<0, max> */ + #[\NoDiscard] public function toInt(): int { return $this->value; diff --git a/src/Model/Exchange.php b/src/Model/Exchange.php index b887716..ddf4825 100644 --- a/src/Model/Exchange.php +++ b/src/Model/Exchange.php @@ -26,6 +26,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( Name $name, VHost\Name $vhost, @@ -44,31 +45,37 @@ public static function of( ); } + #[\NoDiscard] public function name(): Name { return $this->name; } + #[\NoDiscard] public function vhost(): VHost\Name { return $this->vhost; } + #[\NoDiscard] public function type(): Type { return $this->type; } + #[\NoDiscard] public function durable(): bool { return $this->durable; } + #[\NoDiscard] public function autoDelete(): bool { return $this->autoDelete; } + #[\NoDiscard] public function internal(): bool { return $this->internal; diff --git a/src/Model/Exchange/Name.php b/src/Model/Exchange/Name.php index ae9accf..df74adf 100644 --- a/src/Model/Exchange/Name.php +++ b/src/Model/Exchange/Name.php @@ -15,11 +15,13 @@ private function __construct(private string $value) /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return new self($value); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Model/Node.php b/src/Model/Node.php index 1a9d1f3..608a67f 100644 --- a/src/Model/Node.php +++ b/src/Model/Node.php @@ -23,21 +23,25 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of(Name $name, Type $type, bool $running): self { return new self($name, $type, $running); } + #[\NoDiscard] public function name(): Name { return $this->name; } + #[\NoDiscard] public function type(): Type { return $this->type; } + #[\NoDiscard] public function running(): bool { return $this->running; diff --git a/src/Model/Node/Name.php b/src/Model/Node/Name.php index c34ba8e..cff56c5 100644 --- a/src/Model/Node/Name.php +++ b/src/Model/Node/Name.php @@ -26,6 +26,7 @@ private function __construct( * * @throws DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -39,6 +40,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return Str::of($value) @@ -49,11 +51,13 @@ public static function maybe(string $value): Maybe ->map(static fn($host) => new self($value, $host)); } + #[\NoDiscard] public function host(): Host { return $this->host; } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Model/Permission.php b/src/Model/Permission.php index 46ed168..79ca4c3 100644 --- a/src/Model/Permission.php +++ b/src/Model/Permission.php @@ -20,6 +20,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( User\Name $user, VHost\Name $vhost, @@ -36,26 +37,31 @@ public static function of( ); } + #[\NoDiscard] public function user(): User\Name { return $this->user; } + #[\NoDiscard] public function vhost(): VHost\Name { return $this->vhost; } + #[\NoDiscard] public function configure(): string { return $this->configure; } + #[\NoDiscard] public function write(): string { return $this->write; } + #[\NoDiscard] public function read(): string { return $this->read; diff --git a/src/Model/Queue.php b/src/Model/Queue.php index 42d54c7..522d3b8 100644 --- a/src/Model/Queue.php +++ b/src/Model/Queue.php @@ -36,6 +36,7 @@ private function __construct( * * @param Maybe $idleSince */ + #[\NoDiscard] public static function of( Identity $identity, Messages $messages, @@ -60,11 +61,13 @@ public static function of( ); } + #[\NoDiscard] public function identity(): Identity { return $this->identity; } + #[\NoDiscard] public function messages(): Messages { return $this->messages; @@ -73,36 +76,43 @@ public function messages(): Messages /** * @return Maybe */ + #[\NoDiscard] public function idleSince(): Maybe { return $this->idleSince; } + #[\NoDiscard] public function consumers(): Count { return $this->consumers; } + #[\NoDiscard] public function state(): State { return $this->state; } + #[\NoDiscard] public function node(): Node\Name { return $this->node; } + #[\NoDiscard] public function exclusive(): bool { return $this->exclusive; } + #[\NoDiscard] public function autoDelete(): bool { return $this->autoDelete; } + #[\NoDiscard] public function durable(): bool { return $this->durable; diff --git a/src/Model/Queue/Identity.php b/src/Model/Queue/Identity.php index 546fcf1..49f7361 100644 --- a/src/Model/Queue/Identity.php +++ b/src/Model/Queue/Identity.php @@ -19,16 +19,19 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $name, Name $vhost): self { return new self($name, $vhost); } + #[\NoDiscard] public function name(): string { return $this->name; } + #[\NoDiscard] public function vhost(): Name { return $this->vhost; diff --git a/src/Model/Queue/Messages.php b/src/Model/Queue/Messages.php index 8a281d2..07b15b5 100644 --- a/src/Model/Queue/Messages.php +++ b/src/Model/Queue/Messages.php @@ -20,6 +20,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( Count $total, Count $ready, @@ -28,16 +29,19 @@ public static function of( return new self($total, $ready, $unacknowledged); } + #[\NoDiscard] public function total(): Count { return $this->total; } + #[\NoDiscard] public function ready(): Count { return $this->ready; } + #[\NoDiscard] public function unacknowledged(): Count { return $this->unacknowledged; diff --git a/src/Model/User.php b/src/Model/User.php index d031104..f0d8904 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -28,6 +28,7 @@ private function __construct( * @no-named-arguments * @psalm-pure */ + #[\NoDiscard] public static function of( Name $name, Password $password, @@ -40,11 +41,13 @@ public static function of( ); } + #[\NoDiscard] public function name(): Name { return $this->name; } + #[\NoDiscard] public function password(): Password { return $this->password; @@ -53,6 +56,7 @@ public function password(): Password /** * @return Set */ + #[\NoDiscard] public function tags(): Set { return $this->tags; diff --git a/src/Model/User/Name.php b/src/Model/User/Name.php index 45ca23d..d728def 100644 --- a/src/Model/User/Name.php +++ b/src/Model/User/Name.php @@ -15,11 +15,13 @@ private function __construct(private string $value) /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return new self($value); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Model/User/Password.php b/src/Model/User/Password.php index e57e3be..cc17ba7 100644 --- a/src/Model/User/Password.php +++ b/src/Model/User/Password.php @@ -17,16 +17,19 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $hash, string $algorithm): self { return new self($hash, $algorithm); } + #[\NoDiscard] public function algorithm(): string { return $this->algorithm; } + #[\NoDiscard] public function hash(): string { return $this->hash; diff --git a/src/Model/VHost.php b/src/Model/VHost.php index 8b40d5a..a044b9f 100644 --- a/src/Model/VHost.php +++ b/src/Model/VHost.php @@ -23,26 +23,31 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of(Name $name, Messages $messages, bool $tracing): self { return new self($name, $messages, $tracing); } + #[\NoDiscard] public function tracing(): bool { return $this->tracing; } + #[\NoDiscard] public function name(): Name { return $this->name; } + #[\NoDiscard] public function messages(): Messages { return $this->messages; } + #[\NoDiscard] public function toString(): string { return $this->name->toString(); diff --git a/src/Model/VHost/Messages.php b/src/Model/VHost/Messages.php index 08089a6..52864c5 100644 --- a/src/Model/VHost/Messages.php +++ b/src/Model/VHost/Messages.php @@ -20,6 +20,7 @@ private function __construct( /** * @psalm-pure */ + #[\NoDiscard] public static function of( Count $total, Count $ready, @@ -28,16 +29,19 @@ public static function of( return new self($total, $ready, $unacknowledged); } + #[\NoDiscard] public function total(): Count { return $this->total; } + #[\NoDiscard] public function ready(): Count { return $this->ready; } + #[\NoDiscard] public function unacknowledged(): Count { return $this->unacknowledged; diff --git a/src/Model/VHost/Name.php b/src/Model/VHost/Name.php index 4a45aac..06f6f1d 100644 --- a/src/Model/VHost/Name.php +++ b/src/Model/VHost/Name.php @@ -15,11 +15,13 @@ private function __construct(private string $value) /** * @psalm-pure */ + #[\NoDiscard] public static function of(string $value): self { return new self($value); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Status.php b/src/Status.php index c5fb722..fdfdf5a 100644 --- a/src/Status.php +++ b/src/Status.php @@ -52,6 +52,7 @@ private function __construct( ) { } + #[\NoDiscard] public static function of( Server $server, Clock $clock, @@ -70,6 +71,7 @@ public static function of( /** * @return Sequence */ + #[\NoDiscard] public function users(): Sequence { /** @psalm-suppress MixedArgument */ @@ -107,6 +109,7 @@ public function users(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function vhosts(): Sequence { /** @psalm-suppress MixedArgument */ @@ -158,6 +161,7 @@ public function vhosts(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function connections(): Sequence { /** @psalm-suppress MixedArgument */ @@ -271,6 +275,7 @@ public function connections(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function exchanges(): Sequence { /** @psalm-suppress MixedArgument */ @@ -326,6 +331,7 @@ public function exchanges(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function permissions(): Sequence { /** @psalm-suppress MixedArgument */ @@ -366,6 +372,7 @@ public function permissions(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function channels(): Sequence { /** @psalm-suppress MixedArgument */ @@ -474,6 +481,7 @@ public function channels(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function consumers(): Sequence { /** @psalm-suppress MixedArgument,MixedArrayAccess */ @@ -532,6 +540,7 @@ public function consumers(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function queues(): Sequence { /** @psalm-suppress MixedArgument */ @@ -635,6 +644,7 @@ public function queues(): Sequence /** * @return Sequence */ + #[\NoDiscard] public function nodes(): Sequence { /** @psalm-suppress MixedArgument */