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

Skip to content

[Notifier] Use CPP #53234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2024
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
12 changes: 4 additions & 8 deletions src/Symfony/Component/Notifier/Channel/BrowserChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@
*/
final class BrowserChannel implements ChannelInterface
{
private RequestStack $stack;

private FlashMessageImportanceMapperInterface $mapper;

public function __construct(RequestStack $stack, FlashMessageImportanceMapperInterface $mapper = new DefaultFlashMessageImportanceMapper())
{
$this->stack = $stack;
$this->mapper = $mapper;
public function __construct(
private RequestStack $stack,
private FlashMessageImportanceMapperInterface $mapper = new DefaultFlashMessageImportanceMapper(),
) {
}

public function notify(Notification $notification, RecipientInterface $recipient, string $transportName = null): void
Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/Notifier/Channel/ChannelPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
*/
final class ChannelPolicy implements ChannelPolicyInterface
{
private array $policy;

public function __construct(array $policy)
{
$this->policy = $policy;
public function __construct(
private array $policy,
) {
}

public function getChannels(string $importance): array
Expand Down
14 changes: 6 additions & 8 deletions src/Symfony/Component/Notifier/Channel/EmailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@
*/
class EmailChannel implements ChannelInterface
{
private ?TransportInterface $transport;
private ?MessageBusInterface $bus;
private string|Address|null $from;
private ?Envelope $envelope;

public function __construct(TransportInterface $transport = null, MessageBusInterface $bus = null, string $from = null, Envelope $envelope = null)
{
public function __construct(
private ?TransportInterface $transport = null,
private ?MessageBusInterface $bus = null,
string $from = null,
private ?Envelope $envelope = null,
) {
if (null === $transport && null === $bus) {
throw new LogicException(sprintf('"%s" needs a Transport or a Bus but both cannot be "null".', static::class));
}

$this->transport = $transport;
$this->bus = $bus;
$this->from = $from ?: $envelope?->getSender();
$this->envelope = $envelope;
}

/**
Expand Down
14 changes: 5 additions & 9 deletions src/Symfony/Component/Notifier/Chatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@
*/
final class Chatter implements ChatterInterface
{
private TransportInterface $transport;
private ?MessageBusInterface $bus;
private ?EventDispatcherInterface $dispatcher;

public function __construct(TransportInterface $transport, MessageBusInterface $bus = null, EventDispatcherInterface $dispatcher = null)
{
$this->transport = $transport;
$this->bus = $bus;
$this->dispatcher = $dispatcher;
public function __construct(
private TransportInterface $transport,
private ?MessageBusInterface $bus = null,
private ?EventDispatcherInterface $dispatcher = null,
) {
}

public function __toString(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
*/
final class NotificationDataCollector extends DataCollector
{
private NotificationLoggerListener $logger;

public function __construct(NotificationLoggerListener $logger)
{
$this->logger = $logger;
public function __construct(
private NotificationLoggerListener $logger,
) {
}

public function collect(Request $request, Response $response, \Throwable $exception = null): void
Expand Down
11 changes: 4 additions & 7 deletions src/Symfony/Component/Notifier/Event/FailedMessageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
*/
final class FailedMessageEvent extends Event
{
private MessageInterface $message;
private \Throwable $error;

public function __construct(MessageInterface $message, \Throwable $error)
{
$this->message = $message;
$this->error = $error;
public function __construct(
private MessageInterface $message,
private \Throwable $error,
) {
}

public function getMessage(): MessageInterface
Expand Down
11 changes: 4 additions & 7 deletions src/Symfony/Component/Notifier/Event/MessageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
*/
final class MessageEvent extends Event
{
private MessageInterface $message;
private bool $queued;

public function __construct(MessageInterface $message, bool $queued = false)
{
$this->message = $message;
$this->queued = $queued;
public function __construct(
private MessageInterface $message,
private bool $queued = false,
) {
}

public function getMessage(): MessageInterface
Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/Notifier/Event/SentMessageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
final class SentMessageEvent extends Event
{
private SentMessage $message;

public function __construct(SentMessage $message)
{
$this->message = $message;
public function __construct(
private SentMessage $message,
) {
}

public function getMessage(): SentMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
*/
class SendFailedMessageToNotifierListener implements EventSubscriberInterface
{
private Notifier $notifier;

public function __construct(Notifier $notifier)
{
$this->notifier = $notifier;
public function __construct(
private Notifier $notifier,
) {
}

public function onMessageFailed(WorkerMessageFailedEvent $event): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
class IncompleteDsnException extends InvalidArgumentException
{
private ?string $dsn;

public function __construct(string $message, string $dsn = null, \Throwable $previous = null)
{
$this->dsn = $dsn;
public function __construct(
string $message,
private ?string $dsn = null,
\Throwable $previous = null,
) {
if ($dsn) {
$message = sprintf('Invalid "%s" notifier DSN: %s', $dsn, $message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/
class TransportException extends RuntimeException implements TransportExceptionInterface
{
private ResponseInterface $response;
private string $debug = '';

public function __construct(string $message, ResponseInterface $response, int $code = 0, \Throwable $previous = null)
{
$this->response = $response;
public function __construct(
string $message,
private ResponseInterface $response,
int $code = 0,
\Throwable $previous = null,
) {
$this->debug .= $response->getInfo('debug') ?? '';

parent::__construct($message, $code, $previous);
Expand Down
10 changes: 4 additions & 6 deletions src/Symfony/Component/Notifier/Message/ChatMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
class ChatMessage implements MessageInterface, FromNotificationInterface
{
private ?string $transport = null;
private string $subject;
private ?MessageOptionsInterface $options;
private ?Notification $notification = null;

public function __construct(string $subject, MessageOptionsInterface $options = null)
{
$this->subject = $subject;
$this->options = $options;
public function __construct(
private string $subject,
private ?MessageOptionsInterface $options = null,
) {
}

public static function fromNotification(Notification $notification): self
Expand Down
10 changes: 4 additions & 6 deletions src/Symfony/Component/Notifier/Message/EmailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
*/
class EmailMessage implements MessageInterface, FromNotificationInterface
{
private RawMessage $message;
private ?Envelope $envelope;
private ?Notification $notification = null;

public function __construct(RawMessage $message, Envelope $envelope = null)
{
$this->message = $message;
$this->envelope = $envelope;
public function __construct(
private RawMessage $message,
private ?Envelope $envelope = null,
) {
}

public static function fromNotification(Notification $notification, EmailRecipientInterface $recipient): self
Expand Down
13 changes: 5 additions & 8 deletions src/Symfony/Component/Notifier/Message/PushMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
class PushMessage implements MessageInterface, FromNotificationInterface
{
private ?string $transport = null;
private string $subject;
private string $content;
private ?MessageOptionsInterface $options;
private ?Notification $notification = null;

public function __construct(string $subject, string $content, MessageOptionsInterface $options = null)
{
$this->subject = $subject;
$this->content = $content;
$this->options = $options;
public function __construct(
private string $subject,
private string $content,
private ?MessageOptionsInterface $options = null,
) {
}

public static function fromNotification(Notification $notification): self
Expand Down
10 changes: 4 additions & 6 deletions src/Symfony/Component/Notifier/Message/SentMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
*/
class SentMessage
{
private MessageInterface $original;
private string $transport;
private ?string $messageId = null;

public function __construct(MessageInterface $original, string $transport)
{
$this->original = $original;
$this->transport = $transport;
public function __construct(
private MessageInterface $original,
private string $transport,
) {
}

public function getOriginalMessage(): MessageInterface
Expand Down
17 changes: 6 additions & 11 deletions src/Symfony/Component/Notifier/Message/SmsMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,17 @@
class SmsMessage implements MessageInterface, FromNotificationInterface
{
private ?string $transport = null;
private string $subject;
private string $phone;
private string $from;
private ?MessageOptionsInterface $options;
private ?Notification $notification = null;

public function __construct(string $phone, string $subject, string $from = '', MessageOptionsInterface $options = null)
{
public function __construct(
private string $phone,
private string $subject,
private string $from = '',
private ?MessageOptionsInterface $options = null,
) {
if ('' === $phone) {
throw new InvalidArgumentException(sprintf('"%s" needs a phone number, it cannot be empty.', __CLASS__));
}

$this->subject = $subject;
$this->phone = $phone;
$this->from = $from;
$this->options = $options;
}

public static function fromNotification(Notification $notification, SmsRecipientInterface $recipient): self
Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/Notifier/Messenger/MessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
*/
final class MessageHandler
{
private TransportInterface $transport;

public function __construct(TransportInterface $transport)
{
$this->transport = $transport;
public function __construct(
private TransportInterface $transport,
) {
}

public function __invoke(MessageInterface $message): ?SentMessage
Expand Down
10 changes: 4 additions & 6 deletions src/Symfony/Component/Notifier/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@
final class Notifier implements NotifierInterface
{
private array $adminRecipients = [];
private array|ContainerInterface $channels;
private ?ChannelPolicyInterface $policy;

/**
* @param ChannelInterface[]|ContainerInterface $channels
*/
public function __construct(array|ContainerInterface $channels, ChannelPolicyInterface $policy = null)
{
$this->channels = $channels;
$this->policy = $policy;
public function __construct(
private array|ContainerInterface $channels,
private ?ChannelPolicyInterface $policy = null,
) {
}

public function send(Notification $notification, RecipientInterface ...$recipients): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
*/
final class NotificationCount extends Constraint
{
private int $expectedValue;
private ?string $transport;
private bool $queued;

public function __construct(int $expectedValue, string $transport = null, bool $queued = false)
{
$this->expectedValue = $expectedValue;
$this->transport = $transport;
$this->queued = $queued;
public function __construct(
private int $expectedValue,
private ?string $transport = null,
private bool $queued = false,
) {
}

public function toString(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
final class NotificationSubjectContains extends Constraint
{
private string $expectedText;

public function __construct(string $expectedText)
{
$this->expectedText = $expectedText;
public function __construct(
private string $expectedText,
) {
}

public function toString(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
final class NotificationTransportIsEqual extends Constraint
{
private ?string $expectedText;

public function __construct(?string $expectedText)
{
$this->expectedText = $expectedText;
public function __construct(
private ?string $expectedText,
) {
}

public function toString(): string
Expand Down
Loading