Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b187261

Browse filesBrowse files
committed
feature #31350 [Intl] Rename Regions to Countries (ro0NL)
This PR was merged into the 4.3-dev branch. Discussion ---------- [Intl] Rename Regions to Countries | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes (including intl-data group) | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Because that's what the current region data is about; country codes. This makes things consistent across the board; i.e. CountryType, CountryValidator This allows a possible other region subset (e.g "continents") to distinct. Thus having `Countries::class` + `Continents::class` both reading from the `region` data. By then data should be compiled under different keys. Current class is master only, so now or never :) The alternative approach would be `Regions::getCountryNames [,getContinentNames, etc.]`, which is harder to scale, and should also be decided for 4.3 ideally. Commits ------- 49aee67 [Intl] Rename Regions to Countries
2 parents aa37157 + 49aee67 commit b187261
Copy full SHA for b187261

17 files changed

+60
-65
lines changed

‎UPGRADE-4.3.md

Copy file name to clipboardExpand all lines: UPGRADE-4.3.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Intl
108108
* Deprecated `Intl::getCurrencyBundle()`, use `Currencies` instead
109109
* Deprecated `Intl::getLanguageBundle()`, use `Languages` or `Scripts` instead
110110
* Deprecated `Intl::getLocaleBundle()`, use `Locales` instead
111-
* Deprecated `Intl::getRegionBundle()`, use `Regions` instead
111+
* Deprecated `Intl::getRegionBundle()`, use `Countries` instead
112112

113113
Messenger
114114
---------

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Intl
246246
* Removed `Intl::getLanguageBundle()`, use `Languages` or `Scripts` instead
247247
* Removed `Intl::getCurrencyBundle()`, use `Currencies` instead
248248
* Removed `Intl::getLocaleBundle()`, use `Locales` instead
249-
* Removed `Intl::getRegionBundle()`, use `Regions` instead
249+
* Removed `Intl::getRegionBundle()`, use `Countries` instead
250250

251251
Messenger
252252
---------

‎src/Symfony/Component/Form/Extension/Core/Type/CountryType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/CountryType.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Intl\Regions;
18+
use Symfony\Component\Intl\Countries;
1919
use Symfony\Component\OptionsResolver\Options;
2020
use Symfony\Component\OptionsResolver\OptionsResolver;
2121

@@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver)
4444
$choiceTranslationLocale = $options['choice_translation_locale'];
4545

4646
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {
47-
return array_flip(Regions::getNames($choiceTranslationLocale));
47+
return array_flip(Countries::getNames($choiceTranslationLocale));
4848
});
4949
},
5050
'choice_translation_domain' => false,
@@ -83,7 +83,7 @@ public function loadChoiceList($value = null)
8383
return $this->choiceList;
8484
}
8585

86-
return $this->choiceList = new ArrayChoiceList(array_flip(Regions::getNames()), $value);
86+
return $this->choiceList = new ArrayChoiceList(array_flip(Countries::getNames()), $value);
8787
}
8888

