Skip to content

Commit

Permalink
minor #54308 Add more explicit nullable types for default null values…
Browse files Browse the repository at this point in the history
… (alexandre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

Add more explicit nullable types for default null values

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

Continuing to bring deprecation-free support for PHP 8.4 (https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated)

If this gets merged, I'll take care of adding missing ones in upper branches if not done during upmerge 🙂

Commits
-------

e9d30bac03 Add more explicit nullable types for default null values
  • Loading branch information
nicolas-grekas committed Mar 19, 2024
2 parents 42b27ad + da00018 commit a4841ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Tests/Fixtures/ChoiceList/DeprecatedChoiceListFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

class DeprecatedChoiceListFactory implements ChoiceListFactoryInterface
{
public function createListFromChoices(iterable $choices, callable $value = null): ChoiceListInterface
public function createListFromChoices(iterable $choices, ?callable $value = null): ChoiceListInterface
{
}

public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null): ChoiceListInterface
public function createListFromLoader(ChoiceLoaderInterface $loader, ?callable $value = null): ChoiceListInterface
{
}

public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, callable $index = null, callable $groupBy = null, $attr = null): ChoiceListView
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, ?callable $index = null, ?callable $groupBy = null, $attr = null): ChoiceListView
{
}
}
2 changes: 1 addition & 1 deletion Tests/Fixtures/CustomArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
{
private $array;

public function __construct(array $array = null)
public function __construct(?array $array = null)
{
$this->array = $array ?: [];
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/FixedTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(array $translations)
$this->translations = $translations;
}

public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
return $this->translations[$id] ?? $id;
}
Expand Down

0 comments on commit a4841ab

Please sign in to comment.