Skip to content

Commit 4d00525

Browse files
Use CPP where possible
1 parent 5183786 commit 4d00525

6 files changed

+21
-28
lines changed

Envelope.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ final class Envelope
2424
* @var array<class-string<StampInterface>, list<StampInterface>>
2525
*/
2626
private array $stamps = [];
27-
private object $message;
2827

2928
/**
3029
* @param object|Envelope $message
3130
* @param StampInterface[] $stamps
3231
*/
33-
public function __construct(object $message, array $stamps = [])
34-
{
35-
$this->message = $message;
32+
public function __construct(
33+
private object $message,
34+
array $stamps = [],
35+
) {
3636

3737
foreach ($stamps as $stamp) {
3838
$this->stamps[$stamp::class][] = $stamp;

MessageBus.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ public function __construct(iterable $middlewareHandlers = [])
3636
// $this->middlewareAggregate should be an instance of IteratorAggregate.
3737
// When $middlewareHandlers is an Iterator, we wrap it to ensure it is lazy-loaded and can be rewound.
3838
$this->middlewareAggregate = new class($middlewareHandlers) implements \IteratorAggregate {
39-
private \Traversable $middlewareHandlers;
4039
private \ArrayObject $cachedIterator;
4140

42-
public function __construct(\Traversable $middlewareHandlers)
43-
{
44-
$this->middlewareHandlers = $middlewareHandlers;
41+
public function __construct(
42+
private \Traversable $middlewareHandlers,
43+
) {
4544
}
4645

4746
public function getIterator(): \Traversable

Middleware/DispatchAfterCurrentBusMiddleware.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
110110
final class QueuedEnvelope
111111
{
112112
private Envelope $envelope;
113-
private StackInterface $stack;
114113

115-
public function __construct(Envelope $envelope, StackInterface $stack)
116-
{
114+
public function __construct(
115+
Envelope $envelope,
116+
private StackInterface $stack,
117+
) {
117118
$this->envelope = $envelope->withoutAll(DispatchAfterCurrentBusStamp::class);
118-
$this->stack = $stack;
119119
}
120120

121121
public function getEnvelope(): Envelope

RoutableMessageBus.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525
*/
2626
class RoutableMessageBus implements MessageBusInterface
2727
{
28-
private ContainerInterface $busLocator;
29-
private ?MessageBusInterface $fallbackBus;
30-
31-
public function __construct(ContainerInterface $busLocator, ?MessageBusInterface $fallbackBus = null)
32-
{
33-
$this->busLocator = $busLocator;
34-
$this->fallbackBus = $fallbackBus;
28+
public function __construct(
29+
private ContainerInterface $busLocator,
30+
private ?MessageBusInterface $fallbackBus = null,
31+
) {
3532
}
3633

3734
public function dispatch(object $envelope, array $stamps = []): Envelope

TraceableMessageBus.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
*/
1717
class TraceableMessageBus implements MessageBusInterface
1818
{
19-
private MessageBusInterface $decoratedBus;
2019
private array $dispatchedMessages = [];
2120

22-
public function __construct(MessageBusInterface $decoratedBus)
23-
{
24-
$this->decoratedBus = $decoratedBus;
21+
public function __construct(
22+
private MessageBusInterface $decoratedBus,
23+
) {
2524
}
2625

2726
public function dispatch(object $message, array $stamps = []): Envelope

WorkerMetadata.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
*/
1717
final class WorkerMetadata
1818
{
19-
private array $metadata;
20-
21-
public function __construct(array $metadata)
22-
{
23-
$this->metadata = $metadata;
19+
public function __construct(
20+
private array $metadata,
21+
) {
2422
}
2523

2624
public function set(array $newMetadata): void

0 commit comments

Comments
 (0)