php - symfony 更新 2.6 到 3.4 后奏鸣曲/树枝错误
问题描述
我将一个项目从 sf2.6(php5.6) 更新到 sf3.4(php7.1) ......它进展顺利,但现在我遇到了一个错误,我无法弄清楚如何修复它
错误输出:
PHP message: PHP Fatal error: Uncaught Symfony\\Component\\Debug\\Exception\\FatalThrowableError: Type error: Argument 2 passed to Sonata\\FormatterBundle\\Formatter\\Pool::add() must implement interface Sonata\\FormatterBundle\\Formatter\\FormatterInterface, boolean given, called in /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php on line 4924 in /var/www/vendor/sonata-project/formatter-bundle/src/Formatter/Pool.php:43\nStack trace:\n#0 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(4924): Sonata\\FormatterBundle\\Formatter\\Pool->add('twig', true, NULL)\n#1 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(3475): ContainerMklcxqq\\appDevDebugProjectContainer->getSonata_Formatter_PoolService()\n#2 /var/www/var/cache/dev/ContainerMklcxqq/getAssetic_AssetManagerService.php(8): ContainerMklcxqq\\appDevDebugProjectContainer->getTwigService()\n#3 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(1349): require('/var/www/var/ca...')\n#4 /v...\n'
如果我检查容器中提到的行(4924),我会发现:
$instance->add('twig', ${($_ = isset($this- >services['sonata.formatter.text.twigengine']) ? $this-
>services['sonata.formatter.text.twigengine'] : $this-
>getSonata_Formatter_Text_TwigengineService()) && false ?: '_'}, NULL);
当我使用“bin/console debug:container sonata.formatter.text.twigengine”检查实际服务时,我得到以下信息,这很好,我猜:
Information for Service "sonata.formatter.text.twigengine"
==========================================================
---------------- ------------------------------------------------
Option Value
---------------- ------------------------------------------------
Service ID sonata.formatter.text.twigengine
Class Sonata\FormatterBundle\Formatter\TwigFormatter
Tags sonata.text.formatter
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
---------------- ------------------------------------------------
最后我检查了实际的 TwigFormatter 类,这导致了这篇文章:
final class TwigFormatter implements FormatterInterface
这个错误怎么可能发生,我应该解决这个问题还是需要任何包更新?我正在使用最新版本的奏鸣曲项目/格式化程序捆绑包以及最新版本的树枝/树枝。
非常感谢帮助和解释。多谢你们。
解决方案
此错误来自 Symfony,请参阅BUG:FormatterBundle\Formatter\Pool::add() must implement interface then [DI] Error on dumped container for inlined services
您必须等待此修复被合并,或者如果您是玩家,请自行应用。
推荐阅读
- mysql - Sql Query 从混合数据中获取唯一值
- javascript - 如何使用 Google Apps 脚本将平面 JSON 数组转换为嵌套 JSON?
- python - 注销反向 url 不适用于下一页
- python - Selenium Python:无法在 Google Hangouts 上获取聊天元素的路径
- c++ - 为什么在 C++ 中的 get() 之前使用 getchar() 函数?
- python - 如何返回所有正则表达式的结果?我需要从“描述”和“产品”返回所有安卓手机的结果
- ios - 完成后如何重新启动 CABasicAnimation
- django - 根据Django中的模型动态创建URL
- javascript - 具有多个选项和链接的打字稿枚举参数
- python - 遍历列表 - 制作列表