Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82d1c91

Browse files
committed
[Translator] mention that the message id may also be an object that can be cast to string in TranslatorInterface and fix the IdentityTranslator that did not respect this
1 parent 7fc2f59 commit 82d1c91

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

IdentityTranslator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getLocale()
5959
*/
6060
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
6161
{
62-
return strtr($id, $parameters);
62+
return strtr((string) $id, $parameters);
6363
}
6464

6565
/**
@@ -69,6 +69,6 @@ public function trans($id, array $parameters = array(), $domain = 'messages', $l
6969
*/
7070
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
7171
{
72-
return strtr($this->selector->choose($id, (int) $number, $locale), $parameters);
72+
return strtr($this->selector->choose((string) $id, (int) $number, $locale), $parameters);
7373
}
7474
}

TranslatorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface TranslatorInterface
2323
/**
2424
* Translates the given message.
2525
*
26-
* @param string $id The message id
26+
* @param string $id The message id (may also be an object that can be cast to string)
2727
* @param array $parameters An array of parameters for the message
2828
* @param string $domain The domain for the message
2929
* @param string $locale The locale
@@ -37,7 +37,7 @@ public function trans($id, array $parameters = array(), $domain = null, $locale
3737
/**
3838
* Translates the given choice message by choosing a translation according to a number.
3939
*
40-
* @param string $id The message id
40+
* @param string $id The message id (may also be an object that can be cast to string)
4141
* @param integer $number The number to use to find the indice of the message
4242
* @param array $parameters An array of parameters for the message
4343
* @param string $domain The domain for the message

0 commit comments

Comments
 (0)