Skip to content

Commit 8d91db9

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: minor [CS] Fix more nullable types [Testing] Update nullable types
2 parents a293225 + 3aa6914 commit 8d91db9

18 files changed

+40
-40
lines changed

components/expression_language.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ or by using the second argument of the constructor::
385385

386386
class ExpressionLanguage extends BaseExpressionLanguage
387387
{
388-
public function __construct(CacheItemPoolInterface $cache = null, array $providers = [])
388+
public function __construct(?CacheItemPoolInterface $cache = null, array $providers = [])
389389
{
390390
// prepends the default provider to let users override it
391391
array_unshift($providers, new StringExpressionLanguageProvider());

components/serializer.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ exists in your project::
118118
$this->sportsperson = $sportsperson;
119119
}
120120

121-
public function setCreatedAt(\DateTimeInterface $createdAt = null): void
121+
public function setCreatedAt(?\DateTimeInterface $createdAt = null): void
122122
{
123123
$this->createdAt = $createdAt;
124124
}
@@ -751,7 +751,7 @@ When serializing, you can set a callback to format a specific object property::
751751
$encoder = new JsonEncoder();
752752

753753
// all callback parameters are optional (you can omit the ones you don't use)
754-
$dateCallback = function (object $innerObject, object $outerObject, string $attributeName, string $format = null, array $context = []): string {
754+
$dateCallback = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): string {
755755
return $innerObject instanceof \DateTime ? $innerObject->format(\DateTime::ISO8601) : '';
756756
};
757757

@@ -1629,7 +1629,7 @@ having unique identifiers::
16291629
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
16301630

16311631
// all callback parameters are optional (you can omit the ones you don't use)
1632-
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, string $format = null, array $context = []): string {
1632+
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): string {
16331633
return '/foos/'.$innerObject->id;
16341634
};
16351635

controller/error_pages.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input::
216216

217217
class MyCustomProblemNormalizer implements NormalizerInterface
218218
{
219-
public function normalize($exception, string $format = null, array $context = []): array
219+
public function normalize($exception, ?string $format = null, array $context = []): array
220220
{
221221
return [
222222
'content' => 'This is my custom problem normalizer.',
@@ -227,7 +227,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input::
227227
];
228228
}
229229

230-
public function supportsNormalization($data, string $format = null, array $context = []): bool
230+
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
231231
{
232232
return $data instanceof FlattenException;
233233
}

form/dynamic_form_modification.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ The type would now look like::
455455
])
456456
;
457457

