8000 [Intl] Cleanup by ro0NL · Pull Request #31366 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Intl] Cleanup #31366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2019
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
91 changes: 0 additions & 91 deletions src/Symfony/Component/Intl/CONTRIBUTING.md

This file was deleted.

43 changes: 13 additions & 30 deletions src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,20 @@
*/
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's the point of this. Constants were self explanatory, now we need a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maintaining the consts is an extra task, not worth it IMHO. i didnt follow it for languages also.

feel free to ignore :) but it reduces noise and makes adding entries more straightforward (the consts are only used here; it's not real API needed)

];

/**
Expand Down
32 changes: 9 additions & 23 deletions src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,18 @@
*/
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
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Exception\MissingResourceException;
use Symfony\Component\Intl\Locale;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm... are you sure about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep :)

* @param string $displayLocale Optional. The locale to return the result in
* Defaults to {@link \Locale::getDefault()}.

updated as such below

it's a tiny improvement, but worth clarifying IMHO to rely on the root \Locale (either the real one, or the Intl\Locale\Locale stub.

Intl\Locale extends from \Locale and doesnt own the default, only the default fallback.

This internal, first citizent, Intl\Locale is super confusing, and is really a LocaleFallback util


/**
* Data provider for currency-related data.
Expand Down Expand Up @@ -53,7 +52,7 @@ public function getCurrencies()
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]);
Expand All @@ -62,7 +61,7 @@ public function getSymbol($currency, $displayLocale = null)
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]);
Expand All @@ -71,7 +70,7 @@ public function getName($currency, $displayLocale = null)
public function getNames($displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

// ====================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -51,7 +50,7 @@ public function getAliases()
public function getName($language, $displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

return $this->reader->readEntry($this->path, $displayLocale, ['Names', $language]);
Expand All @@ -60,7 +59,7 @@ public function getName($language, $displayLocale = null)
public function getNames($displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

$languages = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -57,7 +56,7 @@ public function getAliases()
public function getName($locale, $displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

return $this->reader->readEntry($this->path, $displayLocale, ['Names', $locale]);
Expand All @@ -66,7 +65,7 @@ public function getName($locale, $displayLocale = null)
public function getNames($displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

$names = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -46,7 +45,7 @@ public function getRegions()
public function getName($region, $displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

return $this->reader->readEntry($this->path, $displayLocale, ['Names', $region]);
Expand All @@ -55,7 +54,7 @@ public function getName($region, $displayLocale = null)
public function getNames($displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

$names = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -46,7 +45,7 @@ public function getScripts()
public function getName($script, $displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

return $this->reader->readEntry($this->path, $displayLocale, ['Names', $script]);
Expand All @@ -55,7 +54,7 @@ public function getName($script, $displayLocale = null)
public function getNames($displayLocale = null)
{
if (null === $displayLocale) {
$displayLocale = Locale::getDefault();
$displayLocale = \Locale::getDefault();
}

$names = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Intl\Data\Provider\CurrencyDataProvider;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locale;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down Expand Up @@ -631,7 +630,7 @@ public function testGetNames($displayLocale)

public function testGetNamesDefaultLocale()
{
Locale::setDefault('de_AT');
\Locale::setDefault('de_AT');

$this->assertSame(
$this->dataProvider->getNames('de_AT'),
Expand Down Expand Up @@ -670,7 +669,7 @@ public function testGetName($displayLocale)

public function testGetNameDefaultLocale()
{
Locale::setDefault('de_AT');
\Locale::setDefault('de_AT');

$expected = $this->dataProvider->getNames('de_AT');
$actual = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ abstract class AbstractDataProviderTest extends TestCase

protected function setUp()
{
Locale::setDefault('en');
\Locale::setDefault('en');
Locale::setDefaultFallback('en');
}

Expand Down
7D69
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Intl\Data\Provider\LanguageDataProvider;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locale;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down Expand Up @@ -865,7 +864,7 @@ public function testGetNames($displayLocale)

public function testGetNamesDefaultLocale()
{
Locale::setDefault('de_AT');
\Locale::setDefault('de_AT');

$this->assertSame(
$this->dataProvider->getNames('de_AT'),
Expand Down Expand Up @@ -901,7 +900,7 @@ public function testGetName($displayLocale)

public function testGetNameDefaultLocale()
{
Locale::setDefault('de_AT');
\Locale::setDefault('de_AT');

$names = $this->dataProvider->getNames('de_AT');

Expand Down
Loading
0