Skip to content

Commit f45a3fd

Browse files
Add return types to internal|final|private methods
1 parent 5de91fa commit f45a3fd

12 files changed

+42
-76
lines changed

Data/Generator/AbstractDataGenerator.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,17 @@ public function generateData(GeneratorConfig $config)
9191
}
9292

9393
/**
94-
* @param string $sourceDir
95-
*
9694
* @return string[]
9795
*/
98-
abstract protected function scanLocales(LocaleScanner $scanner, $sourceDir);
96+
abstract protected function scanLocales(LocaleScanner $scanner, string $sourceDir): array;
9997

100-
/**
101-
* @param string $sourceDir
102-
* @param string $tempDir
103-
*/
104-
abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $sourceDir, $tempDir);
98+
abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, string $sourceDir, string $tempDir);
10599

106100
abstract protected function preGenerate();
107101

108-
/**
109-
* @param string $tempDir
110-
* @param string $displayLocale
111-
*
112-
* @return array|null
113-
*/
114-
abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale);
102+
abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array;
115103

116-
/**
117-
* @param string $tempDir
118-
*
119-
* @return array|null
120-
*/
121-
abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir);
104+
abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array;
122105

123-
/**
124-
* @param string $tempDir
125-
*
126-
* @return array|null
127-
*/
128-
abstract protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir);
106+
abstract protected function generateDataForMeta(BundleEntryReaderInterface $reader, string $tempDir): ?array;
129107
}