458-
$formModifier = function (FormInterface $form, Sport $sport = null): void {
458+
$formModifier = function (FormInterface $form, ?Sport $sport = null): void {
459459
$positions = null === $sport ? [] : $sport->getAvailablePositions();
460460

461461
$form->add('position', EntityType::class, [
@@ -487,7 +487,7 @@ The type would now look like::
487487
$formModifier($event->getForm()->getParent(), $sport);
488488
}
489489
);
490-
490+
491491
// by default, action does not appear in the <form> tag
492492
// you can set this value by passing the controller route
493493
$builder->setAction($options['action']);

http_client.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ If you want to extend the behavior of a base HTTP client, you can use
18041804
class MyExtendedHttpClient implements HttpClientInterface
18051805
{
18061806
public function __construct(
1807-
private HttpClientInterface $decoratedClient = null
1807+
private ?HttpClientInterface $decoratedClient = null
18081808
) {
18091809
$this->decoratedClient ??= HttpClient::create();
18101810
}
@@ -1820,7 +1820,7 @@ If you want to extend the behavior of a base HTTP client, you can use
18201820
return $response;
18211821
}
18221822

1823-
public function stream($responses, float $timeout = null): ResponseStreamInterface
1823+
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
18241824
{
18251825
return $this->decoratedClient->stream($responses, $timeout);
18261826
}

messenger.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ provided in order to ease the declaration of these special handlers::
26212621
{
26222622
use BatchHandlerTrait;
26232623

2624-
public function __invoke(MyMessage $message, Acknowledger $ack = null): mixed
2624+
public function __invoke(MyMessage $message, ?Acknowledger $ack = null): mixed
26252625
{
26262626
return $this->handle($message, $ack);
26272627
}

messenger/custom-transport.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Here is a simplified example of a database transport::
5151
*/
5252
public function __construct(
5353
private FakeDatabase $db,
54-
SerializerInterface $serializer = null,
54+
?SerializerInterface $serializer = null,
5555
) {
5656
$this->serializer = $serializer ?? new PhpSerializer();
5757
}

notifier.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ and its ``asChatMessage()`` method::
824824
) {
825825
}
826826

827-
public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage
827+
public function asChatMessage(RecipientInterface $recipient, ?string $transport = null): ?ChatMessage
828828
{
829829
// Add a custom subject and emoji if the message is sent to Slack
830830
if ('slack' === $transport) {

profiler.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ request::
289289

290290
class RequestCollector extends AbstractDataCollector
291291
{
292-
public function collect(Request $request, Response $response, \Throwable $exception = null): void
292+
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
293293
{
294294
$this->data = [
295295
'method' => $request->getMethod(),

reference/constraints/File.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type. The ``Author`` class might look as follows::
4040
{
4141
protected File $bioFile;
4242

43-
public function setBioFile(File $file = null): void
43+
public function setBioFile(?File $file = null): void
4444
{
4545
$this->bioFile = $file;
4646
}

reference/constraints/Image.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ would be a ``file`` type. The ``Author`` class might look as follows::
3535
{
3636
protected File $headshot;
3737

38-
public function setHeadshot(File $file = null): void
38+
public function setHeadshot(?File $file = null): void
3939
{
4040
$this->headshot = $file;
4141
}

reference/forms/types/collection.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ the value is removed from the collection. For example::
160160

161161
$builder->add('users', CollectionType::class, [
162162
// ...
163-
'delete_empty' => function (User $user = null): bool {
163+
'delete_empty' => function (?User $user = null): bool {
164164
return null === $user || empty($user->getFirstName());
165165
},
166166
]);

routing/custom_route_loader.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ you do. The resource name itself is not actually used in the example::
280280
{
281281
private bool $isLoaded = false;
282282

283-
public function load($resource, string $type = null): RouteCollection
283+
public function load($resource, ?string $type = null): RouteCollection
284284
{
285285
if (true === $this->isLoaded) {
286286
throw new \RuntimeException('Do not add the "extra" loader twice');
@@ -307,7 +307,7 @@ you do. The resource name itself is not actually used in the example::
307307
return $routes;
308308
}
309309

310-
public function supports($resource, string $type = null): bool
310+
public function supports($resource, ?string $type = null): bool
311311
{
312312
return 'extra' === $type;
313313
}
@@ -452,7 +452,7 @@ configuration file - you can call the
452452

453453
class AdvancedLoader extends Loader
454454
{
455-
public function load($resource, string $type = null): RouteCollection
455+
public function load($resource, ?string $type = null): RouteCollection
456456
{
457457
$routes = new RouteCollection();
458458

@@ -466,7 +466,7 @@ configuration file - you can call the
466466
return $routes;
467467
}
468468

469-
public function supports($resource, string $type = null): bool
469+
public function supports($resource, ?string $type = null): bool
470470
{
471471
return 'advanced_extra' === $type;
472472
}

security/access_denied_handler.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ unauthenticated user tries to access a protected resource::
3838
) {
3939
}
4040

41-
public function start(Request $request, AuthenticationException $authException = null): RedirectResponse
41+
public function start(Request $request, ?AuthenticationException $authException = null): RedirectResponse
4242
{
4343
// add a custom flash message and redirect to the login page
4444
$request->getSession()->getFlashBag()->add('note', 'You have to login in order to access this page.');

security/login_link.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ This will send an email like this to the user:
283283

284284
class CustomLoginLinkNotification extends LoginLinkNotification
285285
{
286-
public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage
286+
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): ?EmailMessage
287287
{
288288
$emailMessage = parent::asEmailMessage($recipient, $transport);
289289

serializer/custom_normalizer.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
3232
) {
3333
}
3434

35-
public function normalize($topic, string $format = null, array $context = []): array
35+
public function normalize($topic, ?string $format = null, array $context = []): array
3636
{
3737
$data = $this->normalizer->normalize($topic, $format, $context);
3838

@@ -44,7 +44,7 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
4444
return $data;
4545
}
4646

47-
public function supportsNormalization($data, string $format = null, array $context = []): bool
47+
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
4848
{
4949
return $data instanceof Topic;
5050
}

testing.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,13 @@ returns a ``Crawler`` instance.
560560

561561
The full signature of the ``request()`` method is::
562562

563-
request(
563+
public function request(
564564
string $method,
565565
string $uri,
566566
array $parameters = [],
567567
array $files = [],
568568
array $server = [],
569-
string $content = null,
569+
?string $content = null,
570570
bool $changeHistory = true
571571
): Crawler
572572

@@ -971,7 +971,7 @@ Response Assertions
971971
Asserts that the response was successful (HTTP status is 2xx).
972972
``assertResponseStatusCodeSame(int $expectedCode, string $message = '')``
973973
Asserts a specific HTTP status code.
974-
``assertResponseRedirects(string $expectedLocation = null, int $expectedCode = null, string $message = '')``
974+
``assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = '')``
975975
Asserts the response is a redirect response (optionally, you can check
976976
the target location and status code). The excepted location can be either
977977
an absolute or a relative path.
@@ -980,10 +980,10 @@ Response Assertions
980980
``assertResponseHeaderSame(string $headerName, string $expectedValue, string $message = '')``/``assertResponseHeaderNotSame(string $headerName, string $expectedValue, string $message = '')``
981981
Asserts the given header does (not) contain the expected value on the
982982
response, e.g. ``assertResponseHeaderSame('content-type', 'application/octet-stream');``.
983-
``assertResponseHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``/``assertResponseNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``
983+
``assertResponseHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``/``assertResponseNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``
984984
Asserts the given cookie is present in the response (optionally
985985
checking for a specific cookie path or domain).
986-
``assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = '')``
986+
``assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = '')``
987987
Asserts the given cookie is present and set to the expected value.
988988
``assertResponseFormatSame(?string $expectedFormat, string $message = '')``
989989
Asserts the response format returned by the
@@ -1009,10 +1009,10 @@ Request Assertions
10091009
Browser Assertions
10101010
..................
10111011

1012-
``assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``/``assertBrowserNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``
1012+
``assertBrowserHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``/``assertBrowserNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``
10131013
Asserts that the test Client does (not) have the given cookie set
10141014
(meaning, the cookie was set by any response in the test).
1015-
``assertBrowserCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = '')``
1015+
``assertBrowserCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = '')``
10161016
Asserts the given cookie in the test Client is set to the expected
10171017
value.
10181018
``assertThatForClient(Constraint $constraint, string $message = '')``
@@ -1072,18 +1072,18 @@ Crawler Assertions
10721072
Mailer Assertions
10731073
.................
10741074

1075-
``assertEmailCount(int $count, string $transport = null, string $message = '')``
1075+
``assertEmailCount(int $count, ?string $transport = null, string $message = '')``
10761076
Asserts that the expected number of emails was sent.
1077-
``assertQueuedEmailCount(int $count, string $transport = null, string $message = '')``
1077+
``assertQueuedEmailCount(int $count, ?string $transport = null, string $message = '')``
10781078
Asserts that the expected number of emails was queued (e.g. using the
10791079
Messenger component).
10801080
``assertEmailIsQueued(MessageEvent $event, string $message = '')``/``assertEmailIsNotQueued(MessageEvent $event, string $message = '')``
10811081
Asserts that the given mailer event is (not) queued. Use
1082-
``getMailerEvent(int $index = 0, string $transport = null)`` to
1082+
``getMailerEvent(int $index = 0, ?string $transport = null)`` to
10831083
retrieve a mailer event by index.
10841084
``assertEmailAttachmentCount(RawMessage $email, int $count, string $message = '')``
10851085
Asserts that the given email has the expected number of attachments. Use
1086-
``getMailerMessage(int $index = 0, string $transport = null)`` to
1086+
``getMailerMessage(int $index = 0, ?string $transport = null)`` to
10871087
retrieve a specific email by index.
10881088
``assertEmailTextBodyContains(RawMessage $email, string $text, string $message = '')``/``assertEmailTextBodyNotContains(RawMessage $email, string $text, string $message = '')``
10891089
Asserts that the text body of the given email does (not) contain the

validation/custom_constraint.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ First you need to create a Constraint class and extend :class:`Symfony\\Componen
2727
public string $mode = 'strict';
2828
2929
// all configurable options must be passed to the constructor
30-
public function __construct(string $mode = null, string $message = null, array $groups = null, $payload = null)
30+
public function __construct(?string $mode = null, ?string $message = null, ?array $groups = null, $payload = null)
3131
{
3232
parent::__construct([], $groups, $payload);
3333
@@ -247,9 +247,9 @@ define those options as public properties on the constraint class::
247247

248248
public function __construct(
249249
$mandatoryFooOption,
250-
string $message = null,
251-
bool $optionalBarOption = null,
252-
array $groups = null,
250+
?string $message = null,
251+
?bool $optionalBarOption = null,
252+
?array $groups = null,
253253
$payload = null,
254254
array $options = []
255255
) {

0 commit comments

Comments
 (0)