8989
/**

‎src/Symfony/Component/Intl/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CHANGELOG
88
* added `Currencies` in favor of `Intl::getCurrencyBundle()`
99
* added `Languages` and `Scripts` in favor of `Intl::getLanguageBundle()`
1010
* added `Locales` in favor of `Intl::getLocaleBundle()`
11-
* added `Regions` in favor of `Intl::getRegionBundle()`
11+
* added `Countries` in favor of `Intl::getRegionBundle()`
1212
* added `Timezones`
1313

1414
4.2.0

‎src/Symfony/Component/Intl/Regions.php renamed to ‎src/Symfony/Component/Intl/Countries.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Countries.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
* @author Bernhard Schussek <bschussek@gmail.com>
2020
* @author Roland Franssen <franssen.roland@gmail.com>
2121
*/
22-
final class Regions extends ResourceBundle
22+
final class Countries extends ResourceBundle
2323
{
2424
/**
2525
* @return string[]
2626
*/
27-
public static function getRegionCodes(): array
27+
public static function getCountryCodes(): array
2828
{
2929
return self::readEntry(['Regions'], 'meta');
3030
}
3131

32-
public static function exists(string $region): bool
32+
public static function exists(string $country): bool
3333
{
3434
try {
35-
self::readEntry(['Names', $region]);
35+
self::readEntry(['Names', $country]);
3636

3737
return true;
3838
} catch (MissingResourceException $e) {
@@ -41,11 +41,11 @@ public static function exists(string $region): bool
4141
}
4242

4343
/**
44-
* @throws MissingResourceException if the region code does not exists
44+
* @throws MissingResourceException if the country code does not exists
4545
*/
46-
public static function getName(string $region, string $displayLocale = null): string
46+
public static function getName(string $country, string $displayLocale = null): string
4747
{
48-
return self::readEntry(['Names', $region], $displayLocale);
48+
return self::readEntry(['Names', $country], $displayLocale);
4949
}
5050

5151
/**

‎src/Symfony/Component/Intl/Intl.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Intl.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ public static function getLocaleBundle()
188188
*
189189
* @return RegionBundleInterface The region resource bundle
190190
*
191-
* @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Regions} instead.
191+
* @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Countries} instead.
192192
*/
193193
public static function getRegionBundle()
194194
{
195-
@trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Regions::class), E_USER_DEPRECATED);
195+
@trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Countries::class), E_USER_DEPRECATED);
196196

