Symfony 4.4 翻译界面问题

Symfony 4.4 Translation interface problem

最近将应用程序从 Symfony 4.3 升级到 4.4,在生产中我遇到了 Symfony Translator 界面的问题

配置:

framework:
default_locale: pl
translator:
    default_path: '%kernel.project_dir%/translations'

错误:

Fatal error: Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) in ./vendor/symfony/translation/TranslatorInterface.php on line 24
Fatal error: Declaration of Symfony\Component\Translation\Translator::trans($id, array $parameters = Array, $domain = NULL, $locale = NULL) must be compatible with Symfony\Contracts\Translation\TranslatorInterface::trans(string $id, array $parameters = Array, ?string $domain = NULL, ?string $locale = NULL) in ./vendor/symfony/translation/Translator.php on line 32

我发现降级到 symfony:translation-contracts:1.1.6 对我有用。
Composer 自动安装了此软件包的 2.0.0 版本,它使用了类型提示。
1.1.6 版本不兼容 Translator class 再次兼容。
它不使用类型提示。

在我的 composer.json 文件中,我将版本固定为 1.1.6:

"require": {
        "php": ">=7.3",
        "symfony/translation": "^4.4",
        "symfony/translation-contracts": "1.1.6"
}

P.S。还有更多的依赖关系,但为了便于阅读我省略了它们