Skip to content

Commit 6372130

Browse files
Switch implicit nullable types to explicit (#221)
Fixes deprecation warnings on PHP 8.4
1 parent f67131b commit 6372130

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

src/AddressFormat/AddressFormatHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class AddressFormatHelper
2626
* ]
2727
* @throws \ReflectionException
2828
*/
29-
public static function getGroupedFields(string $formatString, FieldOverrides $fieldOverrides = null): array
29+
public static function getGroupedFields(string $formatString, ?FieldOverrides $fieldOverrides = null): array
3030
{
3131
$groupedFields = [];
3232
$hiddenFields = $fieldOverrides ? $fieldOverrides->getHiddenFields() : [];

src/Country/CountryRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class CountryRepository implements CountryRepositoryInterface
7979
* @param string|null $definitionPath The path to the country definitions.
8080
* Defaults to 'resources/country'.
8181
*/
82-
public function __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', string $definitionPath = null)
82+
public function __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', ?string $definitionPath = null)
8383
{
8484
$this->defaultLocale = $defaultLocale;
8585
$this->fallbackLocale = $fallbackLocale;
@@ -89,7 +89,7 @@ public function __construct(string $defaultLocale = 'en', string $fallbackLocale
8989
/**
9090
* {@inheritdoc}
9191
*/
92-
public function get(string $countryCode, string $locale = null): Country
92+
public function get(string $countryCode, ?string $locale = null): Country
9393
{
9494
$countryCode = strtoupper($countryCode);
9595
$baseDefinitions = $this->getBaseDefinitions();
@@ -112,7 +112,7 @@ public function get(string $countryCode, string $locale = null): Country
112112
/**
113113
* {@inheritdoc}
114114
*/
115-
public function getAll(string $locale = null): array
115+
public function getAll(?string $locale = null): array
116116
{
117117
$locale = $locale ?: $this->defaultLocale;
118118
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);
@@ -136,7 +136,7 @@ public function getAll(string $locale = null): array
136136
/**
137137
* {@inheritdoc}
138138
*/
139-
public function getList(string $locale = null): array
139+
public function getList(?string $locale = null): array
140140
{
141141
$locale = $locale ?: $this->defaultLocale;
142142
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);

src/Country/CountryRepositoryInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface CountryRepositoryInterface
1515
*
1616
* @return Country
1717
*/
18-
public function get(string $countryCode, string $locale = null): Country;
18+
public function get(string $countryCode, ?string $locale = null): Country;
1919

2020
/**
2121
* Gets all countries.
@@ -24,7 +24,7 @@ public function get(string $countryCode, string $locale = null): Country;
2424
*
2525
* @return Country[] An array of countries, keyed by country code.
2626
*/
27-
public function getAll(string $locale = null): array;
27+
public function getAll(?string $locale = null): array;
2828

2929
/**
3030
* Gets a list of countries.
@@ -33,5 +33,5 @@ public function getAll(string $locale = null): array;
3333
*
3434
* @return string[] An array of country names, keyed by country code.
3535
*/
36-
public function getList(string $locale = null): array;
36+
public function getList(?string $locale = null): array;
3737
}

src/Locale.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public static function matchCandidates(?string $firstLocale, ?string $secondLoca
281281
* @throws UnknownLocaleException
282282
* @see self::getCandidates
283283
*/
284-
public static function resolve(array $availableLocales, string $locale, string $fallbackLocale = null): string
284+
public static function resolve(array $availableLocales, string $locale, ?string $fallbackLocale = null): string
285285
{
286286
$locale = self::canonicalize($locale);
287287
$resolvedLocale = null;

src/Subdivision/SubdivisionRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SubdivisionRepository implements SubdivisionRepositoryInterface
3636
* @param AddressFormatRepositoryInterface|null $addressFormatRepository The address format repository.
3737
* @param null $definitionPath Path to the subdivision definitions.
3838
*/
39-
public function __construct(AddressFormatRepositoryInterface $addressFormatRepository = null, $definitionPath = null)
39+
public function __construct(?AddressFormatRepositoryInterface $addressFormatRepository = null, $definitionPath = null)
4040
{
4141
$this->addressFormatRepository = $addressFormatRepository ?: new AddressFormatRepository();
4242
$this->definitionPath = $definitionPath ?: __DIR__ . '/../../resources/subdivision/';
@@ -72,7 +72,7 @@ public function getAll(array $parents): array
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function getList(array $parents, string $locale = null): array
75+
public function getList(array $parents, ?string $locale = null): array
7676
{
7777
$definitions = $this->loadDefinitions($parents);
7878
if (empty($definitions)) {

src/Subdivision/SubdivisionRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ public function getAll(array $parents): array;
3434
*
3535
* @return array An array of subdivision names, keyed by code.
3636
*/
37-
public function getList(array $parents, string $locale = null): array;
37+
public function getList(array $parents, ?string $locale = null): array;
3838
}

src/Validator/Constraints/AddressFormatConstraintValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AddressFormatConstraintValidator extends ConstraintValidator
2424
/**
2525
* Creates an AddressFormatValidator instance.
2626
*/
27-
public function __construct(AddressFormatRepositoryInterface $addressFormatRepository = null, SubdivisionRepositoryInterface $subdivisionRepository = null)
27+
public function __construct(?AddressFormatRepositoryInterface $addressFormatRepository = null, ?SubdivisionRepositoryInterface $subdivisionRepository = null)
2828
{
2929
$this->addressFormatRepository = $addressFormatRepository ?: new AddressFormatRepository();
3030
$this->subdivisionRepository = $subdivisionRepository ?: new SubdivisionRepository();

src/Validator/Constraints/CountryConstraintValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CountryConstraintValidator extends ConstraintValidator
1212
{
1313
protected CountryRepositoryInterface $countryRepository;
1414

15-
public function __construct(CountryRepositoryInterface $countryRepository = null)
15+
public function __construct(?CountryRepositoryInterface $countryRepository = null)
1616
{
1717
$this->countryRepository = $countryRepository ?: new CountryRepository();
1818
}

0 commit comments

Comments
 (0)