Skip to content

[CS] Fix explicit nullable types #19796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion create_framework/separation_of_concerns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ And move the ``is_leap_year()`` function to its own class too::

class LeapYear
{
public function isLeapYear(int $year = null): bool
public function isLeapYear(?int $year = null): bool
{
if (null === $year) {
$year = date('Y');
Expand Down
2 changes: 1 addition & 1 deletion create_framework/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ framework does not need to be modified in any way, create a new
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;

function is_leap_year(int $year = null): bool
function is_leap_year(?int $year = null): bool
{
if (null === $year) {
$year = (int)date('Y');
Expand Down
2 changes: 1 addition & 1 deletion reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i

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

Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ implement ``TranslatableInterface`` to translate or display custom labels::
case Center = 'Center aligned';
case Right = 'Right aligned';

public function trans(TranslatorInterface $translator, string $locale = null): string
public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
// Translate enum from name (Left, Center or Right)
return $translator->trans($this->name, locale: $locale);
Expand Down
4 changes: 2 additions & 2 deletions serializer/custom_context_builders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ value is ``0000-00-00``. To do that you'll first have to create your normalizer:
{
use DenormalizerAwareTrait;

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

public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
{
return true === ($context['zero_datetime_to_null'] ?? false)
&& is_a($type, \DateTimeInterface::class, true);
Expand Down
2 changes: 1 addition & 1 deletion validation/custom_constraint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ You can use ``#[HasNamedArguments]`` to make some constraint options required::
#[HasNamedArguments]
public function __construct(
public string $mode,
array $groups = null,
?array $groups = null,
mixed $payload = null,
) {
parent::__construct([], $groups, $payload);
Expand Down
Loading