首页 > 解决方案 > 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

这个错误怎么可能发生,我应该解决这个问题还是需要任何包更新?我正在使用最新版本的奏鸣曲项目/格式化程序捆绑包以及最新版本的树枝/树枝。

非常感谢帮助和解释。多谢你们。

标签: phpsymfonyinterfacetwigsonata

解决方案


此错误来自 Symfony,请参阅BUG:FormatterBundle\Formatter\Pool::add() must implement interface then [DI] Error on dumped container for inlined services

您必须等待此修复被合并,或者如果您是玩家,请自行应用。


推荐阅读