Skip to content

Commit e4d9608

Browse files
Merge branch '4.4'
* 4.4: [Debug] Improve UPGRADE files remove wrongly added legacy group from test consistently throw NotSupportException [HttpKernel] Clarify error handler restoring process again [HttpClient] Remove CURLOPT_CONNECTTIMEOUT_MS curl opt add missing conflict rule [Intl] fix nullable phpdocs and useless method visibility of internal class remove some more useless phpdocs Resilience against file_get_contents() race conditions. Turned return type annotations of private methods into php return types.
2 parents d8daa7d + 993f971 commit e4d9608

File tree

8 files changed

+25
-58
lines changed

8 files changed

+25
-58
lines changed

Collator/Collator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Collator
7070
const SORT_STRING = 1;
7171

7272
/**
73-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
73+
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
7474
*
7575
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
7676
*/
@@ -84,7 +84,7 @@ public function __construct(?string $locale)
8484
/**
8585
* Static constructor.
8686
*
87-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
87+
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
8888
*
8989
* @return self
9090
*

Data/Bundle/Writer/TextBundleWriter.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Intl\Data\Bundle\Writer;
1313

14-
use Symfony\Component\Intl\Exception\UnexpectedTypeException;
15-
1614
/**
1715
* Writes .txt resource bundles.
1816
*
@@ -183,16 +181,9 @@ private function writeArray($file, array $value, int $indentation)
183181
* Writes a "table" node.
184182
*
185183
* @param resource $file The file handle to write to
186-
*
187-
* @throws UnexpectedTypeException when $value is not an array and not a
188-
* \Traversable instance
189184
*/
190185
private function writeTable($file, iterable $value, int $indentation, bool $fallback = true)
191186
{
192-
if (!\is_array($value) && !$value instanceof \Traversable) {
193-
throw new UnexpectedTypeException($value, 'array or \Traversable');
194-
}
195-
196187
if (!$fallback) {
197188
fwrite($file, ':table(nofallback)');
198189
}

Data/Generator/CurrencyDataGenerator.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ protected function generateDataForMeta(BundleEntryReaderInterface $reader, $temp
130130
return $data;
131131
}
132132

133-
/**
134-
* @return array
135-
*/
136-
private function generateSymbolNamePairs(ArrayAccessibleResourceBundle $rootBundle)
133+
private function generateSymbolNamePairs(ArrayAccessibleResourceBundle $rootBundle): array
137134
{
138135
$symbolNamePairs = iterator_to_array($rootBundle['Currencies']);
139136

@@ -143,14 +140,14 @@ private function generateSymbolNamePairs(ArrayAccessibleResourceBundle $rootBund
143140
return $symbolNamePairs;
144141
}
145142

146-
private function generateCurrencyMeta(ArrayAccessibleResourceBundle $supplementalDataBundle)
143+
private function generateCurrencyMeta(ArrayAccessibleResourceBundle $supplementalDataBundle): array
147144
{
148145
// The metadata is already de-duplicated. It contains one key "DEFAULT"
149146
// which is used for currencies that don't have dedicated entries.
150147
return iterator_to_array($supplementalDataBundle['CurrencyMeta']);
151148
}
152149

153-
private function generateAlpha3ToNumericMapping(ArrayAccessibleResourceBundle $numericCodesBundle, array $currencyCodes)
150+
private function generateAlpha3ToNumericMapping(ArrayAccessibleResourceBundle $numericCodesBundle, array $currencyCodes): array
154151
{
155152
$alpha3ToNumericMapping = iterator_to_array($numericCodesBundle['codeMap']);
156153

@@ -162,7 +159,7 @@ private function generateAlpha3ToNumericMapping(ArrayAccessibleResourceBundle $n
162159
return $alpha3ToNumericMapping;
163160
}
164161

165-
private function generateNumericToAlpha3Mapping(array $alpha3ToNumericMapping)
162+
private function generateNumericToAlpha3Mapping(array $alpha3ToNumericMapping): array
166163
{
167164
$numericToAlpha3Mapping = [];
168165

Data/Generator/LocaleDataGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ protected function generateDataForMeta(BundleEntryReaderInterface $reader, $temp
148148
];
149149
}
150150

151-
/**
152-
* @return string
153-
*/
154-
private function generateLocaleName(BundleEntryReaderInterface $reader, string $tempDir, string $locale, string $displayLocale, string $pattern, string $separator)
151+
private function generateLocaleName(BundleEntryReaderInterface $reader, string $tempDir, string $locale, string $displayLocale, string $pattern, string $separator): string
155152
{
156153
// Apply generic notation using square brackets as described per http://cldr.unicode.org/translation/language-names
157154
$name = str_replace(['(', ')'], ['[', ']'], $reader->readEntry($tempDir.'/lang', $displayLocale, ['Languages', \Locale::getPrimaryLanguage($locale)]));

DateFormatter/DateFormat/FullTransformer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,8 @@ protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
327327
/**
328328
* Add sensible default values for missing items in the extracted date/time options array. The values
329329
* are base in the beginning of the Unix era.
330-
*
331-
* @return array
332330
*/
333-
private function getDefaultValueForOptions(array $options)
331+
private function getDefaultValueForOptions(array $options): array
334332
{
335333
return [
336334
'year' => isset($options['year']) ? $options['year'] : 1970,

DateFormatter/IntlDateFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class IntlDateFormatter
118118
private $timeZoneId;
119119

120120
/**
121-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
121+
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
122122
* @param int|null $datetype Type of date formatting, one of the format type constants
123123
* @param int|null $timetype Type of time formatting, one of the format type constants
124124
* @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier
@@ -152,7 +152,7 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
152152
/**
153153
* Static constructor.
154154
*
155-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
155+
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
156156
* @param int|null $datetype Type of date formatting, one of the format type constants
157157
* @param int|null $timetype Type of time formatting, one of the format type constants
158158
* @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier

NumberFormatter/NumberFormatter.php

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ class NumberFormatter
241241
];
242242

243243
/**
244-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
245-
* @param int $style Style of the formatting, one of the format style constants.
246-
* The only supported styles are NumberFormatter::DECIMAL
247-
* and NumberFormatter::CURRENCY.
248-
* @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
249-
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
250-
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
244+
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
245+
* @param int $style Style of the formatting, one of the format style constants.
246+
* The only supported styles are NumberFormatter::DECIMAL
247+
* and NumberFormatter::CURRENCY.
248+
* @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
249+
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
250+
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
251251
*
252252
* @see http://www.php.net/manual/en/numberformatter.create.php
253253
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
@@ -672,12 +672,10 @@ protected function resetError()
672672
*
673673
* The only actual rounding data as of this writing, is CHF.
674674
*
675-
* @return float The rounded numeric currency value
676-
*
677675
* @see http://en.wikipedia.org/wiki/Swedish_rounding
678676
* @see http://www.docjar.com/html/api/com/ibm/icu/util/Currency.java.html#1007
679677
*/
680-
private function roundCurrency(float $value, string $currency)
678+
private function roundCurrency(float $value, string $currency): float
681679
{
682680
$fractionDigits = Currencies::getFractionDigits($currency);
683681
$roundingIncrement = Currencies::getRoundingIncrement($currency);
@@ -738,10 +736,8 @@ private function round($value, int $precision)
738736
* Formats a number.
739737
*
740738
* @param int|float $value The numeric value to format
741-
*
742-
* @return string The formatted number
743739
*/
744-
private function formatNumber($value, int $precision)
740+
private function formatNumber($value, int $precision): string
745741
{
746742
$precision = $this->getUninitializedPrecision($value, $precision);
747743

@@ -752,10 +748,8 @@ private function formatNumber($value, int $precision)
752748
* Returns the precision value if the DECIMAL style is being used and the FRACTION_DIGITS attribute is uninitialized.
753749
*
754750
* @param int|float $value The value to get the precision from if the FRACTION_DIGITS attribute is uninitialized
755-
*
756-
* @return int The precision value
757751
*/
758-
private function getUninitializedPrecision($value, int $precision)
752+
private function getUninitializedPrecision($value, int $precision): int
759753
{
760754
if (self::CURRENCY == $this->style) {
761755
return $precision;
@@ -773,10 +767,8 @@ private function getUninitializedPrecision($value, int $precision)
773767

774768
/**
775769
* Check if the attribute is initialized (value set by client code).
776-
*
777-
* @return bool true if the value was set by client, false otherwise
778770
*/
779-
private function isInitializedAttribute(string $attr)
771+
private function isInitializedAttribute(string $attr): bool
780772
{
781773
return isset($this->initializedAttributes[$attr]);
782774
}
@@ -835,10 +827,8 @@ private function getInt64Value($value)
835827

836828
/**
837829
* Check if the rounding mode is invalid.
838-
*
839-
* @return bool true if the rounding mode is invalid, false otherwise
840830
*/
841-
private function isInvalidRoundingMode(int $value)
831+
private function isInvalidRoundingMode(int $value): bool
842832
{
843833
if (\in_array($value, self::$roundingModes, true)) {
844834
return false;
@@ -850,20 +840,16 @@ private function isInvalidRoundingMode(int $value)
850840
/**
851841
* Returns the normalized value for the GROUPING_USED attribute. Any value that can be converted to int will be
852842
* cast to Boolean and then to int again. This way, negative values are converted to 1 and string values to 0.
853-
*
854-
* @return int The normalized value for the attribute (0 or 1)
855843
*/
856-
private function normalizeGroupingUsedValue($value)
844+
private function normalizeGroupingUsedValue($value): int
857845
{
858846
return (int) (bool) (int) $value;
859847
}
860848

861849
/**
862850
* Returns the normalized value for the FRACTION_DIGITS attribute.
863-
*
864-
* @return int The normalized value for the attribute
865851
*/
866-
private function normalizeFractionDigitsValue($value)
852+
private function normalizeFractionDigitsValue($value): int
867853
{
868854
return (int) $value;
869855
}

Tests/DateFormatter/IntlDateFormatterTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,8 @@ protected function isIntlFailure($errorCode)
207207
* Also in intl, format like 'ss E' for '10 2' (2nd day of year
208208
* + 10 seconds) are added, then we have 86,400 seconds (24h * 60min * 60s)
209209
* + 10 seconds
210-
*
211-
* @return array
212210
*/
213-
private function notImplemented(array $dataSets)
211+
private function notImplemented(array $dataSets): array
214212
{
215213
return array_map(function (array $row) {
216214
return [$row[0], $row[1], 0];

0 commit comments

Comments
 (0)