Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
private array $zoneIds = [];
private array $zoneToCountryMapping = [];
private array $localeAliases = [];
private array $ianaMap = [];

protected function scanLocales(LocaleScanner $scanner, string $sourceDir): array
{
Expand Down Expand Up @@ -65,8 +66,14 @@

protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array
{
if (!$this->ianaMap) {
foreach ($reader->readEntry($tempDir, 'timezoneTypes', ['ianaMap', 'timezone']) as $cldr => $iana) {
$this->ianaMap[str_replace(':', '/', $cldr)] = $iana;

Check failure on line 71 in src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidPropertyAssignmentValue

src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php:71:17: InvalidPropertyAssignmentValue: $this->ianaMap with declared type 'array<array-key, mixed>' cannot be assigned type 'non-empty-array<array<array-key, string>|string, mixed>' (see https://psalm.dev/145)

Check failure on line 71 in src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidPropertyAssignmentValue

src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php:71:17: InvalidPropertyAssignmentValue: $this->ianaMap with declared type 'array<array-key, mixed>' cannot be assigned type 'non-empty-array<array<array-key, string>|string, mixed>' (see https://psalm.dev/145)
}
}

if (!$this->zoneToCountryMapping) {
$this->zoneToCountryMapping = self::generateZoneToCountryMapping($reader->read($tempDir, 'windowsZones'));
$this->zoneToCountryMapping = $this->generateZoneToCountryMapping($reader->read($tempDir, 'windowsZones'));
}

// Don't generate aliases, as they are resolved during runtime
Expand All @@ -77,7 +84,7 @@

$localeBundle = $reader->read($tempDir, $displayLocale);

if (!isset($localeBundle['zoneStrings']) || null === $localeBundle['zoneStrings']) {
if (!isset($localeBundle['zoneStrings'])) {
return null;
}

Expand Down Expand Up @@ -137,7 +144,7 @@
return $data;
}

private function generateZones(BundleEntryReaderInterface $reader, string $tempDir, string $locale): array

Check failure on line 147 in src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidReturnType

src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php:147:106: InvalidReturnType: The declared return type 'array<array-key, mixed>' for Symfony\Component\Intl\Data\Generator\TimezoneDataGenerator::generateZones is incorrect, got 'array<array-key|array<array-key, string>, array<array-key, string>|mixed|string>' (see https://psalm.dev/011)

Check failure on line 147 in src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidReturnType

src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php:147:106: InvalidReturnType: The declared return type 'array<array-key, mixed>' for Symfony\Component\Intl\Data\Generator\TimezoneDataGenerator::generateZones is incorrect, got 'array<array-key|array<array-key, string>, array<array-key, string>|mixed|string>' (see https://psalm.dev/011)
{
$typeBundle = $reader->read($tempDir, 'timezoneTypes');
$available = [];
Expand Down Expand Up @@ -222,6 +229,10 @@
}

$zones[$id] = $name;

if (isset($this->ianaMap[$id])) {
$zones[$this->ianaMap[$id]] = $name;
}
}

return $zones;
Expand All @@ -242,14 +253,20 @@
return $metadata;
}

private static function generateZoneToCountryMapping(ArrayAccessibleResourceBundle $windowsZoneBundle): array
private function generateZoneToCountryMapping(ArrayAccessibleResourceBundle $windowsZoneBundle): array
{
$mapping = [];

foreach ($windowsZoneBundle['mapTimezones'] as $zoneInfo) {
foreach ($zoneInfo as $region => $zones) {
if (RegionDataGenerator::isValidCountryCode($region)) {
$mapping += array_fill_keys(explode(' ', $zones), $region);
foreach (explode(' ', $zones) as $zone) {
$mapping[$zone] = $region;

if (isset($this->ianaMap[$zone])) {
$mapping[$this->ianaMap[$zone]] = $region;
}
}
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/af.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/ak.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading