Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48e3f40

Browse files
committed
bug #31332 [Intl] Add phpdoc (ro0NL)
This PR was squashed before being merged into the 4.3-dev branch (closes #31332). Discussion ---------- [Intl] Add phpdoc | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #31325 (comment) | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Commits ------- 22a6f7b [Intl] Add phpdoc
2 parents 51ff98e + 22a6f7b commit 48e3f40

File tree

9 files changed

+64
-5
lines changed

9 files changed

+64
-5
lines changed

src/Symfony/Component/Intl/Currencies.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public static function exists(string $currency): bool
4545
}
4646
}
4747

48+
/**
49+
* @throws MissingResourceException if the currency code does not exists
50+
*/
4851
public static function getName(string $currency, string $displayLocale = null): string
4952
{
5053
return self::readEntry(['Names', $currency, self::INDEX_NAME], $displayLocale);
@@ -74,6 +77,9 @@ public static function getNames(string $displayLocale = null): array
7477
return self::asort($names, $displayLocale);
7578
}
7679

80+
/**
81+
* @throws MissingResourceException if the currency code does not exists
82+
*/
7783
public static function getSymbol(string $currency, string $displayLocale = null): string
7884
{
7985
return self::readEntry(['Names', $currency, self::INDEX_SYMBOL], $displayLocale);
@@ -100,11 +106,17 @@ public static function getRoundingIncrement(string $currency)
100106
}
101107
}
102108

109+
/**
110+
* @throws MissingResourceException if the currency code has no numeric code
111+
*/
103112
public static function getNumericCode(string $currency): int
104113
{
105114
return self::readEntry(['Alpha3ToNumeric', $currency], 'meta');
106115
}
107116

117+
/**
118+
* @throws MissingResourceException if the numeric code does not exists
119+
*/
108120
public static function forNumericCode(int $numericCode): array
109121
{
110122
return self::readEntry(['NumericToAlpha3', (string) $numericCode], 'meta');

src/Symfony/Component/Intl/Languages.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public static function exists(string $language): bool
4949
}
5050
}
5151

52+
/**
53+
* @throws MissingResourceException if the language code does not exists
54+
*/
5255
public static function getName(string $language, string $displayLocale = null): string
5356
{
5457
return self::readEntry(['Names', $language], $displayLocale);

src/Symfony/Component/Intl/Locales.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public static function exists(string $locale): bool
4848
}
4949
}
5050

51+
/**
52+
* @throws MissingResourceException if the locale does not exists
53+
*/
5154
public static function getName(string $locale, string $displayLocale = null): string
5255
{
5356
return self::readEntry(['Names', $locale], $displayLocale);

src/Symfony/Component/Intl/Regions.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static function exists(string $region): bool
4040
}
4141
}
4242

43+
/**
44+
* @throws MissingResourceException if the region code does not exists
45+
*/
4346
public static function getName(string $region, string $displayLocale = null): string
4447
{
4548
return self::readEntry(['Names', $region], $displayLocale);

src/Symfony/Component/Intl/Scripts.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static function exists(string $script): bool
4040
}
4141
}
4242

43+
/**
44+
* @throws MissingResourceException if the script code does not exists
45+
*/
4346
public static function getName(string $script, string $displayLocale = null): string
4447
{
4548
return self::readEntry(['Names', $script], $displayLocale);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,10 @@ function ($currency) { return [$currency]; },
683683
*/
684684
public function testGetFractionDigits($currency)
685685
{
686-
$this->assertInternalType('numeric', Currencies::getFractionDigits($currency));
686+
// ensure each currency code has a corresponding fraction digit
687+
Currencies::getFractionDigits($currency);
688+
689+
$this->addToAssertionCount(1);
687690
}
688691

689692
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,6 @@ public function testExists()
287287
{
288288
$this->assertTrue(Scripts::exists('Hans'));
289289
$this->assertTrue(Scripts::exists('Zzzz'));
290+
$this->assertFalse(Scripts::exists('foobar'));
290291
}
291292
}

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,15 @@ public function testGetRawOffset()
549549
$this->assertSame(20700, Timezones::getRawOffset('Asia/Katmandu'));
550550
}
551551

