55use Symfony \Contracts \Translation \LocaleAwareInterface ;
66use Symfony \Contracts \Translation \TranslatorInterface ;
77use Webfactory \IcuTranslationBundle \Translator \Formatting \FormatterInterface ;
8- use Webfactory \IcuTranslationBundle \Translator \Formatting \IntlFormatter ;
98
109/**
1110 * Decorates a Symfony translator and adds support for message formatting.
@@ -15,16 +14,14 @@ class FormatterDecorator implements TranslatorInterface, LocaleAwareInterface
1514 /**
1615 * The inner translator.
1716 *
18- * @var TranslatorInterface
17+ * @var TranslatorInterface&LocaleAwareInterface
1918 */
20- protected $ translator ;
19+ protected TranslatorInterface $ translator ;
2120
2221 /**
2322 * The formatter that is used to apply message transformations.
24- *
25- * @var IntlFormatter
2623 */
27- protected $ formatter ;
24+ protected FormatterInterface $ formatter ;
2825
2926 public function __construct (TranslatorInterface $ translator , FormatterInterface $ formatter )
3027 {
@@ -36,27 +33,14 @@ public function __construct(TranslatorInterface $translator, FormatterInterface
3633 $ this ->formatter = $ formatter ;
3734 }
3835
39- /**
40- * Translates the given message.
41- *
42- * @param string $id The message id
43- * @param array $parameters An array of parameters for the message
44- * @param string $domain The domain for the message
45- * @param string $locale The locale
46- */
47- public function trans ($ id , array $ parameters = [], $ domain = null , $ locale = null ): string
36+ public function trans (string $ id , array $ parameters = [], string $ domain = null , string $ locale = null ): string
4837 {
4938 $ message = $ this ->translator ->trans ($ id , $ parameters , $ domain , $ locale );
5039
5140 return $ this ->handleFormatting ($ id , $ message , $ parameters , $ locale );
5241 }
5342
54- /**
55- * Sets the current locale.
56- *
57- * @param string $locale The locale
58- */
59- public function setLocale ($ locale )
43+ public function setLocale (string $ locale ): void
6044 {
6145 $ this ->translator ->setLocale ($ locale );
6246 }
0 commit comments