From 70a941ec0c22c45c3bf2c47dec6bbd95882be283 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 2 May 2019 21:17:15 +0200 Subject: [PATCH] [Intl] Cleanup --- src/Symfony/Component/Intl/CONTRIBUTING.md | 91 ------------------- .../Data/Generator/CurrencyDataGenerator.php | 43 +++------ .../Data/Generator/RegionDataGenerator.php | 32 ++----- .../Data/Provider/CurrencyDataProvider.php | 7 +- .../Data/Provider/LanguageDataProvider.php | 5 +- .../Intl/Data/Provider/LocaleDataProvider.php | 5 +- .../Intl/Data/Provider/RegionDataProvider.php | 5 +- .../Intl/Data/Provider/ScriptDataProvider.php | 5 +- .../AbstractCurrencyDataProviderTest.php | 5 +- .../Provider/AbstractDataProviderTest.php | 2 +- .../AbstractLanguageDataProviderTest.php | 5 +- .../AbstractLocaleDataProviderTest.php | 5 +- .../AbstractRegionDataProviderTest.php | 3 +- .../AbstractScriptDataProviderTest.php | 5 +- 14 files changed, 43 insertions(+), 175 deletions(-) delete mode 100644 src/Symfony/Component/Intl/CONTRIBUTING.md diff --git a/src/Symfony/Component/Intl/CONTRIBUTING.md b/src/Symfony/Component/Intl/CONTRIBUTING.md deleted file mode 100644 index 971e0af7f5..0000000000 --- a/src/Symfony/Component/Intl/CONTRIBUTING.md +++ /dev/null @@ -1,91 +0,0 @@ -Contributing to the Intl component -================================== - -A very good way of contributing to the Intl component is by updating the -included data for the ICU version you have installed on your system. - -Preparation ------------ - -To prepare, you need to install the development dependencies of the component. - - $ cd /path/to/Symfony/Component/Intl - $ composer install - -Determining your ICU version ---------------------------- - -The ICU version installed in your PHP environment can be found by running -icu-version.php: - - $ php Resources/bin/icu-version.php - -Updating the ICU data ---------------------- - -To update the data files, run the update-icu-component.php script: - - $ php Resources/bin/update-icu-component.php - -The script needs the binaries "svn" and "make" to be available on your system. -It will download the latest version of the ICU sources for the ICU version -installed in your PHP environment. The script will then compile the "genrb" -binary and use it to compile the ICU data files to binaries. The binaries are -copied to the Resources/ directory of the Icu component found in the -vendor/symfony/icu/ directory. - -Updating the stub data ----------------------- - -In the previous step you updated the Icu component for the ICU version -installed on your system. If you are using the latest ICU version, you should -also create the stub data files which will be used by people who don't have -the intl extension installed. - -To update the stub files, run the update-stubs.php script: - - $ php Resources/bin/update-stubs.php - -The script will fail if you don't have the latest ICU version. If you want to -upgrade the ICU version, adjust the return value of the -`Intl::getIcuStubVersion()` before you run the script. - -The script creates copies of the binary resource bundles in the Icu component -and stores them in the Resources/ directory of the Intl component. The copies -are made for the locale "en" only and are stored in .php files, so that they -can be read even if the intl extension is not available. - -Creating a pull request ------------------------ - -You need to create up to two pull requests: - -* If you updated the Icu component, you need to push that change and create a - pull request in the `symfony/Icu` repository. Make sure to submit the pull - request to the correct master branch. If you updated the ICU data for version - 4.8, your pull request goes to branch `48-master`, for version 49 to - `49-master` and so on. - -* If you updated the stub files of the Intl component, you need to push that - change and create a pull request in the `symfony/symfony` repository. The - pull request should be based on the `master` branch. - -Combining .res files to a .dat-package --------------------------------------- - -The individual *.res files can be combined into a single .dat-file. -Unfortunately, PHP's `ResourceBundle` class is currently not able to handle -.dat-files. - -Once it is, the following steps have to be followed to build the .dat-file: - -1. Package the resource bundles into a single file - - $ find . -name *.res | sed -e "s/\.\///g" > packagelist.txt - $ pkgdata -p region -T build -d . packagelist.txt - -2. Clean up - - $ rm -rf build packagelist.txt - -3. You can now move region.dat to replace the version bundled with Symfony. diff --git a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php index 1be618d787..f64daf275a 100644 --- a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php @@ -25,37 +25,20 @@ use Symfony\Component\Intl\Data\Util\LocaleScanner; */ class CurrencyDataGenerator extends AbstractDataGenerator { - const UNKNOWN_CURRENCY_ID = 'XXX'; - const EUROPEAN_COMPOSITE_UNIT_ID = 'XBA'; - const EUROPEAN_MONETARY_UNIT_ID = 'XBB'; - const EUROPEAN_UNIT_OF_ACCOUNT_XBC_ID = 'XBC'; - const EUROPEAN_UNIT_OF_ACCOUNT_XBD_ID = 'XBD'; - const TESTING_CURRENCY_CODE_ID = 'XTS'; - const ADB_UNIT_OF_ACCOUNT_ID = 'XUA'; - const GOLD_ID = 'XAU'; - const SILVER_ID = 'XAG'; - const PLATINUM_ID = 'XPT'; - const PALLADIUM_ID = 'XPD'; - const SUCRE_ID = 'XSU'; - const SPECIAL_DRAWING_RIGHTS_ID = 'XDR'; - - /** - * Monetary units excluded from generation. - */ private static $blacklist = [ - self::UNKNOWN_CURRENCY_ID => true, - self::EUROPEAN_COMPOSITE_UNIT_ID => true, - self::EUROPEAN_MONETARY_UNIT_ID => true, - self::EUROPEAN_UNIT_OF_ACCOUNT_XBC_ID => true, - self::EUROPEAN_UNIT_OF_ACCOUNT_XBD_ID => true, - self::TESTING_CURRENCY_CODE_ID => true, - self::ADB_UNIT_OF_ACCOUNT_ID => true, - self::GOLD_ID => true, - self::SILVER_ID => true, - self::PLATINUM_ID => true, - self::PALLADIUM_ID => true, - self::SUCRE_ID => true, - self::SPECIAL_DRAWING_RIGHTS_ID => true, + 'XBA' => true, // European Composite Unit + 'XBB' => true, // European Monetary Unit + 'XBC' => true, // European Unit of Account (XBC) + 'XBD' => true, // European Unit of Account (XBD) + 'XUA' => true, // ADB Unit of Account + 'XAU' => true, // Gold + 'XAG' => true, // Silver + 'XPT' => true, // Platinum + 'XPD' => true, // Palladium + 'XSU' => true, // Sucre + 'XDR' => true, // Special Drawing Rights + 'XTS' => true, // Testing Currency Code + 'XXX' => true, // Unknown Currency ]; /** diff --git a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php index 0728db8030..9524e18eaf 100644 --- a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php @@ -27,32 +27,18 @@ use Symfony\Component\Intl\Data\Util\LocaleScanner; */ class RegionDataGenerator extends AbstractDataGenerator { - const UNKNOWN_REGION_ID = 'ZZ'; - const OUTLYING_OCEANIA_REGION_ID = 'QO'; - const EUROPEAN_UNION_ID = 'EU'; - const NETHERLANDS_ANTILLES_ID = 'AN'; - const BOUVET_ISLAND_ID = 'BV'; - const HEARD_MCDONALD_ISLANDS_ID = 'HM'; - const CLIPPERTON_ISLAND_ID = 'CP'; - const EUROZONE_ID = 'EZ'; - const UNITED_NATIONS_ID = 'UN'; - - /** - * Regions excluded from generation. - */ private static $blacklist = [ - self::UNKNOWN_REGION_ID => true, // Look like countries, but are sub-continents - self::OUTLYING_OCEANIA_REGION_ID => true, - self::EUROPEAN_UNION_ID => true, - self::EUROZONE_ID => true, - self::UNITED_NATIONS_ID => true, - // No longer exists - self::NETHERLANDS_ANTILLES_ID => true, + 'QO' => true, // Outlying Oceania + 'EU' => true, // European Union + 'EZ' => true, // Eurozone + 'UN' => true, // United Nations // Uninhabited islands - self::BOUVET_ISLAND_ID => true, - self::HEARD_MCDONALD_ISLANDS_ID => true, - self::CLIPPERTON_ISLAND_ID => true, + 'BV' => true, // Bouvet Island + 'HM' => true, // Heard & McDonald Islands + 'CP' => true, // Clipperton Island + // Misc + 'ZZ' => true, // Unknown Region ]; /** diff --git a/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php index dacde26f83..f31128535e 100644 --- a/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Data\Provider; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; use Symfony\Component\Intl\Exception\MissingResourceException; -use Symfony\Component\Intl\Locale; /** * Data provider for currency-related data. @@ -53,7 +52,7 @@ class CurrencyDataProvider public function getSymbol($currency, $displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, ['Names', $currency, static::INDEX_SYMBOL]); @@ -62,7 +61,7 @@ class CurrencyDataProvider public function getName($currency, $displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, ['Names', $currency, static::INDEX_NAME]); @@ -71,7 +70,7 @@ class CurrencyDataProvider public function getNames($displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } // ==================================================================== diff --git a/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php index 2178158513..ba31087a10 100644 --- a/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Intl\Data\Provider; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Locale; /** * Data provider for language-related ICU data. @@ -51,7 +50,7 @@ class LanguageDataProvider public function getName($language, $displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, ['Names', $language]); @@ -60,7 +59,7 @@ class LanguageDataProvider public function getNames($displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } $languages = $this->reader->readEntry($this->path, $displayLocale, ['Names']); diff --git a/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php index 4328b57d2f..df00f64406 100644 --- a/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Intl\Data\Provider; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Locale; /** * Data provider for locale-related ICU data. @@ -57,7 +56,7 @@ class LocaleDataProvider public function getName($locale, $displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, ['Names', $locale]); @@ -66,7 +65,7 @@ class LocaleDataProvider public function getNames($displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); diff --git a/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php index 08bd724394..c1ce805f1c 100644 --- a/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Intl\Data\Provider; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Locale; /** * Data provider for region-related ICU data. @@ -46,7 +45,7 @@ class RegionDataProvider public function getName($region, $displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, ['Names', $region]); @@ -55,7 +54,7 @@ class RegionDataProvider public function getNames($displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); diff --git a/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php index c6844494a8..55cd862c5e 100644 --- a/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Intl\Data\Provider; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Locale; /** * Data provider for script-related ICU data. @@ -46,7 +45,7 @@ class ScriptDataProvider public function getName($script, $displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } return $this->reader->readEntry($this->path, $displayLocale, ['Names', $script]); @@ -55,7 +54,7 @@ class ScriptDataProvider public function getNames($displayLocale = null) { if (null === $displayLocale) { - $displayLocale = Locale::getDefault(); + $displayLocale = \Locale::getDefault(); } $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php index 428f6f89b0..4c566aed3c 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider; use Symfony\Component\Intl\Data\Provider\CurrencyDataProvider; use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Locale; /** * @author Bernhard Schussek @@ -631,7 +630,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest public function testGetNamesDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $this->assertSame( $this->dataProvider->getNames('de_AT'), @@ -670,7 +669,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest public function testGetNameDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $expected = $this->dataProvider->getNames('de_AT'); $actual = []; diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php index d0ef4d273b..562f8386d1 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php @@ -703,7 +703,7 @@ abstract class AbstractDataProviderTest extends TestCase protected function setUp() { - Locale::setDefault('en'); + \Locale::setDefault('en'); Locale::setDefaultFallback('en'); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php index 003e688d03..2b55349584 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider; use Symfony\Component\Intl\Data\Provider\LanguageDataProvider; use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Locale; /** * @author Bernhard Schussek @@ -865,7 +864,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest public function testGetNamesDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $this->assertSame( $this->dataProvider->getNames('de_AT'), @@ -901,7 +900,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest public function testGetNameDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $names = $this->dataProvider->getNames('de_AT'); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php index aeca40cdbd..88242a6f9b 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider; use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Locale; /** * @author Bernhard Schussek @@ -64,7 +63,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest public function testGetNamesDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $this->assertSame( $this->dataProvider->getNames('de_AT'), @@ -100,7 +99,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest public function testGetNameDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $names = $this->dataProvider->getNames('de_AT'); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php index 1f5febb2b8..aeb922f9e3 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider; use Symfony\Component\Intl\Data\Provider\RegionDataProvider; use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Locale; /** * @author Bernhard Schussek @@ -316,7 +315,7 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest public function testGetNamesDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $this->assertSame( $this->dataProvider->getNames('de_AT'), diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php index db4b81ebdb..8620fb2060 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider; use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Locale; /** * @author Bernhard Schussek @@ -255,7 +254,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest public function testGetNamesDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $this->assertSame( $this->dataProvider->getNames('de_AT'), @@ -291,7 +290,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest public function testGetNameDefaultLocale() { - Locale::setDefault('de_AT'); + \Locale::setDefault('de_AT'); $names = $this->dataProvider->getNames('de_AT');