552+
/**
553+
* @expectedException \Exception
554+
* @expectedExceptionMessage Unknown or bad timezone (foobar)
555+
*/
556+
public function testGetRawOffsetWithUnknownTimezone()
557+
{
558+
Timezones::getRawOffset('foobar');
559+
}
560+
552561
public function testGetGmtOffset()
553562
{
554563
// timezones free from DST changes to avoid time-based variance
@@ -595,8 +604,11 @@ public function testGetCountryCodeWithUnknownTimezone()
595604
*/
596605
public function testGetGmtOffsetAvailability(string $timezone)
597606
{
598-
$this->assertInternalType('int', Timezones::getRawOffset($timezone));
599-
$this->assertInternalType('string', Timezones::getGmtOffset($timezone));
607+
// ensure each timezone identifier has a corresponding GMT offset
608+
Timezones::getRawOffset($timezone);
609+
Timezones::getGmtOffset($timezone);
610+
611+
$this->addToAssertionCount(1);
600612
}
601613

602614
/**
@@ -605,7 +617,10 @@ public function testGetGmtOffsetAvailability(string $timezone)
605617
public function testGetCountryCodeAvailability(string $timezone)
606618
{
607619
try {
608-
$this->assertInternalType('string', Timezones::getCountryCode($timezone));
620+
// ensure each timezone identifier has a corresponding country code
621+
Timezones::getCountryCode($timezone);
622+
623+
$this->addToAssertionCount(1);
609624
} catch (MissingResourceException $e) {
610625
if (\in_array($timezone, self::$zonesNoCountry, true)) {
611626
$this->markTestSkipped();
@@ -627,7 +642,10 @@ public function provideTimezones(): iterable
627642
*/
628643
public function testForCountryCodeAvailability(string $country)
629644
{
630-
$this->assertInternalType('array', Timezones::forCountryCode($country));
645+
// ensure each country code has a list of timezone identifiers (possibly empty)
646+
Timezones::forCountryCode($country);
647+
648+
$this->addToAssertionCount(1);
631649
}
632650

633651
public function provideCountries(): iterable

src/Symfony/Component/Intl/Timezones.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static function exists(string $timezone): bool
4040
}
4141
}
4242

43+
/**
44+
* @throws MissingResourceException if the timezone identifier does not exists
45+
*/
4346
public static function getName(string $timezone, string $displayLocale = null): string
4447
{
4548
return self::readEntry(['Names', $timezone], $displayLocale);
@@ -53,6 +56,10 @@ public static function getNames(string $displayLocale = null): array
5356
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
5457
}
5558

59+
/**
60+
* @throws \Exception if the timezone identifier does not exists
61+
* @throws RuntimeException if there's no timezone DST transition information available
62+
*/
5663
public static function getRawOffset(string $timezone, int $timestamp = null): int
5764
{
5865
if (null === $timestamp) {
@@ -76,11 +83,17 @@ public static function getGmtOffset(string $timezone, int $timestamp = null, str
7683
return sprintf(self::readEntry(['Meta', 'GmtFormat'], $displayLocale), sprintf(self::readEntry(['Meta', 'HourFormat', 0 <= $offset ? 0 : 1], $displayLocale), $abs / 3600, $abs / 60 % 60));
7784
}
7885

86+
/**
87+
* @throws MissingResourceException if the timezone identifier has no associated country code
88+
*/
7989
public static function getCountryCode(string $timezone): string
8090
{
8191
return self::readEntry(['ZoneToCountry', $timezone], 'meta');
8292
}
8393

94+
/**
95+
* @throws MissingResourceException if the country code does not exists
96+
*/
8497
public static function forCountryCode(string $country): array
8598
{
8699
try {

0 commit comments

Comments
 (0)