某个 TranslatorInterface::setLocale ($locale) not compatible

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

Symfony\Component\Translation\TranslatorInterface 是在 symfony/translation 包里,依赖的
Symfony\Contracts\Translation\LocaleAwareInterface 是在 symfony/translation-contracts 包里,版本设置的是: "symfony/translation-contracts": "^1.1.6|^2"

参数类型限制是 2.0 加的,不知道为啥继承的却不改,用意何在?!

这个在 PHP 7.1 及以下都有问题,详情见此:

3v4l.org/WQhqq#output

相关讨论及解决方法可参考:

github.com/symfony/symfony/issues/...
laracasts.com/discuss/channels/lar...

我目前选择的是在项目里安装指定版本: “symfony/translation-contracts”: “^1.1.7”,

本作品采用《CC 协议》,转载必须注明作者和本文链接
? 我的导航网站已经可以公开使用啦:Cootab
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

我也遇到同样问题了. www.freesion.com/article/357027927...
这个方法能暂时应急下.

3年前 评论
chuoke (楼主) 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!