Skip to content

Commit 31a435d

Browse files
committed
minor #19796 [CS] Fix explicit nullable types (smnandre)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [CS] Fix explicit nullable types Fix explicit nullable types (6.4) Commits ------- 4981d13 [CS] Fix explicit nullable types
2 parents 26f992d + 4981d13 commit 31a435d

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

create_framework/separation_of_concerns.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ And move the ``is_leap_year()`` function to its own class too::
120120

121121
class LeapYear
122122
{
123-
public function isLeapYear(int $year = null): bool
123+
public function isLeapYear(?int $year = null): bool
124124
{
125125
if (null === $year) {
126126
$year = date('Y');

create_framework/templating.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ framework does not need to be modified in any way, create a new
146146
use Symfony\Component\HttpFoundation\Response;
147147
use Symfony\Component\Routing;
148148

149-
function is_leap_year(int $year = null): bool
149+
function is_leap_year(?int $year = null): bool
150150
{
151151
if (null === $year) {
152152
$year = (int)date('Y');

reference/dic_tags.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
490490

491491
class MyCustomWarmer implements CacheWarmerInterface
492492
{
493-
public function warmUp(string $cacheDir, string $buildDir = null): array
493+
public function warmUp(string $cacheDir, ?string $buildDir = null): array
494494
{
495495
// ... do some sort of operations to "warm" your cache
496496

reference/forms/types/enum.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ implement ``TranslatableInterface`` to translate or display custom labels::
6666
case Center = 'Center aligned';
6767
case Right = 'Right aligned';
6868

69-
public function trans(TranslatorInterface $translator, string $locale = null): string
69+
public function trans(TranslatorInterface $translator, ?string $locale = null): string
7070
{
7171
// Translate enum from name (Left, Center or Right)
7272
return $translator->trans($this->name, locale: $locale);

serializer/custom_context_builders.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ value is ``0000-00-00``. To do that you'll first have to create your normalizer:
3333
{
3434
use DenormalizerAwareTrait;
3535

36-
public function denormalize($data, string $type, string $format = null, array $context = []): mixed
36+
public function denormalize($data, string $type, ?string $format = null, array $context = []): mixed
3737
{
3838
if ('0000-00-00' === $data) {
3939
return null;
@@ -44,7 +44,7 @@ value is ``0000-00-00``. To do that you'll first have to create your normalizer:
4444
return $this->denormalizer->denormalize($data, $type, $format, $context);
4545
}
4646

47-
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
47+
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
4848
{
4949
return true === ($context['zero_datetime_to_null'] ?? false)
5050
&& is_a($type, \DateTimeInterface::class, true);

validation/custom_constraint.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ You can use ``#[HasNamedArguments]`` to make some constraint options required::
5959
#[HasNamedArguments]
6060
public function __construct(
6161
public string $mode,
62-
array $groups = null,
62+
?array $groups = null,
6363
mixed $payload = null,
6464
) {
6565
parent::__construct([], $groups, $payload);

0 commit comments

Comments
 (0)