upgraded dependencies
This commit is contained in:
@@ -12,8 +12,6 @@
|
||||
namespace Symfony\Component\Translation\Formatter;
|
||||
|
||||
use Symfony\Component\Translation\IdentityTranslator;
|
||||
use Symfony\Component\Translation\MessageSelector;
|
||||
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
@@ -22,7 +20,7 @@ class_exists(IntlFormatter::class);
|
||||
/**
|
||||
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
|
||||
*/
|
||||
class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterface, ChoiceMessageFormatterInterface
|
||||
class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterface
|
||||
{
|
||||
private $translator;
|
||||
private $intlFormatter;
|
||||
@@ -30,14 +28,8 @@ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterf
|
||||
/**
|
||||
* @param TranslatorInterface|null $translator An identity translator to use as selector for pluralization
|
||||
*/
|
||||
public function __construct($translator = null, IntlFormatterInterface $intlFormatter = null)
|
||||
public function __construct(TranslatorInterface $translator = null, IntlFormatterInterface $intlFormatter = null)
|
||||
{
|
||||
if ($translator instanceof MessageSelector) {
|
||||
$translator = new IdentityTranslator($translator);
|
||||
} elseif (null !== $translator && !$translator instanceof TranslatorInterface && !$translator instanceof LegacyTranslatorInterface) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be an instance of "%s", "%s" given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
|
||||
}
|
||||
|
||||
$this->translator = $translator ?? new IdentityTranslator();
|
||||
$this->intlFormatter = $intlFormatter ?? new IntlFormatter();
|
||||
}
|
||||
@@ -45,7 +37,7 @@ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterf
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format($message, $locale, array $parameters = [])
|
||||
public function format(string $message, string $locale, array $parameters = [])
|
||||
{
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
return $this->translator->trans($message, $parameters, null, $locale);
|
||||
@@ -61,22 +53,4 @@ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterf
|
||||
{
|
||||
return $this->intlFormatter->formatIntl($message, $locale, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated since Symfony 4.2, use format() with a %count% parameter instead
|
||||
*/
|
||||
public function choiceFormat($message, $number, $locale, array $parameters = [])
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the format() one instead with a %%count%% parameter.', __METHOD__), \E_USER_DEPRECATED);
|
||||
|
||||
$parameters = ['%count%' => $number] + $parameters;
|
||||
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
return $this->format($message, $locale, $parameters);
|
||||
}
|
||||
|
||||
return $this->format($this->translator->transChoice($message, $number, [], null, $locale), $locale, $parameters);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user