Skip to content

Commit 8feb81e

Browse files
derrabusnicolas-grekas
authored andcommitted
Add parameter type declarations to contracts.
1 parent 364518c commit 8feb81e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

LocaleAwareInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface LocaleAwareInterface
2020
*
2121
* @throws \InvalidArgumentException If the locale contains invalid characters
2222
*/
23-
public function setLocale($locale);
23+
public function setLocale(string $locale);
2424

2525
/**
2626
* Returns the current locale.

TranslatorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ interface TranslatorInterface
6161
*
6262
* @throws \InvalidArgumentException If the locale contains invalid characters
6363
*/
64-
public function trans($id, array $parameters = [], $domain = null, $locale = null);
64+
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null);
6565
}

TranslatorTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ trait TranslatorTrait
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function setLocale($locale)
28+
public function setLocale(string $locale)
2929
{
30-
$this->locale = (string) $locale;
30+
$this->locale = $locale;
3131
}
3232

3333
/**
@@ -41,9 +41,9 @@ public function getLocale()
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
public function trans($id, array $parameters = [], $domain = null, $locale = null)
44+
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
4545
{
46-
if ('' === $id = (string) $id) {
46+
if (null === $id || '' === $id) {
4747
return '';
4848
}
4949

@@ -52,7 +52,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
5252
}
5353

5454
$number = (float) $parameters['%count%'];
55-
$locale = (string) $locale ?: $this->getLocale();
55+
$locale = $locale ?: $this->getLocale();
5656

5757
$parts = [];
5858
if (preg_match('/^\|++$/', $id)) {

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.1.3"
19+
"php": "^7.2.9"
2020
},
2121
"suggest": {
2222
"symfony/translation-implementation": ""
@@ -27,7 +27,7 @@
2727
"minimum-stability": "dev",
2828
"extra": {
2929
"branch-alias": {
30-
"dev-master": "1.1-dev"
30+
"dev-master": "2.0-dev"
3131
}
3232
}
3333
}

0 commit comments

Comments
 (0)