Skip to content

Commit 1f2c6e4

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: stop marking parameters implicitly as nullable include message id provided by the MTA when dispatching the SentMessageEvent
2 parents 07d63d3 + 020ef60 commit 1f2c6e4

File tree

14 files changed

+62
-29
lines changed

14 files changed

+62
-29
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/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
@@ -107,7 +107,7 @@ public function __construct(string $arg1, #[AutowireDecorated] AsDecoratorInterf
107107
#[AsDecorator(decorates: \NonExistent::class, onInvalid: ContainerInterface::NULL_ON_INVALID_REFERENCE)]
108108
class AsDecoratorBaz implements AsDecoratorInterface
109109
{
110-
public function __construct(#[AutowireDecorated] AsDecoratorInterface $inner = null)
110+
public function __construct(#[AutowireDecorated] ?AsDecoratorInterface $inner = null)
111111
{
112112
}
113113
}

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;

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testEmptyParamAnnotation()
8080
/**
8181
* @dataProvider typesWithNoPrefixesProvider
8282
*/
83-
public function testExtractTypesWithNoPrefixes($property, array $type = null)
83+
public function testExtractTypesWithNoPrefixes($property, ?array $type = null)
8484
{
8585
$noPrefixExtractor = new PhpDocExtractor(null, [], [], []);
8686

@@ -202,7 +202,7 @@ public static function provideCollectionTypes()
202202
/**
203203
* @dataProvider typesWithCustomPrefixesProvider
204204
*/
205-
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
205+
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
206206
{
207207
$customExtractor = new PhpDocExtractor(null, ['add', 'remove'], ['is', 'can']);
208208

@@ -401,7 +401,7 @@ public function testUnknownPseudoType()
401401
/**
402402
* @dataProvider constructorTypesProvider
403403
*/
404-
public function testExtractConstructorTypes($property, array $type = null)
404+
public function testExtractConstructorTypes($property, ?array $type = null)
405405
{
406406
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
407407
}

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
/**
4545
* @dataProvider typesProvider
4646
*/
47-
public function testExtract($property, array $type = null)
47+
public function testExtract($property, ?array $type = null)
4848
{
4949
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
5050
}
@@ -75,7 +75,7 @@ public function testInvalid($property)
7575
/**
7676
* @dataProvider typesWithNoPrefixesProvider
7777
*/
78-
public function testExtractTypesWithNoPrefixes($property, array $type = null)
78+
public function testExtractTypesWithNoPrefixes($property, ?array $type = null)
7979
{
8080
$noPrefixExtractor = new PhpStanExtractor([], [], []);
8181

@@ -130,7 +130,7 @@ public static function typesProvider()
130130
/**
131131
* @dataProvider provideCollectionTypes
132132
*/
133-
public function testExtractCollection($property, array $type = null)
133+
public function testExtractCollection($property, ?array $type = null)
134134
{
135135
$this->testExtract($property, $type);
136136
}
@@ -186,7 +186,7 @@ public static function provideCollectionTypes()
186186
/**
187187
* @dataProvider typesWithCustomPrefixesProvider
188188
*/
189-
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
189+
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
190190
{
191191
$customExtractor = new PhpStanExtractor(['add', 'remove'], ['is', 'can']);
192192

@@ -344,7 +344,7 @@ public static function propertiesParentTypeProvider(): array
344344
/**
345345
* @dataProvider constructorTypesProvider
346346
*/
347-
public function testExtractConstructorTypes($property, array $type = null)
347+
public function testExtractConstructorTypes($property, ?array $type = null)
348348
{
349349
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
350350
}
@@ -459,7 +459,7 @@ public static function intRangeTypeProvider(): array
459459
/**
460460
* @dataProvider php80TypesProvider
461461
*/
462-
public function testExtractPhp80Type(string $class, $property, array $type = null)
462+
public function testExtractPhp80Type(string $class, $property, ?array $type = null)
463463
{
464464
$this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
465465
}

0 commit comments

Comments
 (0)