Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents 4cc98c0 + 2fb503f commit fc67d38
Show file tree
Hide file tree
Showing 23 changed files with 3,306 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function alpha3CodeExists(string $alpha3Code): bool
*
* @throws MissingResourceException if the country code does not exist
*/
public static function getName(string $country, string $displayLocale = null): string
public static function getName(string $country, ?string $displayLocale = null): string
{
return self::readEntry(['Names', $country], $displayLocale);
}
Expand All @@ -99,7 +99,7 @@ public static function getName(string $country, string $displayLocale = null): s
*
* @throws MissingResourceException if the country code does not exist
*/
public static function getAlpha3Name(string $alpha3Code, string $displayLocale = null): string
public static function getAlpha3Name(string $alpha3Code, ?string $displayLocale = null): string
{
return self::getName(self::getAlpha2Code($alpha3Code), $displayLocale);
}
Expand All @@ -109,7 +109,7 @@ public static function getAlpha3Name(string $alpha3Code, string $displayLocale =
*
* @return array<string, string>
*/
public static function getNames(string $displayLocale = null): array
public static function getNames(?string $displayLocale = null): array
{
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
}
Expand All @@ -121,7 +121,7 @@ public static function getNames(string $displayLocale = null): array
*
* @return array<string, string>
*/
public static function getAlpha3Names(string $displayLocale = null): array
public static function getAlpha3Names(?string $displayLocale = null): array
{
$alpha2Names = self::getNames($displayLocale);
$alpha3Names = [];
Expand Down
6 changes: 3 additions & 3 deletions Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public static function exists(string $currency): bool
/**
* @throws MissingResourceException if the currency code does not exist
*/
public static function getName(string $currency, string $displayLocale = null): string
public static function getName(string $currency, ?string $displayLocale = null): string
{
return self::readEntry(['Names', $currency, self::INDEX_NAME], $displayLocale);
}

/**
* @return string[]
*/
public static function getNames(string $displayLocale = null): array
public static function getNames(?string $displayLocale = null): array
{
// ====================================================================
// For reference: It is NOT possible to return names indexed by
Expand All @@ -82,7 +82,7 @@ public static function getNames(string $displayLocale = null): array
/**
* @throws MissingResourceException if the currency code does not exist
*/
public static function getSymbol(string $currency, string $displayLocale = null): string
public static function getSymbol(string $currency, ?string $displayLocale = null): string
{
return self::readEntry(['Names', $currency, self::INDEX_SYMBOL], $displayLocale);
}
Expand Down
2 changes: 1 addition & 1 deletion Data/Generator/TimezoneDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function generateZones(BundleEntryReaderInterface $reader, string $tempD

$regionFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'regionFormat']);
$fallbackFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'fallbackFormat']);
$resolveName = function (string $id, string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string {
$resolveName = function (string $id, ?string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string {
// Resolve default name as described per http://cldr.unicode.org/translation/timezones
if (isset($this->zoneToCountryMapping[$id])) {
try {
Expand Down
66 changes: 66 additions & 0 deletions DateFormatter/DateFormat/Hour1200Transformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Intl\DateFormatter\DateFormat;

/**
* Parser and formatter for 12 hour format (0-11).
*
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour1200Transformer extends HourTransformer
{
/**
* {@inheritdoc}
*/
public function format(\DateTime $dateTime, int $length): string
{
$hourOfDay = $dateTime->format('g');
$hourOfDay = '12' === $hourOfDay ? '0' : $hourOfDay;

return $this->padLeft($hourOfDay, $length);
}

/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ('PM' === $marker) {
$hour += 12;
}

return $hour;
}

/**
* {@inheritdoc}
*/
public function getReverseMatchingRegExp(int $length): string
{
return '\d{1,2}';
}

/**
* {@inheritdoc}
*/
public function extractDateOptions(string $matched, int $length): array
{
return [
'hour' => (int) $matched,
'hourInstance' => $this,
];
}
}
66 changes: 66 additions & 0 deletions DateFormatter/DateFormat/Hour1201Transformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Intl\DateFormatter\DateFormat;

/**
* Parser and formatter for 12 hour format (1-12).
*
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour1201Transformer extends HourTransformer
{
/**
* {@inheritdoc}
*/
public function format(\DateTime $dateTime, int $length): string
{
return $this->padLeft($dateTime->format('g'), $length);
}

/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ('PM' !== $marker && 12 === $hour) {
$hour = 0;
} elseif ('PM' === $marker && 12 !== $hour) {
// If PM and hour is not 12 (1-12), sum 12 hour
$hour += 12;
}

return $hour;
}

/**
* {@inheritdoc}
*/
public function getReverseMatchingRegExp(int $length): string
{
return '\d{1,2}';
}

/**
* {@inheritdoc}
*/
public function extractDateOptions(string $matched, int $length): array
{
return [
'hour' => (int) $matched,
'hourInstance' => $this,
];
}
}
65 changes: 65 additions & 0 deletions DateFormatter/DateFormat/Hour2400Transformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Intl\DateFormatter\DateFormat;

/**
* Parser and formatter for 24 hour format (0-23).
*
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour2400Transformer extends HourTransformer
{
/**
* {@inheritdoc}
*/
public function format(\DateTime $dateTime, int $length): string
{
return $this->padLeft($dateTime->format('G'), $length);
}

/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ('AM' === $marker) {
$hour = 0;
} elseif ('PM' === $marker) {
$hour = 12;
}

return $hour;
}

/**
* {@inheritdoc}
*/
public function getReverseMatchingRegExp(int $length): string
{
return '\d{1,2}';
}

/**
* {@inheritdoc}
*/
public function extractDateOptions(string $matched, int $length): array
{
return [
'hour' => (int) $matched,
'hourInstance' => $this,
];
}
}
68 changes: 68 additions & 0 deletions DateFormatter/DateFormat/Hour2401Transformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Intl\DateFormatter\DateFormat;

/**
* Parser and formatter for 24 hour format (1-24).
*
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour2401Transformer extends HourTransformer
{
/**
* {@inheritdoc}
*/
public function format(\DateTime $dateTime, int $length): string
{
$hourOfDay = $dateTime->format('G');
$hourOfDay = '0' === $hourOfDay ? '24' : $hourOfDay;

return $this->padLeft($hourOfDay, $length);
}

/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ((null === $marker && 24 === $hour) || 'AM' === $marker) {
$hour = 0;
} elseif ('PM' === $marker) {
$hour = 12;
}

return $hour;
}

/**
* {@inheritdoc}
*/
public function getReverseMatchingRegExp(int $length): string
{
return '\d{1,2}';
}

/**
* {@inheritdoc}
*/
public function extractDateOptions(string $matched, int $length): array
{
return [
'hour' => (int) $matched,
'hourInstance' => $this,
];
}
}
34 changes: 34 additions & 0 deletions DateFormatter/DateFormat/HourTransformer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Intl\DateFormatter\DateFormat;

/**
* Base class for hour transformers.
*
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class HourTransformer extends Transformer
{
/**
* Returns a normalized hour value suitable for the hour transformer type.
*
* @param int $hour The hour value
* @param string|null $marker An optional AM/PM marker
*
* @return int The normalized hour value
*/
abstract public function normalizeHour(int $hour, ?string $marker = null): int;
}
Loading

0 comments on commit fc67d38

Please sign in to comment.