Skip to content

Commit 6a66c22

Browse files
Philippe Segatorinicolas-grekas
authored andcommitted
[Intl][5.0] Add parameters type-hints
1 parent 4d10ee0 commit 6a66c22

38 files changed

+155
-207
lines changed

Collator/Collator.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(?string $locale)
9090
*
9191
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
9292
*/
93-
public static function create($locale)
93+
public static function create(?string $locale)
9494
{
9595
return new self($locale);
9696
}
@@ -106,7 +106,7 @@ public static function create($locale)
106106
*
107107
* @return bool True on success or false on failure
108108
*/
109-
public function asort(&$array, $sortFlag = self::SORT_REGULAR)
109+
public function asort(array &$array, int $sortFlag = self::SORT_REGULAR)
110110
{
111111
$intlToPlainFlagMap = [
112112
self::SORT_REGULAR => \SORT_REGULAR,
@@ -134,7 +134,7 @@ public function asort(&$array, $sortFlag = self::SORT_REGULAR)
134134
*
135135
* @throws MethodNotImplementedException
136136
*/
137-
public function compare($str1, $str2)
137+
public function compare(string $str1, string $str2)
138138
{
139139
throw new MethodNotImplementedException(__METHOD__);
140140
}
@@ -150,7 +150,7 @@ public function compare($str1, $str2)
150150
*
151151
* @throws MethodNotImplementedException
152152
*/
153-
public function getAttribute($attr)
153+
public function getAttribute(int $attr)
154154
{
155155
throw new MethodNotImplementedException(__METHOD__);
156156
}
@@ -183,7 +183,7 @@ public function getErrorMessage()
183183
* @return string The locale used to create the collator. Currently always
184184
* returns "en".
185185
*/
186-
public function getLocale($type = Locale::ACTUAL_LOCALE)
186+
public function getLocale(int $type = Locale::ACTUAL_LOCALE)
187187
{
188188
return 'en';
189189
}
@@ -199,7 +199,7 @@ public function getLocale($type = Locale::ACTUAL_LOCALE)
199199
*
200200
* @throws MethodNotImplementedException
201201
*/
202-
public function getSortKey($string)
202+
public function getSortKey(string $string)
203203
{
204204
throw new MethodNotImplementedException(__METHOD__);
205205
}
@@ -230,7 +230,7 @@ public function getStrength()
230230
*
231231
* @throws MethodNotImplementedException
232232
*/
233-
public function setAttribute($attr, $val)
233+
public function setAttribute(int $attr, int $val)
234234
{
235235
throw new MethodNotImplementedException(__METHOD__);
236236
}
@@ -252,7 +252,7 @@ public function setAttribute($attr, $val)
252252
*
253253
* @throws MethodNotImplementedException
254254
*/
255-
public function setStrength($strength)
255+
public function setStrength(int $strength)
256256
{
257257
throw new MethodNotImplementedException(__METHOD__);
258258
}
@@ -268,7 +268,7 @@ public function setStrength($strength)
268268
*
269269
* @throws MethodNotImplementedException
270270
*/
271-
public function sortWithSortKeys(&$arr)
271+
public function sortWithSortKeys(array &$arr)
272272
{
273273
throw new MethodNotImplementedException(__METHOD__);
274274
}
@@ -288,7 +288,7 @@ public function sortWithSortKeys(&$arr)
288288
*
289289
* @throws MethodNotImplementedException
290290
*/
291-
public function sort(&$arr, $sortFlag = self::SORT_REGULAR)
291+
public function sort(array &$arr, int $sortFlag = self::SORT_REGULAR)
292292
{
293293
throw new MethodNotImplementedException(__METHOD__);
294294
}

Data/Bundle/Compiler/BundleCompilerInterface.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ interface BundleCompilerInterface
2323
/**
2424
* Compiles a resource bundle at the given source to the given target
2525
* directory.
26-
*
27-
* @param string $sourcePath
28-
* @param string $targetDir
2926
*/
30-
public function compile($sourcePath, $targetDir);
27+
public function compile(string $sourcePath, string $targetDir);
3128
}

Data/Bundle/Compiler/GenrbCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(string $genrb = 'genrb', string $envVars = '')
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function compile($sourcePath, $targetDir)
49+
public function compile(string $sourcePath, string $targetDir)
5050
{
5151
if (is_dir($sourcePath)) {
5252
$sourcePath .= '/*.txt';

Data/Bundle/Reader/BufferedBundleReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(BundleReaderInterface $reader, int $bufferSize)
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function read($path, $locale)
40+
public function read(string $path, string $locale)
4141
{
4242
$hash = $path.'//'.$locale;
4343

Data/Bundle/Reader/BundleEntryReader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,23 @@ public function __construct(BundleReaderInterface $reader)
5353
*
5454
* @param array $localeAliases A mapping of locale aliases to locales
5555
*/
56-
public function setLocaleAliases($localeAliases)
56+
public function setLocaleAliases(array $localeAliases)
5757
{
5858
$this->localeAliases = $localeAliases;
5959
}
6060

6161
/**
6262
* {@inheritdoc}
6363
*/
64-
public function read($path, $locale)
64+
public function read(string $path, string $locale)
6565
{
6666
return $this->reader->read($path, $locale);
6767
}
6868

6969
/**
7070
* {@inheritdoc}
7171
*/
72-
public function readEntry($path, $locale, array $indices, $fallback = true)
72+
public function readEntry(string $path, string $locale, array $indices, bool $fallback = true)
7373
{
7474
$entry = null;
7575
$isMultiValued = false;

Data/Bundle/Reader/BundleEntryReaderInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ interface BundleEntryReaderInterface extends BundleReaderInterface
3838
* $reader->readEntry('...', 'en', ['TopLevel', 'NestedLevel', 'Entry']);
3939
*
4040
* @param string $path The path to the resource bundle
41-
* @param string $locale The locale to read
4241
* @param string[] $indices The indices to read from the bundle
4342
* @param bool $fallback Whether to merge the value with the value from
4443
* the fallback locale (e.g. "en" for "en_GB").
@@ -51,5 +50,5 @@ interface BundleEntryReaderInterface extends BundleReaderInterface
5150
*
5251
* @throws MissingResourceException If the indices cannot be accessed
5352
*/
54-
public function readEntry($path, $locale, array $indices, $fallback = true);
53+
public function readEntry(string $path, string $locale, array $indices, bool $fallback = true);
5554
}

Data/Bundle/Reader/BundleReaderInterface.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121
interface BundleReaderInterface
2222
{
2323
/**
24-
* Reads a resource bundle.
25-
*
26-
* @param string $path The path to the resource bundle
27-
* @param string $locale The locale to read
28-
*
2924
* @return mixed returns an array or {@link \ArrayAccess} instance for
3025
* complex data, a scalar value otherwise
3126
*/
32-
public function read($path, $locale);
27+
public function read(string $path, string $locale);
3328
}

Data/Bundle/Reader/IntlBundleReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IntlBundleReader implements BundleReaderInterface
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function read($path, $locale)
29+
public function read(string $path, string $locale)
3030
{
3131
// Point for future extension: Modify this class so that it works also
3232
// if the \ResourceBundle class is not available.

Data/Bundle/Reader/JsonBundleReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class JsonBundleReader implements BundleReaderInterface
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function read($path, $locale)
29+
public function read(string $path, string $locale)
3030
{
3131
$fileName = $path.'/'.$locale.'.json';
3232

Data/Bundle/Reader/PhpBundleReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PhpBundleReader implements BundleReaderInterface
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function read($path, $locale)
29+
public function read(string $path, string $locale)
3030
{
3131
$fileName = $path.'/'.$locale.'.php';
3232

0 commit comments

Comments
 (0)