Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,17 @@

final class Client
{
/** @var Maybe<Command> */
private Maybe $command;
/** @var callable(): Attempt<Connection> */
private $load;
private Filesystem $filesystem;
/** @var Maybe<CurrentProcess> */
private Maybe $signals;

/**
* @param Maybe<Command> $command
* @param callable(): Attempt<Connection> $load
* @param \Closure(): Attempt<Connection> $load
* @param Maybe<CurrentProcess> $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;
}

/**
Expand All @@ -60,7 +48,7 @@ public static function of(callable $load, Filesystem $filesystem): self

return new self(
$command,
$load,
\Closure::fromCallable($load),
$filesystem,
$signals,
);
Expand Down
5 changes: 1 addition & 4 deletions src/Client/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/Command/Bind.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 6 additions & 10 deletions src/Command/Consume.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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));
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Command/DeclareExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/Command/DeclareQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/Command/DeleteExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/Command/DeleteQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
24 changes: 9 additions & 15 deletions src/Command/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions src/Command/Pipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 1 addition & 5 deletions src/Command/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@

final class Publish implements Command
{
/** @var Sequence<Model> */
private Sequence $commands;

/**
* @param Sequence<Model> $commands
*/
private function __construct(Sequence $commands)
private function __construct(private Sequence $commands)
{
$this->commands = $commands;
}

#[\Override]
Expand Down
5 changes: 1 addition & 4 deletions src/Command/Purge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/Command/Qos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 6 additions & 10 deletions src/Command/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/Command/Unbind.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/Consumer/Canceled.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions src/Consumer/Continuation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 5 additions & 18 deletions src/Consumer/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<Count> */
private Maybe $messages;

/**
* @param int<0, max> $deliveryTag
* @param Maybe<Count> $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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading