8000 Merge branch '7.0' into 7.1 · symfony/symfony@3f2ed0f · GitHub
[go: up one dir, main page]

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
8000
-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:<recipient2@example.org>\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('sender@example.com');
166+
$email->to('recipient@example.com');
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
@@ -94,7 +94,7 @@ public function testEmptyParamAnnotation()
9494
/**
9595
* @dataProvider typesWithNoPrefixesProvider
9696
*/
97-
public function testExtractTypesWithNoPrefixes($property, array $type = null)
97+
public function testExtractTypesWithNoPrefixes($property, ?array $type = null)
9898
{
9999
$noPrefixExtractor = new PhpDocExtractor(null, [], [], []);
100100

@@ -216,7 +216,7 @@ public static function provideCollectionTypes()
216216
/**
217217
* @dataProvider typesWithCustomPrefixesProvider
218218
*/
219-
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
219+
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
220220
{
221221
$customExtractor = new PhpDocExtractor(null, ['add', 'remove'], ['is', 'can']);
222222

@@ -415,7 +415,7 @@ public function testUnknownPseudoType()
415415
/**
416416
* @dataProvider constructorTypesProvider
417417
*/
418-
public function testExtractConstructorTypes($property, array $type = null)
418+
public function testExtractConstructorTypes($property, ?array $type = null)
419419
{
420420
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
421421
}

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

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

@@ -131,7 +131,7 @@ public static function typesProvider()
131131
/**
132132
* @dataProvider provideCollectionTypes
133133
*/
134-
public function testExtractCollection($property, array $type = null)
134+
public function testExtractCollection($property, ?array $type = null)
135135
{
136136
$this->testExtract($property, $type);
137137
}
@@ -187,7 +187,7 @@ public static function provideCollectionTypes()
187187
/**
188188
* @dataProvider typesWithCustomPrefixesProvider
189189
*/
190-
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
190+
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
191191
{
192192
$customExtractor = new PhpStanExtractor(['add', 'remove'], ['is', 'can']);
193193

@@ -345,7 +345,7 @@ public static function propertiesParentTypeProvider(): array
345345
/**
346346
* @dataProvider constructorTypesProvider
347347
*/
348-
public function testExtractConstructorTypes($property, array $type = null)
348+
public function testExtractConstructorTypes($property, ?array $type = null)
349349
{
350350
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
351351
}
@@ -460,7 +460,7 @@ public static function intRangeTypeProvider(): array
460460
/**
461461
* @dataProvider php80TypesProvider
462462
*/
463-
public function testExtractPhp80Type(string $class, $property, array $type = null)
463+
public function testExtractPhp80Type(string $class, $property, ?array $type = null)
464464
{
465465
$this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
466466
}

src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ExtendedRoute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
88
class ExtendedRoute extends Route
99
{
10-
public function __construct(array|string $path = null, ?string $name = null, array $defaults = [])
10+
public function __construct(array|string|null $path = null, ?string $name = null, array $defaults = [])
1111
{
1212
parent::__construct("/{section<(foo|bar|baz)>}" . $path, $name, [], [], array_merge(['section' => 'foo'], $defaults));
1313
}

src/Symfony/Component/Routing/Tests/Fixtures/TraceableAttributeClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class TraceableAttributeClassLoader extends AttributeClassLoader
2020
/** @var list<string> */
2121
public array $foundClasses = [];
2222

23-
public function load(mixed $class, string $type = null): RouteCollection
23+
public function load(mixed $class, ?string $type = null): RouteCollection
2424
{
2525
if (!is_string($class)) {
2626
throw new \InvalidArgumentException(sprintf('Expected string, got "%s"', get_debug_type($class)));

src/Symfony/Component/Serializer/Tests/Fixtures/FooInterfaceDummyDenormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
final class FooInterfaceDummyDenormalizer implements DenormalizerInterface
1717
{
18-
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): array
18+
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): array
1919
{
2020
$result = [];
2121
foreach ($data as $foo) {
@@ -27,7 +27,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
2727
return $result;
2828
}
2929

30-
public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
30+
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
3131
{
3232
if (str_ends_with($type, '[]')) {
3333
$className = substr($type, 0, -2);

src/Symfony/Component/Serializer/Tests/Fixtures/StaticConstructorNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ public function getSupportedTypes(?string $format): array
2323
return [StaticConstructorDummy::class];
2424
}
2525

26-
protected function extractAttributes(object $object, string $format = null, array $context = []): array
26+
protected function extractAttributes(object $object, ?string $format = null, array $context = []): array
2727
{
2828
return get_object_vars($object);
2929
}
3030

31-
protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed
31+
protected function getAttributeValue(object $object, string $attribute, ?string $format = null, array $context = []): mixed
3232
{
3333
return $object->$attribute;
3434
}
3535

36-
protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []): void
36+
protected function setAttributeValue(object $object, string $attribute, mixed $value, ?string $format = null, array $context = []): void
3737
{
3838
$object->$attribute = $value;
3939
}

src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithRequiredArgument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ConstraintWithRequiredArgument extends Constraint
2020
public string $requiredArg;
2121

2222
#[HasNamedArgumen 5677 ts]
23-
public function __construct(string $requiredArg, array $groups = null, mixed $payload = null)
23+
public function __construct(string $requiredArg, ?array $groups = null, mixed $payload = null)
2424
{
2525
parent::__construct([], $groups, $payload);
2626

0 commit comments

Comments
 (0)
0