Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  minor
  [CS] Fix more nullable types
  [Testing] Update nullable types
  • Loading branch information
OskarStark committed Apr 15, 2024
2 parents a293225 + 3aa6914 commit 8d91db9
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion components/expression_language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ or by using the second argument of the constructor::

class ExpressionLanguage extends BaseExpressionLanguage
{
public function __construct(CacheItemPoolInterface $cache = null, array $providers = [])
public function __construct(?CacheItemPoolInterface $cache = null, array $providers = [])
{
// prepends the default provider to let users override it
array_unshift($providers, new StringExpressionLanguageProvider());
Expand Down
6 changes: 3 additions & 3 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ exists in your project::
$this->sportsperson = $sportsperson;
}

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

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

Expand Down Expand Up @@ -1629,7 +1629,7 @@ having unique identifiers::
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());

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

Expand Down
4 changes: 2 additions & 2 deletions controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input::

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

public function supportsNormalization($data, string $format = null, array $context = []): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof FlattenException;
}
Expand Down
4 changes: 2 additions & 2 deletions form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ The type would now look like::
])
;

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

$form->add('position', EntityType::class, [
Expand Down Expand Up @@ -487,7 +487,7 @@ The type would now look like::
$formModifier($event->getForm()->getParent(), $sport);
}
);

// by default, action does not appear in the <form> tag
// you can set this value by passing the controller route
$builder->setAction($options['action']);
Expand Down
4 changes: 2 additions & 2 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ If you want to extend the behavior of a base HTTP client, you can use
class MyExtendedHttpClient implements HttpClientInterface
{
public function __construct(
private HttpClientInterface $decoratedClient = null
private ?HttpClientInterface $decoratedClient = null
) {
$this->decoratedClient ??= HttpClient::create();
}
Expand All @@ -1820,7 +1820,7 @@ If you want to extend the behavior of a base HTTP client, you can use
return $response;
}

public function stream($responses, float $timeout = null): ResponseStreamInterface
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
{
return $this->decoratedClient->stream($responses, $timeout);
}
Expand Down
2 changes: 1 addition & 1 deletion messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2621,7 +2621,7 @@ provided in order to ease the declaration of these special handlers::
{
use BatchHandlerTrait;

public function __invoke(MyMessage $message, Acknowledger $ack = null): mixed
public function __invoke(MyMessage $message, ?Acknowledger $ack = null): mixed
{
return $this->handle($message, $ack);
}
Expand Down
2 changes: 1 addition & 1 deletion messenger/custom-transport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Here is a simplified example of a database transport::
*/
public function __construct(
private FakeDatabase $db,
SerializerInterface $serializer = null,
?SerializerInterface $serializer = null,
) {
$this->serializer = $serializer ?? new PhpSerializer();
}
Expand Down
2 changes: 1 addition & 1 deletion notifier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ and its ``asChatMessage()`` method::
) {
}