197197
if (null === self::$regionBundle) {
198198
self::$regionBundle = new RegionBundle(

‎src/Symfony/Component/Intl/Tests/RegionsTest.php renamed to ‎src/Symfony/Component/Intl/Tests/CountriesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/CountriesTest.php
+19-20Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14-
use Symfony\Component\Intl\Locale;
15-
use Symfony\Component\Intl\Regions;
14+
use Symfony\Component\Intl\Countries;
1615

1716
/**
1817
* @group intl-data
1918
*/
20-
class RegionsTest extends ResourceBundleTestCase
19+
class CountriesTest extends ResourceBundleTestCase
2120
{
2221
// The below arrays document the state of the ICU data bundled with this package.
2322

24-
private static $territories = [
23+
private static $countries = [
2524
'AC',
2625
'AD',
2726
'AE',
@@ -279,28 +278,28 @@ class RegionsTest extends ResourceBundleTestCase
279278
'ZW',
280279
];
281280

282-
public function testGetRegions()
281+
public function testGetCountryCodes()
283282
{
284-
$this->assertSame(self::$territories, Regions::getRegionCodes());
283+
$this->assertSame(self::$countries, Countries::getCountryCodes());
285284
}
286285

287286
/**
288287
* @dataProvider provideLocales
289288
*/
290289
public function testGetNames($displayLocale)
291290
{
292-
$countries = array_keys(Regions::getNames($displayLocale));
291+
$countries = array_keys(Countries::getNames($displayLocale));
293292

294293
sort($countries);
295294

296-
$this->assertSame(self::$territories, $countries);
295+
$this->assertSame(self::$countries, $countries);
297296
}
298297

299298
public function testGetNamesDefaultLocale()
300299
{
301-
Locale::setDefault('de_AT');
300+
\Locale::setDefault('de_AT');
302301

303-
$this->assertSame(Regions::getNames('de_AT'), Regions::getNames());
302+
$this->assertSame(Countries::getNames('de_AT'), Countries::getNames());
304303
}
305304

306305
/**
@@ -311,18 +310,18 @@ public function testGetNamesSupportsAliases($alias, $ofLocale)
311310
// Can't use assertSame(), because some aliases contain scripts with
312311
// different collation (=order of output) than their aliased locale
313312
// e.g. sr_Latn_ME => sr_ME
314-
$this->assertEquals(Regions::getNames($ofLocale), Regions::getNames($alias));
313+
$this->assertEquals(Countries::getNames($ofLocale), Countries::getNames($alias));
315314
}
316315

317316
/**
318317
* @dataProvider provideLocales
319318
*/
320319
public function testGetName($displayLocale)
321320
{
322-
$names = Regions::getNames($displayLocale);
321+
$names = Countries::getNames($displayLocale);
323322

324323
foreach ($names as $country => $name) {
325-
$this->assertSame($name, Regions::getName($country, $displayLocale));
324+
$this->assertSame($name, Countries::getName($country, $displayLocale));
326325
}
327326
}
328327

@@ -332,13 +331,13 @@ public function testGetName($displayLocale)
332331
public function testLocaleAliasesAreLoaded()
333332
{
334333
\Locale::setDefault('zh_TW');
335-
$countryNameZhTw = Regions::getName('AD');
334+
$countryNameZhTw = Countries::getName('AD');
336335

337336
\Locale::setDefault('zh_Hant_TW');
338-
$countryNameHantZhTw = Regions::getName('AD');
337+
$countryNameHantZhTw = Countries::getName('AD');
339338

340339
\Locale::setDefault('zh');
341-
$countryNameZh = Regions::getName('AD');
340+
$countryNameZh = Countries::getName('AD');
342341

343342
$this->assertSame($countryNameZhTw, $countryNameHantZhTw, 'zh_TW is an alias to zh_Hant_TW');
344343
$this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh');
@@ -347,14 +346,14 @@ public function testLocaleAliasesAreLoaded()
347346
/**
348347
* @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
349348
*/
350-
public function testGetNameWithInvalidRegionCode()
349+
public function testGetNameWithInvalidCountryCode()
351350
{
352-
Regions::getName('foo');
351+
Countries::getName('foo');
353352
}
354353

355354
public function testExists()
356355
{
357-
$this->assertTrue(Regions::exists('NL'));
358-
$this->assertFalse(Regions::exists('ZZ'));
356+
$this->assertTrue(Countries::exists('NL'));
357+
$this->assertFalse(Countries::exists('ZZ'));
359358
}
360359
}

‎src/Symfony/Component/Intl/Tests/CurrenciesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/CurrenciesTest.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Intl\Tests;
1313

1414
use Symfony\Component\Intl\Currencies;
15-
use Symfony\Component\Intl\Locale;
1615

1716
/**
1817
* @group intl-data
@@ -585,7 +584,7 @@ class CurrenciesTest extends ResourceBundleTestCase
585584
'USS' => 998,
586585
];
587586

588-
public function testGetCurrencies()
587+
public function testGetCurrencyCodes()
589588
{
590589
$this->assertSame(self::$currencies, Currencies::getCurrencyCodes());
591590
}
@@ -613,7 +612,7 @@ public function testGetNames($displayLocale)
613612

614613
public function testGetNamesDefaultLocale()
615614
{
616-
Locale::setDefault('de_AT');
615+
\Locale::setDefault('de_AT');
617616

618617
$this->assertSame(Currencies::getNames('de_AT'), Currencies::getNames());
619618
}
@@ -646,7 +645,7 @@ public function testGetName($displayLocale)
646645

647646
public function testGetNameDefaultLocale()
648647
{
649-
Locale::setDefault('de_AT');
648+
\Locale::setDefault('de_AT');
650649

651650
$expected = Currencies::getNames('de_AT');
652651
$actual = [];

‎src/Symfony/Component/Intl/Tests/LanguagesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/LanguagesTest.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Intl\Tests;
1313

1414
use Symfony\Component\Intl\Languages;
15-
use Symfony\Component\Intl\Locale;
1615

1716
/**
1817
* @group intl-data
@@ -824,7 +823,7 @@ class LanguagesTest extends ResourceBundleTestCase
824823
'zu' => 'zul',
825824
];
826825

827-
public function testGetLanguages()
826+
public function testGetLanguageCodes()
828827
{
829828
$this->assertEquals(self::$languages, Languages::getLanguageCodes());
830829
}
@@ -844,7 +843,7 @@ public function testGetNames($displayLocale)
844843

845844
public function testGetNamesDefaultLocale()
846845
{
847-
Locale::setDefault('de_AT');
846+
\Locale::setDefault('de_AT');
848847

849848
$this->assertSame(Languages::getNames('de_AT'), Languages::getNames());
850849
}
@@ -874,7 +873,7 @@ public function testGetName($displayLocale)
874873

875874
public function testGetNameDefaultLocale()
876875
{
877-
Locale::setDefault('de_AT');
876+
\Locale::setDefault('de_AT');
878877

879878
$names = Languages::getNames('de_AT');
880879

‎src/Symfony/Component/Intl/Tests/LocalesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/LocalesTest.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14-
use Symfony\Component\Intl\Locale;
1514
use Symfony\Component\Intl\Locales;
1615

1716
/**
@@ -24,7 +23,7 @@ public function testGetLocales()
2423
$this->assertSame($this->getLocales(), Locales::getLocales());
2524
}
2625

27-
public function testGetLocaleAliases()
26+
public function testGetAliases()
2827
{
2928
$this->assertSame($this->getLocaleAliases(), Locales::getAliases());
3029
}
@@ -46,7 +45,7 @@ public function testGetNames($displayLocale)
4645

4746
public function testGetNamesDefaultLocale()
4847
{
49-
Locale::setDefault('de_AT');
48+
\Locale::setDefault('de_AT');
5049

5150
$this->assertSame(Locales::getNames('de_AT'), Locales::getNames());
5251
}
@@ -76,7 +75,7 @@ public function testGetName($displayLocale)
7675

7776
public function testGetNameDefaultLocale()
7877
{
79-
Locale::setDefault('de_AT');
78+
\Locale::setDefault('de_AT');
8079

8180
$names = Locales::getNames('de_AT');
8281

‎src/Symfony/Component/Intl/Tests/ScriptsTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/ScriptsTest.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14-
use Symfony\Component\Intl\Locale;
1514
use Symfony\Component\Intl\Scripts;
1615

1716
/**
@@ -214,7 +213,7 @@ class ScriptsTest extends ResourceBundleTestCase
214213
'Zzzz',
215214
];
216215

217-
public function testGetScripts()
216+
public function testGetScriptCodes()
218217
{
219218
$this->assertSame(self::$scripts, Scripts::getScriptCodes());
220219
}
@@ -236,7 +235,7 @@ public function testGetNames($displayLocale)
236235

237236
public function testGetNamesDefaultLocale()
238237
{
239-
Locale::setDefault('de_AT');
238+
\Locale::setDefault('de_AT');
240239

241240
$this->assertSame(Scripts::getNames('de_AT'), Scripts::getNames());
242241
}
@@ -266,7 +265,7 @@ public function testGetName($displayLocale)
266265

267266
public function testGetNameDefaultLocale()
268267
{
269-
Locale::setDefault('de_AT');
268+
\Locale::setDefault('de_AT');
270269

271270
$names = Scripts::getNames('de_AT');
272271

‎src/Symfony/Component/Intl/Tests/TimezonesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/TimezonesTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14+
use Symfony\Component\Intl\Countries;
1415
use Symfony\Component\Intl\Exception\MissingResourceException;
15-
use Symfony\Component\Intl\Regions;
1616
use Symfony\Component\Intl\Timezones;
1717

1818
/**
@@ -468,7 +468,7 @@ class TimezonesTest extends ResourceBundleTestCase
468468
'Etc/UTC',
469469
];
470470

471-
public function testGetTimezones()
471+
public function testGetIds()
472472
{
473473
$this->assertEquals(self::$zones, Timezones::getIds());
474474
}
@@ -652,6 +652,6 @@ public function provideCountries(): iterable
652652
{
653653
return array_map(function ($country) {
654654
return [$country];
655-
}, Regions::getRegionCodes());
655+
}, Countries::getCountryCodes());
656656
}
657657
}

‎src/Symfony/Component/Intl/Timezones.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Timezones.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static function forCountryCode(string $country): array
9999
try {
100100
return self::readEntry(['CountryToZone', $country], 'meta');
101101
} catch (MissingResourceException $e) {
102-
if (Regions::exists($country)) {
102+
if (Countries::exists($country)) {
103103
return [];
104104
}
105105

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.