Skip to content

Commit fc67d38

Browse files
Merge branch '5.4' into 6.3
* 5.4: Fix implicitly-required parameters List CS fix in .git-blame-ignore-revs Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value [Messenger][AmazonSqs] Allow async-aws/sqs version 2
2 parents 4cc98c0 + 2fb503f commit fc67d38

23 files changed

+3306
-28
lines changed

Countries.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static function alpha3CodeExists(string $alpha3Code): bool
8989
*
9090
* @throws MissingResourceException if the country code does not exist
9191
*/
92-
public static function getName(string $country, string $displayLocale = null): string
92+
public static function getName(string $country, ?string $displayLocale = null): string
9393
{
9494
return self::readEntry(['Names', $country], $displayLocale);
9595
}
@@ -99,7 +99,7 @@ public static function getName(string $country, string $displayLocale = null): s
9999
*
100100
* @throws MissingResourceException if the country code does not exist
101101
*/
102-
public static function getAlpha3Name(string $alpha3Code, string $displayLocale = null): string
102+
public static function getAlpha3Name(string $alpha3Code, ?string $displayLocale = null): string
103103
{
104104
return self::getName(self::getAlpha2Code($alpha3Code), $displayLocale);
105105
}
@@ -109,7 +109,7 @@ public static function getAlpha3Name(string $alpha3Code, string $displayLocale =
109109
*
110110
* @return array<string, string>
111111
*/
112-
public static function getNames(string $displayLocale = null): array
112+
public static function getNames(?string $displayLocale = null): array
113113
{
114114
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
115115
}
@@ -121,7 +121,7 @@ public static function getNames(string $displayLocale = null): array
121121
*
122122
* @return array<string, string>
123123
*/
124-
public static function getAlpha3Names(string $displayLocale = null): array
124+
public static function getAlpha3Names(?string $displayLocale = null): array
125125
{
126126
$alpha2Names = self::getNames($displayLocale);
127127
$alpha3Names = [];

Currencies.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public static function exists(string $currency): bool
5050
/**
5151
* @throws MissingResourceException if the currency code does not exist
5252
*/
53-
public static function getName(string $currency, string $displayLocale = null): string
53+
public static function getName(string $currency, ?string $displayLocale = null): string
5454
{
5555
return self::readEntry(['Names', $currency, self::INDEX_NAME], $displayLocale);
5656
}
5757

5858
/**
5959
* @return string[]
6060
*/
61-
public static function getNames(string $displayLocale = null): array
61+
public static function getNames(?string $displayLocale = null): array
6262
{
6363
// ====================================================================
6464
// For reference: It is NOT possible to return names indexed by
@@ -82,7 +82,7 @@ public static function getNames(string $displayLocale = null): array
8282
/**
8383
* @throws MissingResourceException if the currency code does not exist
8484
*/
85-
public static function getSymbol(string $currency, string $displayLocale = null): string
85+
public static function getSymbol(string $currency, ?string $displayLocale = null): string
8686
{
8787
return self::readEntry(['Names', $currency, self::INDEX_SYMBOL], $displayLocale);
8888
}

Data/Generator/TimezoneDataGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private function generateZones(BundleEntryReaderInterface $reader, string $tempD
159159

160160
$regionFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'regionFormat']);
161161
$fallbackFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'fallbackFormat']);
162-
$resolveName = function (string $id, string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string {
162+
$resolveName = function (string $id, ?string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string {
163163
// Resolve default name as described per http://cldr.unicode.org/translation/timezones
164164
if (isset($this->zoneToCountryMapping[$id])) {
165165
try {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13+
14+
/**
15+
* Parser and formatter for 12 hour format (0-11).
16+
*
17+
* @author Igor Wiedler <[email protected]>
18+
*
19+
* @internal
20+
*
21+
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
22+
*/
23+
class Hour1200Transformer extends HourTransformer
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function format(\DateTime $dateTime, int $length): string
29+
{
30+
$hourOfDay = $dateTime->format('g');
31+
$hourOfDay = '12' === $hourOfDay ? '0' : $hourOfDay;
32+
33+
return $this->padLeft($hourOfDay, $length);
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function normalizeHour(int $hour, ?string $marker = null): int
40+
{
41+
if ('PM' === $marker) {
42+
$hour += 12;
43+
}
44+
45+
return $hour;
46+
}
47+
48+
/**
49+
* {@inheritdoc}
50+
*/
51+
public function getReverseMatchingRegExp(int $length): string
52+
{
53+
return '\d{1,2}';
54+
}
55+
56+
/**
57+
* {@inheritdoc}
58+
*/
59+
public function extractDateOptions(string $matched, int $length): array
60+
{
61+
return [
62+
'hour' => (int) $matched,
63+
'hourInstance' => $this,
64+
];
65+
}
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13+
14+
/**
15+
* Parser and formatter for 12 hour format (1-12).
16+
*
17+
* @author Igor Wiedler <[email protected]>
18+
*
19+
* @internal
20+
*
21+
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
22+
*/
23+
class Hour1201Transformer extends HourTransformer
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function format(\DateTime $dateTime, int $length): string
29+
{
30+
return $this->padLeft($dateTime->format('g'), $length);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
public function normalizeHour(int $hour, ?string $marker = null): int
37+
{
38+
if ('PM' !== $marker && 12 === $hour) {
39+
$hour = 0;
40+
} elseif ('PM' === $marker && 12 !== $hour) {
41+
// If PM and hour is not 12 (1-12), sum 12 hour
42+
$hour += 12;
43+
}
44+
45+
return $hour;
46+
}
47+
48+
/**
49+
* {@inheritdoc}
50+
*/
51+
public function getReverseMatchingRegExp(int $length): string
52+
{
53+
return '\d{1,2}';
54+
}
55+
56+
/**
57+
* {@inheritdoc}
58+
*/
59+
public function extractDateOptions(string $matched, int $length): array
60+
{
61+
return [
62+
'hour' => (int) $matched,
63+
'hourInstance' => $this,
64+
];
65+
}
66+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13+
14+
/**
15+
* Parser and formatter for 24 hour format (0-23).
16+
*
17+
* @author Igor Wiedler <[email protected]>
18+
*
19+
* @internal
20+
*
21+
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
22+
*/
23+
class Hour2400Transformer extends HourTransformer
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function format(\DateTime $dateTime, int $length): string
29+
{
30+
return $this->padLeft($dateTime->format('G'), $length);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
public function normalizeHour(int $hour, ?string $marker = null): int
37+
{
38+
if ('AM' === $marker) {
39+
$hour = 0;
40+
} elseif ('PM' === $marker) {
41+
$hour = 12;
42+
}
43+
44+
return $hour;
45+
}
46+
47+
/**
48+
* {@inheritdoc}
49+
*/
50+
public function getReverseMatchingRegExp(int $length): string
51+
{
52+
return '\d{1,2}';
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
*/
58+
public function extractDateOptions(string $matched, int $length): array
59+
{
60+
return [
61+
'hour' => (int) $matched,
62+
'hourInstance' => $this,
63+
];
64+
}
65+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13+
14+
/**
15+
* Parser and formatter for 24 hour format (1-24).
16+
*
17+
* @author Igor Wiedler <[email protected]>
18+
*
19+
* @internal
20+
*
21+
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
22+
*/
23+
class Hour2401Transformer extends HourTransformer
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function format(\DateTime $dateTime, int $length): string
29+
{
30+
$hourOfDay = $dateTime->format('G');
31+
$hourOfDay = '0' === $hourOfDay ? '24' : $hourOfDay;
32+
33+
return $this->padLeft($hourOfDay, $length);
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function normalizeHour(int $hour, ?string $marker = null): int
40+
{
41+
if ((null === $marker && 24 === $hour) || 'AM' === $marker) {
42+
$hour = 0;
43+
} elseif ('PM' === $marker) {
44+
$hour = 12;
45+
}
46+
47+
return $hour;
48+
}
49+
50+
/**
51+
* {@inheritdoc}
52+
*/
53+
public function getReverseMatchingRegExp(int $length): string
54+
{
55+
return '\d{1,2}';
56+
}
57+
58+
/**
59+
* {@inheritdoc}
60+
*/
61+
public function extractDateOptions(string $matched, int $length): array
62+
{
63+
return [
64+
'hour' => (int) $matched,
65+
'hourInstance' => $this,
66+
];
67+
}
68+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13+
14+
/**
15+
* Base class for hour transformers.
16+
*
17+
* @author Eriksen Costa <[email protected]>
18+
*
19+
* @internal
20+
*
21+
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
22+
*/
23+
abstract class HourTransformer extends Transformer
24+
{
25+
/**
26+
* Returns a normalized hour value suitable for the hour transformer type.
27+
*
28+
* @param int $hour The hour value
29+
* @param string|null $marker An optional AM/PM marker
30+
*
31+
* @return int The normalized hour value
32+
*/
33+
abstract public function normalizeHour(int $hour, ?string $marker = null): int;
34+
}

0 commit comments

Comments
 (0)