Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a01e3a1

Browse files
committed
[Notifier] Use CPP
1 parent ccbdc1a commit a01e3a1

24 files changed

+86
-150
lines changed

src/Symfony/Component/Notifier/Channel/BrowserChannel.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@
2222
*/
2323
final class BrowserChannel implements ChannelInterface
2424
{
25-
private RequestStack $stack;
26-
27-
private FlashMessageImportanceMapperInterface $mapper;
28-
29-
public function __construct(RequestStack $stack, FlashMessageImportanceMapperInterface $mapper = new DefaultFlashMessageImportanceMapper())
30-
{
31-
$this->stack = $stack;
32-
$this->mapper = $mapper;
25+
public function __construct(
26+
private RequestStack $stack,
27+
private FlashMessageImportanceMapperInterface $mapper = new DefaultFlashMessageImportanceMapper(),
28+
) {
3329
}
3430

3531
public function notify(Notification $notification, RecipientInterface $recipient, string $transportName = null): void

src/Symfony/Component/Notifier/Channel/ChannelPolicy.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
*/
1919
final class ChannelPolicy implements ChannelPolicyInterface
2020
{
21-
private array $policy;
22-
23-
public function __construct(array $policy)
21+
public function __construct(private array $policy)
2422
{
25-
$this->policy = $policy;
2623
}
2724

2825
public function getChannels(string $importance): array

src/Symfony/Component/Notifier/Channel/EmailChannel.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@
2929
*/
3030
class EmailChannel implements ChannelInterface
3131
{
32-
private ?TransportInterface $transport;
33-
private ?MessageBusInterface $bus;
3432
private string|Address|null $from;
35-
private ?Envelope $envelope;
3633

37-
public function __construct(TransportInterface $transport = null, MessageBusInterface $bus = null, string $from = null, Envelope $envelope = null)
38-
{
34+
public function __construct(
35+
private ?TransportInterface $transport = null,
36+
private ?MessageBusInterface $bus = null,
37+
string $from = null,
38+
private ?Envelope $envelope = null,
39+
) {
3940
if (null === $transport && null === $bus) {
4041
throw new LogicException(sprintf('"%s" needs a Transport or a Bus but both cannot be "null".', static::class));
4142
}
4243

43-
$this->transport = $transport;
44-
$this->bus = $bus;
4544
$this->from = $from ?: $envelope?->getSender();
46-
$this->envelope = $envelope;
4745
}
4846

4947
/**

src/Symfony/Component/Notifier/Chatter.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@
2323
*/
2424
final class Chatter implements ChatterInterface
2525
{
26-
private TransportInterface $transport;
27-
private ?MessageBusInterface $bus;
28-
private ?EventDispatcherInterface $dispatcher;
29-
30-
public function __construct(TransportInterface $transport, MessageBusInterface $bus = null, EventDispatcherInterface $dispatcher = null)
31-
{
32-
$this->transport = $transport;
33-
$this->bus = $bus;
34-
$this->dispatcher = $dispatcher;
26+
public function __construct(
27+
private TransportInterface $transport,
28+
private ?MessageBusInterface $bus = null,
29+
private ?EventDispatcherInterface $dispatcher = null,
30+
) {
3531
}
3632

3733
public function __toString(): string

src/Symfony/Component/Notifier/DataCollector/NotificationDataCollector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
*/
2323
final class NotificationDataCollector extends DataCollector
2424
{
25-
private NotificationLoggerListener $logger;
26-
27-
public function __construct(NotificationLoggerListener $logger)
25+
public function __construct(private NotificationLoggerListener $logger)
2826
{
29-
$this->logger = $logger;
3027
}
3128

3229
public function collect(Request $request, Response $response, \Throwable $exception = null): void

src/Symfony/Component/Notifier/Event/FailedMessageEvent.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
*/
2020
final class FailedMessageEvent extends Event
2121
{
22-
private MessageInterface $message;
23-
private \Throwable $error;
24-
25-
public function __construct(MessageInterface $message, \Throwable $error)
26-
{
27-
$this->message = $message;
28-
$this->error = $error;
22+
public function __construct(
23+
private MessageInterface $message,
24+
private \Throwable $error,
25+
) {
2926
}
3027

3128
public function getMessage(): MessageInterface

src/Symfony/Component/Notifier/Event/MessageEvent.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
*/
2020
final class MessageEvent extends Event
2121
{
22-
private MessageInterface $message;
23-
private bool $queued;
24-
25-
public function __construct(MessageInterface $message, bool $queued = false)
26-
{
27-
$this->message = $message;
28-
$this->queued = $queued;
22+
public function __construct(
23+
private MessageInterface $message,
24+
private bool $queued = false,
25+
) {
2926
}
3027

3128
public function getMessage(): MessageInterface

src/Symfony/Component/Notifier/Event/SentMessageEvent.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
*/
2020
final class SentMessageEvent extends Event
2121
{
22-
private SentMessage $message;
23-
24-
public function __construct(SentMessage $message)
22+
public function __construct(private SentMessage $message)
2523
{
26-
$this->message = $message;
2724
}
2825

2926
public function getMessage(): SentMessage

src/Symfony/Component/Notifier/EventListener/SendFailedMessageToNotifierListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
*/
2525
class SendFailedMessageToNotifierListener implements EventSubscriberInterface
2626
{
27-
private Notifier $notifier;
28-
29-
public function __construct(Notifier $notifier)
27+
public function __construct(private Notifier $notifier)
3028
{
31-
$this->notifier = $notifier;
3229
}
3330

3431
public function onMessageFailed(WorkerMessageFailedEvent $event): void

src/Symfony/Component/Notifier/Exception/IncompleteDsnException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
*/
1717
class IncompleteDsnException extends InvalidArgumentException
1818
{
19-
private ?string $dsn;
20-
21-
public function __construct(string $message, string $dsn = null, \Throwable $previous = null)
22-
{
23-
$this->dsn = $dsn;
19+
public function __construct(
20+
string $message,
21+
private ?string $dsn = null,
22+
\Throwable $previous = null,
23+
) {
2424
if ($dsn) {
2525
$message = sprintf('Invalid "%s" notifier DSN: %s', $dsn, $message);
2626
}

src/Symfony/Component/Notifier/Exception/TransportException.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
*/
1919
class TransportException extends RuntimeException implements TransportExceptionInterface
2020
{
21-
private ResponseInterface $response;
2221
private string $debug = '';
2322

24-
public function __construct(string $message, ResponseInterface $response, int $code = 0, \Throwable $previous = null)
25-
{
26-
$this->response = $response;
23+
public function __construct(
24+
string $message,
25+
private ResponseInterface $response,
26+
int $code = 0,
27+
\Throwable $previous = null,
28+
) {
2729
$this->debug .= $response->getInfo('debug') ?? '';
2830

2931
parent::__construct($message, $code, $previous);

src/Symfony/Component/Notifier/Message/ChatMessage.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
class ChatMessage implements MessageInterface, FromNotificationInterface
2020
{
2121
private ?string $transport = null;
22-
private string $subject;
23-
private ?MessageOptionsInterface $options;
2422
private ?Notification $notification = null;
2523

26-
public function __construct(string $subject, MessageOptionsInterface $options = null)
27-
{
28-
$this->subject = $subject;
29-
$this->options = $options;
24+
public function __construct(
25+
private string $subject,
26+
private ?MessageOptionsInterface $options = null,
27+
) {
3028
}
3129

3230
public static function fromNotification(Notification $notification): self

src/Symfony/Component/Notifier/Message/EmailMessage.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@
2525
*/
2626
class EmailMessage implements MessageInterface, FromNotificationInterface
2727
{
28-
private RawMessage $message;
29-
private ?Envelope $envelope;
3028
private ?Notification $notification = null;
3129

32-
public function __construct(RawMessage $message, Envelope $envelope = null)
33-
{
34-
$this->message = $message;
35-
$this->envelope = $envelope;
30+
public function __construct(
31+
private RawMessage $message,
32+
private ?Envelope $envelope = null,
33+
) {
3634
}
3735

3836
public static function fromNotification(Notification $notification, EmailRecipientInterface $recipient): self

src/Symfony/Component/Notifier/Message/PushMessage.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@
1919
class PushMessage implements MessageInterface, FromNotificationInterface
2020
{
2121
private ?string $transport = null;
22-
private string $subject;
23-
private string $content;
24-
private ?MessageOptionsInterface $options;
2522
private ?Notification $notification = null;
2623

27-
public function __construct(string $subject, string $content, MessageOptionsInterface $options = null)
28-
{
29-
$this->subject = $subject;
30-
$this->content = $content;
31-
$this->options = $options;
24+
public function __construct(
25+
private string $subject,
26+
private string $content,
27+
private ?MessageOptionsInterface $options = null,
28+
) {
3229
}
3330

3431
public static function fromNotification(Notification $notification): self

src/Symfony/Component/Notifier/Message/SentMessage.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
*/
1717
class SentMessage
1818
{
19-
private MessageInterface $original;
20-
private string $transport;
2119
private ?string $messageId = null;
2220

23-
public function __construct(MessageInterface $original, string $transport)
24-
{
25-
$this->original = $original;
26-
$this->transport = $transport;
21+
public function __construct(
22+
private MessageInterface $original,
23+
private string $transport,
24+
) {
2725
}
2826

2927
public function getOriginalMessage(): MessageInterface

src/Symfony/Component/Notifier/Message/SmsMessage.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,17 @@
2121
class SmsMessage implements MessageInterface, FromNotificationInterface
2222
{
2323
private ?string $transport = null;
24-
private string $subject;
25-
private string $phone;
26-
private string $from;
27-
private ?MessageOptionsInterface $options;
2824
private ?Notification $notification = null;
2925

30-
public function __construct(string $phone, string $subject, string $from = '', MessageOptionsInterface $options = null)
31-
{
26+
public function __construct(
27+
private string $phone,
28+
private string $subject,
29+
private string $from = '',
30+
private ?MessageOptionsInterface $options = null,
31+
) {
3232
if ('' === $phone) {
3333
throw new InvalidArgumentException(sprintf('"%s" needs a phone number, it cannot be empty.', __CLASS__));
3434
}
35-
36-
$this->subject = $subject;
37-
$this->phone = $phone;
38-
$this->from = $from;
39-
$this->options = $options;
4035
}
4136

4237
public static function fromNotification(Notification $notification, SmsRecipientInterface $recipient): self

src/Symfony/Component/Notifier/Messenger/MessageHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
*/
2121
final class MessageHandler
2222
{
23-
private TransportInterface $transport;
24-
25-
public function __construct(TransportInterface $transport)
23+
public function __construct(private TransportInterface $transport)
2624
{
27-
$this->transport = $transport;
2825
}
2926

3027
public function __invoke(MessageInterface $message): ?SentMessage

src/Symfony/Component/Notifier/Notification/Notification.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,19 @@ class Notification
3636
public const IMPORTANCE_MEDIUM = 'medium';
3737
public const IMPORTANCE_LOW = 'low';
3838

39-
private array $channels = [];
40-
private string $subject = '';
4139
private string $content = '';
4240
private string $emoji = '';
4341
private ?FlattenException $exception = null;
4442
private string $exceptionAsString = '';
4543
private string $importance = self::IMPORTANCE_HIGH;
4644

47-
/**
48-
* @param list<string> $channels
49-
*/
50-
public function __construct(string $subject = '', array $channels = [])
51-
{
52-
$this->subject = $subject;
53-
$this->channels = $channels;
45+
public function __construct(
46+
private string $subject = '',
47+
/**
48+
* @var list<string>
49+
*/
50+
private array $channels = [],
51+
) {
5452
}
5553

5654
/**

src/Symfony/Component/Notifier/Notifier.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
final class Notifier implements NotifierInterface
2828
{
2929
private array $adminRecipients = [];
30-
private array|ContainerInterface $channels;
31-
private ?ChannelPolicyInterface $policy;
3230

3331
/**
3432
* @param ChannelInterface[]|ContainerInterface $channels
3533
*/
36-
public function __construct(array|ContainerInterface $channels, ChannelPolicyInterface $policy = null)
37-
{
38-
$this->channels = $channels;
39-
$this->policy = $policy;
34+
public function __construct(
35+
private array|ContainerInterface $channels,
36+
private ?ChannelPolicyInterface $policy = null,
37+
) {
4038
}
4139

4240
public function send(Notification $notification, RecipientInterface ...$recipients): void

src/Symfony/Component/Notifier/Test/Constraint/NotificationCount.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@
1919
*/
2020
final class NotificationCount extends Constraint
2121
{
22-
private int $expectedValue;
23-
private ?string $transport;
24-
private bool $queued;
25-
26-
public function __construct(int $expectedValue, string $transport = null, bool $queued = false)
27-
{
28-
$this->expectedValue = $expectedValue;
29-
$this->transport = $transport;
30-
$this->queued = $queued;
22+
public function __construct(
23+
private int $expectedValue,
24+
private ?string $transport = null,
25+
private bool $queued = false,
26+
) {
3127
}
3228

3329
public function toString(): string

src/Symfony/Component/Notifier/Test/Constraint/NotificationSubjectContains.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
*/
2020
final class NotificationSubjectContains extends Constraint
2121
{
22-
private string $expectedText;
23-
24-
public function __construct(string $expectedText)
22+
public function __construct(private string $expectedText)
2523
{
26-
$this->expectedText = $expectedText;
2724
}
2825

2926
public function toString(): string

0 commit comments

Comments
 (0)