Twig 扩展似乎导致尝试加载不存在的缓存文件

Twig extension seems to cause attempt to load non existent cache file

我有一个基于 silex 的站点的树枝扩展:

<?php
namespace UT\Provider;

/**
 * Twig extension for containing any additional twig functions we need
 */
class TwigUTProvider extends \Twig_Extension {

    public function getName() {
        return 'ut_functions';
    }

    public function getFunctions() {
        return [
            new \Twig_SimpleFunction("maybeDecodeJapanse", [$this, \UT\Provider\TwigUTProvider::maybeDecodeJapanse()]),
        ];
    }

    public function maybeDecodeJapanse() {
        return 'a string';
    }
}

在应用文件中这样注册的:

$this->register(new Provider\TwigServiceProvider, [
            'twig.path' => [
                __DIR__ . '/Resources/Templates',
                $this['docroot'] . '/silex/vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Resources/views/Form',
                __DIR__ . '/../Floso/Templates',
            ],
            'twig.options' => [
                'auto_reload' => true,
                'cache' => $this['debug_mode'] ? false : ($this['docroot'] . '/silex/var/cache/twig'),
                'debug' => $this['debug_mode'],
            ],
        ]);

        # Add Twig extensions
        $this['twig'] = $this->share($this->extend('twig', function ($twig) {
            $twig->addExtension(new \UT\Provider\TwigUTProvider());
            $twig->addExtension(new BootstrapBundle\Twig\BootstrapIconExtension('glyphicon'));
            $twig->addExtension(new BootstrapBundle\Twig\BootstrapLabelExtension);
            $twig->addExtension(new BootstrapBundle\Twig\BootstrapBadgeExtension);
            $twig->addExtension(new BootstrapBundle\Twig\BootstrapFormExtension);
            $twig->addExtension(new \Twig_Extension_StringLoader());

            $twig->getExtension('core')->setTimezone('Europe/London');

            return $twig;
        }));

这似乎是正确的 - 在扩展 class 名称中引入拼写错误会导致与我遇到的那个不同的异常。

我在我的 twig 模板中用 {{ maybeDecodeJapanese() }} 调用这个扩展,这导致了这个异常(它似乎不是由模板调用本身引起的,拼写错误会生成一个标准函数未找到异常):

Class '__TwigTemplate_3318c38dfd9c3eb0c4193184a517ff94fdd975ffb45d7f0a8f7490718f3bc1ef' not found

这发生在 /silex/vendor/twig/twig/lib/Twig/Environment。php

我最好的猜测是这是某种缓存文件。缓存在开发环境中被禁用,但我已经尝试删除缓存文件夹内容,但没有帮助。谷歌搜索尚未提供任何其他线索。

找到问题根源的任何帮助都将非常有帮助。

我认为函数定义有误。尝试将其更改为:

...new \Twig_SimpleFunction("maybeDecodeJapanse", [$this, "maybeDecodeJapanse"]),...