Skip to content

Commit f8599ac

Browse files
committed
Turned return type annotations of private methods into php return types.
1 parent f6ec04c commit f8599ac

File tree

6 files changed

+15
-41
lines changed

6 files changed

+15
-41
lines changed

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,

Intl.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,8 @@ public static function getDataDirectory()
271271

272272
/**
273273
* Returns the cached bundle entry reader.
274-
*
275-
* @return BundleEntryReaderInterface The bundle entry reader
276274
*/
277-
private static function getEntryReader()
275+
private static function getEntryReader(): BundleEntryReaderInterface
278276
{
279277
if (null === self::$entryReader) {
280278
self::$entryReader = new BundleEntryReader(new BufferedBundleReader(

NumberFormatter/NumberFormatter.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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)