Skip to content

Commit 3f2ed0f

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: Fix implicit nullable parameters stop marking parameters implicitly as nullable include message id provided by the MTA when dispatching the SentMessageEvent Remove whitespaces from block form_help Fix TypeError on ProgressBar
2 parents f340351 + 913f8d4 commit 3f2ed0f

File tree

17 files changed

+70
-37
lines changed

17 files changed

+70
-37
lines changed

src/Symfony/Bridge/PsrHttpMessage/Tests/Fixtures/ServerRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class ServerRequest extends Message implements ServerRequestInterface
2626
public function __construct(
2727
string $version = '1.1',
2828
array $headers = [],
29-
StreamInterface $body = null,
29+
?StreamInterface $body = null,
3030
private readonly string $requestTarget = '/',
3131
private readonly string $method = 'GET',
32-
UriInterface|string $uri = null,
32+
UriInterface|string|null $uri = null,
3333
private readonly array $server = [],
3434
private readonly array $cookies = [],
3535
private readonly array $query = [],

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_5_layout.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@
361361
{# Help #}
362362

363363
{%- block form_help -%}
364-
{% set row_class = row_attr.class|default('') %}
365-
{% set help_class = ' form-text' %}
366-
{% if 'input-group' in row_class %}
364+
{%- set row_class = row_attr.class|default('') -%}
365+
{%- set help_class = ' form-text' -%}
366+
{%- if 'input-group' in row_class -%}
367367
{#- Hack to properly display help with input group -#}
368-
{% set help_class = ' input-group-text' %}
369-
{% endif %}
368+
{%- set help_class = ' input-group-text' -%}
369+
{%- endif -%}
370370
{%- if help is not empty -%}
371371
{%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ help_class ~ ' mb-0')|trim}) -%}
372372
{%- endif -%}

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ public function setMessage(string $message, string $name = 'message'): void
183183
$this->messages[$name] = $message;
184184
}
185185

186-
public function getMessage(string $name = 'message'): string
186+
public function getMessage(string $name = 'message'): ?string
187187
{
188-
return $this->messages[$name];
188+
return $this->messages[$name] ?? null;
189189
}
190190

191191
public function getStartTime(): int

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Foo
1616
public static int $counter = 0;
1717

1818
#[Required]
19-
public function cloneFoo(\stdClass $bar = null): static
19+
public function cloneFoo(?\stdClass $bar = null): static
2020
{
2121
++self::$counter;
2222

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes_80.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function __construct(string $arg1, #[AutowireDecorated] AsDecoratorInterf
108108
#[AsDecorator(decorates: \NonExistent::class, onInvalid: ContainerInterface::NULL_ON_INVALID_REFERENCE)]
109109
class AsDecoratorBaz implements AsDecoratorInterface
110110
{
111-
public function __construct(#[AutowireDecorated] AsDecoratorInterface $inner = null)
111+
public function __construct(#[AutowireDecorated] ?AsDecoratorInterface $inner = null)
112112
{
113113
}
114114
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function callPassed()
8383

8484
class DummyProxyDumper implements DumperInterface
8585
{
86-
public function isProxyCandidate(Definition $definition, bool &$asGhostObject = null, string $id = null): bool
86+
public function isProxyCandidate(Definition $definition, ?bool &$asGhostObject = null, ?string $id = null): bool
8787
{
8888
$asGhostObject = false;
8989

src/Symfony/Component/Form/Tests/Fixtures/TranslatableTextAlign.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum TranslatableTextAlign implements TranslatableInterface
2020
case Center;
2121
case Right;
2222

23-
public function trans(TranslatorInterface $translator, string $locale = null): string
23+
public function trans(TranslatorInterface $translator, ?string $locale = null): string
2424
{
2525
return $translator->trans($this->name, locale: $locale);
2626
}

src/Symfony/Component/Mailer/Tests/Transport/Smtp/DummyStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function write(string $bytes, $debug = true): void
7777
} elseif (str_starts_with($bytes, 'QUIT')) {
7878
$this->nextResponse = '221 Goodbye';
7979
} else {
80-
$this->nextResponse = '250 OK';
80+
$this->nextResponse = '250 OK queued as 000501c4054c';
8181
}
8282
}
8383

src/Symfony/Component/Mailer/Tests/Transport/Smtp/SmtpTransportTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Envelope;
16+
use Symfony\Component\Mailer\Event\MessageEvent;
17+
use Symfony\Component\Mailer\Event\SentMessageEvent;
1618
use Symfony\Component\Mailer\Exception\LogicException;
1719
use Symfony\Component\Mailer\Exception\TransportException;
1820
use Symfony\Component\Mailer\Transport\Smtp\SmtpTransport;
@@ -24,6 +26,7 @@
2426
use Symfony\Component\Mime\Part\DataPart;
2527
use Symfony\Component\Mime\Part\File;
2628
use Symfony\Component\Mime\RawMessage;
29+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
2730

2831
/**
2932
* @group time-sensitive
@@ -137,6 +140,37 @@ public function testWriteEncodedRecipientAndSenderAddresses()
137140
$this->assertContains("RCPT TO:<[email protected]>\r\n", $stream->getCommands());
138141
}
139142

143+
public function testMessageIdFromServerIsEmbeddedInSentMessageEvent()
144+
{
145+
$calls = 0;
146+
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
147+
$eventDispatcher->expects($this->any())
148+
->method('dispatch')
149+
->with($this->callback(static function ($event) use (&$calls): bool {
150+
++$calls;
151+
152+
if (1 === $calls && $event instanceof MessageEvent) {
153+
return true;
154+
}
155+
156+
if (2 === $calls && $event instanceof SentMessageEvent && '000501c4054c' === $event->getMessage()->getMessageId()) {
157+
return true;
158+
}
159+
160+
return false;
161+
}));
162+
$transport = new SmtpTransport(new DummyStream(), $eventDispatcher);
163+
164+
$email = new Email();
165+
$email->from('[email protected]');
166+
$email->to('[email protected]');
167+
$email->text('.');
168+
169+
$transport->send($email);
170+
171+
$this->assertSame(2, $calls);
172+
}
173+
140174
public function testAssertResponseCodeNoCodes()
141175
{
142176
$this->expectException(LogicException::class);

src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class SmtpTransport extends AbstractTransport
3939
private int $pingThreshold = 100;
4040
private float $lastMessageTime = 0;
4141
private AbstractStream $stream;
42-
private string $mtaResult = '';
4342
private string $domain = '[127.0.0.1]';
4443

4544
public function __construct(?AbstractStream $stream = null, ?EventDispatcherInterface $dispatcher = null, ?LoggerInterface $logger = null)
@@ -148,10 +147,6 @@ public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMess
148147
throw $e;
149148
}
150149

151-
if ($this->mtaResult && $messageId = $this->parseMessageId($this->mtaResult)) {
152-
$message->setMessageId($messageId);
153-
}
154-
155150
$this->checkRestartThreshold();
156151

157152
return $message;
@@ -235,9 +230,13 @@ protected function doSend(SentMessage $message): void
235230
$this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
236231
throw $e;
237232
}
238-
$this->mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
233+
$mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
239234
$message->appendDebug($this->stream->getDebug());
240235
$this->lastMessageTime = microtime(true);
236+
237+
if ($mtaResult && $messageId = $this->parseMessageId($mtaResult)) {
238+
$message->setMessageId($messageId);
239+
}
241240
} catch (TransportExceptionInterface $e) {
242241
$e->appendDebug($this->stream->getDebug());
243242
$this->lastMessageTime = 0;

0 commit comments

Comments
 (0)