bug #29344 Fixes sprintf(): Too few arguments in Translator (stephanedelprat)

This PR was submitted for the master branch but it was merged into the 4.2 branch instead (closes #29344).

Discussion
----------

Fixes sprintf(): Too few arguments in Translator

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | related to a previous deprecation <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | ?
| Fixed tickets | none
| License       | MIT
| Doc PR        | none

Fixes the log produced when the method is called :

Before : "sprintf(): Too few arguments"

After : "The "Symfony\Component\Translation\Translator::transChoice()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%count%" parameter."

Reference : http://php.net/manual/function.sprintf.php

Commits
-------

45c3de044e Fixes sprintf(): Too few arguments in Translator
This commit is contained in:
Nicolas Grekas 2018-11-27 08:20:38 +01:00
commit 12e1c9b9e5
1 changed files with 1 additions and 1 deletions

View File

@ -226,7 +226,7 @@ class Translator implements LegacyTranslatorInterface, TranslatorInterface, Tran
*/
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%count%" parameter.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);
if (!$this->formatter instanceof ChoiceMessageFormatterInterface) {
throw new LogicException(sprintf('The formatter "%s" does not support plural translations.', \get_class($this->formatter)));