Skip to content

Commit 9d14eef

Browse files
Merge branch '6.4' into 7.2
* 6.4: Improve docblock on compile() [VarDumper] Fix dumping LazyObjectState when using VarExporter v8 Allow NumberToLocalizedStringTransformer empty values [Intl] Ensure data consistency between alpha and numeric codes [Intl] Add missing currency (NOK) localization (en_NO)
2 parents f8a603f + a3b12ce commit 9d14eef

File tree

4 files changed

+30
-111
lines changed

4 files changed

+30
-111
lines changed

Data/Generator/RegionDataGenerator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected function generateDataForMeta(BundleEntryReaderInterface $reader, strin
160160
$alpha3ToAlpha2 = array_flip($alpha2ToAlpha3);
161161
asort($alpha3ToAlpha2);
162162

163-
$alpha2ToNumeric = $this->generateAlpha2ToNumericMapping($metadataBundle);
163+
$alpha2ToNumeric = $this->generateAlpha2ToNumericMapping(array_flip($this->regionCodes), $metadataBundle);
164164
$numericToAlpha2 = [];
165165
foreach ($alpha2ToNumeric as $alpha2 => $numeric) {
166166
// Add underscore prefix to force keys with leading zeros to remain as string keys.
@@ -231,7 +231,7 @@ private function generateAlpha2ToAlpha3Mapping(array $countries, ArrayAccessible
231231
return $alpha2ToAlpha3;
232232
}
233233

234-
private function generateAlpha2ToNumericMapping(ArrayAccessibleResourceBundle $metadataBundle): array
234+
private function generateAlpha2ToNumericMapping(array $countries, ArrayAccessibleResourceBundle $metadataBundle): array
235235
{
236236
$aliases = iterator_to_array($metadataBundle['alias']['territory']);
237237

@@ -250,6 +250,10 @@ private function generateAlpha2ToNumericMapping(ArrayAccessibleResourceBundle $m
250250
continue;
251251
}
252252

253+
if (!isset($countries[$data['replacement']])) {
254+
continue;
255+
}
256+
253257
if ('deprecated' === $data['reason']) {
254258
continue;
255259
}

Resources/data/currencies/en_NO.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
return [
4+
'Names' => [
5+
'NOK' => [
6+
'kr',
7+
'Norwegian Krone',
8+
],
9+
],
10+
];

Resources/data/regions/meta.php

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@
755755
'ZWE' => 'ZW',
756756
],
757757
'Alpha2ToNumeric' => [
758-
'AA' => '958',
759758
'AD' => '020',
760759
'AE' => '784',
761760
'AF' => '004',
@@ -943,18 +942,6 @@
943942
'PW' => '585',
944943
'PY' => '600',
945944
'QA' => '634',
946-
'QM' => '959',
947-
'QN' => '960',
948-
'QP' => '962',
949-
'QQ' => '963',
950-
'QR' => '964',
951-
'QS' => '965',
952-
'QT' => '966',
953-
'QV' => '968',
954-
'QW' => '969',
955-
'QX' => '970',
956-
'QY' => '971',
957-
'QZ' => '972',
958945
'RE' => '638',
959946
'RO' => '642',
960947
'RS' => '688',
@@ -1012,37 +999,13 @@
1012999
'VU' => '548',
10131000
'WF' => '876',
10141001
'WS' => '882',
1015-
'XC' => '975',
1016-
'XD' => '976',
1017-
'XE' => '977',
1018-
'XF' => '978',
1019-
'XG' => '979',
1020-
'XH' => '980',
1021-
'XI' => '981',
1022-
'XJ' => '982',
1023-
'XL' => '984',
1024-
'XM' => '985',
1025-
'XN' => '986',
1026-
'XO' => '987',
1027-
'XP' => '988',
1028-
'XQ' => '989',
1029-
'XR' => '990',
1030-
'XS' => '991',
1031-
'XT' => '992',
1032-
'XU' => '993',
1033-
'XV' => '994',
1034-
'XW' => '995',
1035-
'XX' => '996',
1036-
'XY' => '997',
1037-
'XZ' => '998',
10381002
'YE' => '887',
10391003
'YT' => '175',
10401004
'ZA' => '710',
10411005
'ZM' => '894',
10421006
'ZW' => '716',
10431007
],
10441008
'NumericToAlpha2' => [
1045-
'_958' => 'AA',
10461009
'_020' => 'AD',
10471010
'_784' => 'AE',
10481011
'_004' => 'AF',
@@ -1230,18 +1193,6 @@
12301193
'_585' => 'PW',
12311194
'_600' => 'PY',
12321195
'_634' => 'QA',
1233-
'_959' => 'QM',
1234-
'_960' => 'QN',
1235-
'_962' => 'QP',
1236-
'_963' => 'QQ',
1237-
'_964' => 'QR',
1238-
'_965' => 'QS',
1239-
'_966' => 'QT',
1240-
'_968' => 'QV',
1241-
'_969' => 'QW',
1242-
'_970' => 'QX',
1243-
'_971' => 'QY',
1244-
'_972' => 'QZ',
12451196
'_638' => 'RE',
12461197
'_642' => 'RO',
12471198
'_688' => 'RS',
@@ -1299,29 +1250,6 @@
12991250
'_548' => 'VU',
13001251
'_876' => 'WF',
13011252
'_882' => 'WS',
1302-
'_975' => 'XC',
1303-
'_976' => 'XD',
1304-
'_977' => 'XE',
1305-
'_978' => 'XF',
1306-
'_979' => 'XG',
1307-
'_980' => 'XH',
1308-
'_981' => 'XI',
1309-
'_982' => 'XJ',
1310-
'_984' => 'XL',
1311-
'_985' => 'XM',
1312-
'_986' => 'XN',
1313-
'_987' => 'XO',
1314-
'_988' => 'XP',
1315-
'_989' => 'XQ',
1316-
'_990' => 'XR',
1317-
'_991' => 'XS',
1318-
'_992' => 'XT',
1319-
'_993' => 'XU',
1320-
'_994' => 'XV',
1321-
'_995' => 'XW',
1322-
'_996' => 'XX',
1323-
'_997' => 'XY',
1324-
'_998' => 'XZ',
13251253
'_887' => 'YE',
13261254
'_175' => 'YT',
13271255
'_710' => 'ZA',

Tests/CountriesTest.php

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ class CountriesTest extends ResourceBundleTestCase
527527
];
528528

529529
private const ALPHA2_TO_NUMERIC = [
530-
'AA' => '958',
531530
'AD' => '020',
532531
'AE' => '784',
533532
'AF' => '004',
@@ -715,18 +714,6 @@ class CountriesTest extends ResourceBundleTestCase
715714
'PW' => '585',
716715
'PY' => '600',
717716
'QA' => '634',
718-
'QM' => '959',
719-
'QN' => '960',
720-
'QP' => '962',
721-
'QQ' => '963',
722-
'QR' => '964',
723-
'QS' => '965',
724-
'QT' => '966',
725-
'QV' => '968',
726-
'QW' => '969',
727-
'QX' => '970',
728-
'QY' => '971',
729-
'QZ' => '972',
730717
'RE' => '638',
731718
'RO' => '642',
732719
'RS' => '688',
@@ -784,36 +771,26 @@ class CountriesTest extends ResourceBundleTestCase
784771
'VU' => '548',
785772
'WF' => '876',
786773
'WS' => '882',
787-
'XC' => '975',
788-
'XD' => '976',
789-
'XE' => '977',
790-
'XF' => '978',
791-
'XG' => '979',
792-
'XH' => '980',
793-
'XI' => '981',
794-
'XJ' => '982',
795-
'XL' => '984',
796-
'XM' => '985',
797-
'XN' => '986',
798-
'XO' => '987',
799-
'XP' => '988',
800-
'XQ' => '989',
801-
'XR' => '990',
802-
'XS' => '991',
803-
'XT' => '992',
804-
'XU' => '993',
805-
'XV' => '994',
806-
'XW' => '995',
807-
'XX' => '996',
808-
'XY' => '997',
809-
'XZ' => '998',
810774
'YE' => '887',
811775
'YT' => '175',
812776
'ZA' => '710',
813777
'ZM' => '894',
814778
'ZW' => '716',
815779
];
816780

781+
public function testAllGettersGenerateTheSameDataSetCount()
782+
{
783+
$alpha2Count = count(Countries::getCountryCodes());
784+
$alpha3Count = count(Countries::getAlpha3Codes());
785+
$numericCodesCount = count(Countries::getNumericCodes());
786+
$namesCount = count(Countries::getNames());
787+
788+
// we base all on Name count since it is the first to be generated
789+
$this->assertEquals($namesCount, $alpha2Count, 'Alpha 2 count does not match');
790+
$this->assertEquals($namesCount, $alpha3Count, 'Alpha 3 count does not match');
791+
$this->assertEquals($namesCount, $numericCodesCount, 'Numeric codes count does not match');
792+
}
793+
817794
public function testGetCountryCodes()
818795
{
819796
$this->assertSame(self::COUNTRIES, Countries::getCountryCodes());
@@ -992,7 +969,7 @@ public function testGetNumericCode()
992969
public function testNumericCodeExists()
993970
{
994971
$this->assertTrue(Countries::numericCodeExists('250'));
995-
$this->assertTrue(Countries::numericCodeExists('982'));
972+
$this->assertTrue(Countries::numericCodeExists('008'));
996973
$this->assertTrue(Countries::numericCodeExists('716'));
997974
$this->assertTrue(Countries::numericCodeExists('036'));
998975
$this->assertFalse(Countries::numericCodeExists('667'));

0 commit comments

Comments
 (0)