Data/Generator/CurrencyDataGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class CurrencyDataGenerator extends AbstractDataGenerator
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
protected function scanLocales(LocaleScanner $scanner, $sourceDir)
54+
protected function scanLocales(LocaleScanner $scanner, $sourceDir): array
5555
{
5656
return $scanner->scanLocales($sourceDir.'/curr');
5757
}
@@ -76,7 +76,7 @@ protected function preGenerate()
7676
/**
7777
* {@inheritdoc}
7878
*/
79-
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
79+
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array
8080
{
8181
$localeBundle = $reader->read($tempDir, $displayLocale);
8282

@@ -97,7 +97,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
9797
/**
9898
* {@inheritdoc}
9999
*/
100-
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
100+
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array
101101
{
102102
$rootBundle = $reader->read($tempDir, 'root');
103103

@@ -110,7 +110,7 @@ protected function generateDataForRoot(BundleEntryReaderInterface $reader, $temp
110110
/**
111111
* {@inheritdoc}
112112
*/
113-
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
113+
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array
114114
{
115115
$rootBundle = $reader->read($tempDir, 'root');
116116
$supplementalDataBundle = $reader->read($tempDir, 'supplementalData');

Data/Generator/GeneratorConfig.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ public function __construct(string $sourceDir, string $icuVersion)
3838

3939
/**
4040
* Adds a writer to be used during the data conversion.
41-
*
42-
* @param string $targetDir The output directory
4341
*/
44-
public function addBundleWriter($targetDir, BundleWriterInterface $writer)
42+
public function addBundleWriter(string $targetDir, BundleWriterInterface $writer)
4543
{
4644
$this->bundleWriters[$targetDir] = $writer;
4745
}
@@ -51,7 +49,7 @@ public function addBundleWriter($targetDir, BundleWriterInterface $writer)
5149
*
5250
* @return BundleWriterInterface[]
5351
*/
54-
public function getBundleWriters()
52+
public function getBundleWriters(): array
5553
{
5654
return $this->bundleWriters;
5755
}
@@ -62,7 +60,7 @@ public function getBundleWriters()
6260
*
6361
* @return string An absolute path to a directory
6462
*/
65-
public function getSourceDir()
63+
public function getSourceDir(): string
6664
{
6765
return $this->sourceDir;
6866
}
@@ -72,7 +70,7 @@ public function getSourceDir()
7270
*
7371
* @return string The ICU version string
7472
*/
75-
public function getIcuVersion()
73+
public function getIcuVersion(): string
7674
{
7775
return $this->icuVersion;
7876
}

Data/Generator/LanguageDataGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class LanguageDataGenerator extends AbstractDataGenerator
101101
/**
102102
* {@inheritdoc}
103103
*/
104-
protected function scanLocales(LocaleScanner $scanner, $sourceDir)
104+
protected function scanLocales(LocaleScanner $scanner, $sourceDir): array
105105
{
106106
return $scanner->scanLocales($sourceDir.'/lang');
107107
}
@@ -126,7 +126,7 @@ protected function preGenerate()
126126
/**
127127
* {@inheritdoc}
128128
*/
129-
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
129+
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array
130130
{
131131
$localeBundle = $reader->read($tempDir, $displayLocale);
132132

@@ -148,14 +148,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
148148
/**
149149
* {@inheritdoc}
150150
*/
151-
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
151+
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array
152152
{
153153
}
154154

155155
/**
156156
* {@inheritdoc}
157157
*/
158-
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
158+
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array
159159
{
160160
$rootBundle = $reader->read($tempDir, 'root');
161161
$metadataBundle = $reader->read($tempDir, 'metadata');

Data/Generator/LocaleDataGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class LocaleDataGenerator extends AbstractDataGenerator
3636
/**
3737
* {@inheritdoc}
3838
*/
39-
protected function scanLocales(LocaleScanner $scanner, $sourceDir)
39+
protected function scanLocales(LocaleScanner $scanner, $sourceDir): array
4040
{
4141
$this->locales = $scanner->scanLocales($sourceDir.'/locales');
4242
$this->localeAliases = $scanner->scanAliases($sourceDir.'/locales');
@@ -74,7 +74,7 @@ protected function preGenerate()
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
77+
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array
7878
{
7979
// Don't generate aliases, as they are resolved during runtime
8080
// Unless an alias is needed as fallback for de-duplication purposes
@@ -133,14 +133,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
133133
/**
134134
* {@inheritdoc}
135135
*/
136-
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
136+
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array
137137
{
138138
}
139139

140140
/**
141141
* {@inheritdoc}
142142
*/
143-
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
143+
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array
144144
{
145145
return [
146146
'Locales' => $this->locales,

Data/Generator/RegionDataGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static function isValidCountryCode($region)
8484
/**
8585
* {@inheritdoc}
8686
*/
87-
protected function scanLocales(LocaleScanner $scanner, $sourceDir)
87+
protected function scanLocales(LocaleScanner $scanner, $sourceDir): array
8888
{
8989
return $scanner->scanLocales($sourceDir.'/region');
9090
}
@@ -109,7 +109,7 @@ protected function preGenerate()
109109
/**
110110
* {@inheritdoc}
111111
*/
112-
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
112+
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array
113113
{
114114
$localeBundle = $reader->read($tempDir, $displayLocale);
115115

@@ -131,14 +131,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
131131
/**
132132
* {@inheritdoc}
133133
*/
134-
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
134+
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array
135135
{
136136
}
137137

138138
/**
139139
* {@inheritdoc}
140140
*/
141-
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
141+
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array
142142
{
143143
$rootBundle = $reader->read($tempDir, 'root');
144144
$metadataBundle = $reader->read($tempDir, 'metadata');

Data/Generator/ScriptDataGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ScriptDataGenerator extends AbstractDataGenerator
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
protected function scanLocales(LocaleScanner $scanner, $sourceDir)
41+
protected function scanLocales(LocaleScanner $scanner, $sourceDir): array
4242
{
4343
return $scanner->scanLocales($sourceDir.'/lang');
4444
}
@@ -62,7 +62,7 @@ protected function preGenerate()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
65+
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array
6666
{
6767
$localeBundle = $reader->read($tempDir, $displayLocale);
6868

@@ -84,14 +84,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
8484
/**
8585
* {@inheritdoc}
8686
*/
87-
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
87+
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array
8888
{
8989
}
9090

9191
/**
9292
* {@inheritdoc}
9393
*/
94-
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
94+
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array
9595
{
9696
$rootBundle = $reader->read($tempDir, 'root');
9797

Data/Generator/TimezoneDataGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TimezoneDataGenerator extends AbstractDataGenerator
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
protected function scanLocales(LocaleScanner $scanner, $sourceDir)
45+
protected function scanLocales(LocaleScanner $scanner, $sourceDir): array
4646
{
4747
$this->localeAliases = $scanner->scanAliases($sourceDir.'/locales');
4848

@@ -75,7 +75,7 @@ protected function preGenerate()
7575
/**
7676
* {@inheritdoc}
7777
*/
78-
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
78+
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array
7979
{
8080
if (!$this->zoneToCountryMapping) {
8181
$this->zoneToCountryMapping = self::generateZoneToCountryMapping($reader->read($tempDir, 'windowsZones'));
@@ -126,7 +126,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
126126
/**
127127
* {@inheritdoc}
128128
*/
129-
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
129+
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array
130130
{
131131
$rootBundle = $reader->read($tempDir, 'root');
132132

@@ -139,7 +139,7 @@ protected function generateDataForRoot(BundleEntryReaderInterface $reader, $temp
139139
/**
140140
* {@inheritdoc}
141141
*/
142-
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
142+
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array
143143
{
144144
$rootBundle = $reader->read($tempDir, 'root');
145145

Data/Util/LocaleScanner.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ class LocaleScanner
3333
/**
3434
* Returns all locales found in the given directory.
3535
*
36-
* @param string $sourceDir The directory with ICU files
37-
*
3836
* @return array An array of locales. The result also contains locales that
3937
* are in fact just aliases for other locales. Use
4038
* {@link scanAliases()} to determine which of the locales
4139
* are aliases
4240
*/
43-
public function scanLocales($sourceDir)
41+
public function scanLocales(string $sourceDir): array
4442
{
4543
$locales = glob($sourceDir.'/*.txt');
4644

@@ -60,12 +58,10 @@ public function scanLocales($sourceDir)
6058
/**
6159
* Returns all locale aliases found in the given directory.
6260
*
63-
* @param string $sourceDir The directory with ICU files
64-
*
6561
* @return array An array with the locale aliases as keys and the aliased
6662
* locales as values
6763
*/
68-
public function scanAliases($sourceDir)
64+
public function scanAliases(string $sourceDir): array
6965
{
7066
$locales = $this->scanLocales($sourceDir);
7167
$aliases = [];

DateFormatter/DateFormat/FullTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct(string $pattern, string $timezone)
7474
*
7575
* @return string The formatted value
7676
*/
77-
public function format(\DateTime $dateTime)
77+
public function format(\DateTime $dateTime): string
7878
{
7979
$formatted = preg_replace_callback($this->regExp, function ($matches) use ($dateTime) {
8080
return $this->formatReplace($matches[0], $dateTime);
@@ -120,7 +120,7 @@ private function formatReplace(string $dateChars, \DateTime $dateTime): string
120120
*
121121
* @throws \InvalidArgumentException When the value can not be matched with pattern
122122
*/
123-
public function parse(\DateTime $dateTime, $value)
123+
public function parse(\DateTime $dateTime, string $value)
124124
{
125125
$reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
126126
$reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';

0 commit comments

Comments
 (0)