public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage
public function asChatMessage(RecipientInterface $recipient, ?string $transport = null): ?ChatMessage
{
// Add a custom subject and emoji if the message is sent to Slack
if ('slack' === $transport) {
Expand Down
2 changes: 1 addition & 1 deletion profiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ request::

class RequestCollector extends AbstractDataCollector
{
public function collect(Request $request, Response $response, \Throwable $exception = null): void
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
$this->data = [
'method' => $request->getMethod(),
Expand Down
2 changes: 1 addition & 1 deletion reference/constraints/File.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type. The ``Author`` class might look as follows::
{
protected File $bioFile;

public function setBioFile(File $file = null): void
public function setBioFile(?File $file = null): void
{
$this->bioFile = $file;
}
Expand Down
2 changes: 1 addition & 1 deletion reference/constraints/Image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ would be a ``file`` type. The ``Author`` class might look as follows::
{
protected File $headshot;

public function setHeadshot(File $file = null): void
public function setHeadshot(?File $file = null): void
{
$this->headshot = $file;
}
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ the value is removed from the collection. For example::

$builder->add('users', CollectionType::class, [
// ...
'delete_empty' => function (User $user = null): bool {
'delete_empty' => function (?User $user = null): bool {
return null === $user || empty($user->getFirstName());
},
]);
Expand Down
8 changes: 4 additions & 4 deletions routing/custom_route_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ you do. The resource name itself is not actually used in the example::
{
private bool $isLoaded = false;

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

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

class AdvancedLoader extends Loader
{
public function load($resource, string $type = null): RouteCollection
public function load($resource, ?string $type = null): RouteCollection
{
$routes = new RouteCollection();

Expand All @@ -466,7 +466,7 @@ configuration file - you can call the
return $routes;
}

public function supports($resource, string $type = null): bool
public function supports($resource, ?string $type = null): bool
{
return 'advanced_extra' === $type;
}
Expand Down
2 changes: 1 addition & 1 deletion security/access_denied_handler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ unauthenticated user tries to access a protected resource::
) {
}

public function start(Request $request, AuthenticationException $authException = null): RedirectResponse
public function start(Request $request, ?AuthenticationException $authException = null): RedirectResponse
{
// add a custom flash message and redirect to the login page
$request->getSession()->getFlashBag()->add('note', 'You have to login in order to access this page.');
Expand Down
2 changes: 1 addition & 1 deletion security/login_link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ This will send an email like this to the user:

class CustomLoginLinkNotification extends LoginLinkNotification
{
public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): ?EmailMessage
{
$emailMessage = parent::asEmailMessage($recipient, $transport);

Expand Down
4 changes: 2 additions & 2 deletions serializer/custom_normalizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
) {
}

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

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

public function supportsNormalization($data, string $format = null, array $context = []): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof Topic;
}
Expand Down
22 changes: 11 additions & 11 deletions testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,13 @@ returns a ``Crawler`` instance.

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

request(
public function request(
string $method,
string $uri,
array $parameters = [],
array $files = [],
array $server = [],
string $content = null,
?string $content = null,
bool $changeHistory = true
): Crawler

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

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

``assertEmailCount(int $count, string $transport = null, string $message = '')``
``assertEmailCount(int $count, ?string $transport = null, string $message = '')``
Asserts that the expected number of emails was sent.
``assertQueuedEmailCount(int $count, string $transport = null, string $message = '')``
``assertQueuedEmailCount(int $count, ?string $transport = null, string $message = '')``
Asserts that the expected number of emails was queued (e.g. using the
Messenger component).
``assertEmailIsQueued(MessageEvent $event, string $message = '')``/``assertEmailIsNotQueued(MessageEvent $event, string $message = '')``
Asserts that the given mailer event is (not) queued. Use
``getMailerEvent(int $index = 0, string $transport = null)`` to
``getMailerEvent(int $index = 0, ?string $transport = null)`` to
retrieve a mailer event by index.
``assertEmailAttachmentCount(RawMessage $email, int $count, string $message = '')``
Asserts that the given email has the expected number of attachments. Use
``getMailerMessage(int $index = 0, string $transport = null)`` to
``getMailerMessage(int $index = 0, ?string $transport = null)`` to
retrieve a specific email by index.
``assertEmailTextBodyContains(RawMessage $email, string $text, string $message = '')``/``assertEmailTextBodyNotContains(RawMessage $email, string $text, string $message = '')``
Asserts that the text body of the given email does (not) contain the
Expand Down
8 changes: 4 additions & 4 deletions validation/custom_constraint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ First you need to create a Constraint class and extend :class:`Symfony\\Componen
public string $mode = 'strict';
// all configurable options must be passed to the constructor
public function __construct(string $mode = null, string $message = null, array $groups = null, $payload = null)
public function __construct(?string $mode = null, ?string $message = null, ?array $groups = null, $payload = null)
{
parent::__construct([], $groups, $payload);
Expand Down Expand Up @@ -247,9 +247,9 @@ define those options as public properties on the constraint class::

public function __construct(
$mandatoryFooOption,
string $message = null,
bool $optionalBarOption = null,
array $groups = null,
?string $message = null,
?bool $optionalBarOption = null,
?array $groups = null,
$payload = null,
array $options = []
) {
Expand Down

0 comments on commit 8d91db9

Please sign in to comment.