從2.3更新symfony 2.7後,我得到了許多棄用警告消息,我沒有找到解決該問題的鏈接。如何解決棄用的Twig_Function,Twig_Function_Method,Twig_Function_Node
我得到的警告消息:
DEPRECATED - The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead. -
Called from require() at line 154
Called from DebugClassLoader::loadClass()
Called from spl_autoload_call() at line 25
Called from require() at line 154
Called from DebugClassLoader::loadClass()
Called from spl_autoload_call() at line 22
Called from MenuExtension::getFunctions() at line 1282
Called from Twig_Environment::initExtension() at line 1263
Called from Twig_Environment::initExtensions() at line 1196
Called from Twig_Environment::getUnaryOperators() at line 371
Called from Twig_Lexer::getOperatorRegex() at line 65
Called from Twig_Lexer::__construct() at line 529
Called from Twig_Environment::getLexer() at line 557
Called from Twig_Environment::tokenize() at line 647
Called from Twig_Environment::compileSource() at line 382
Called from Twig_Environment::loadTemplate() at line 126
Called from TwigEngine::load() at line 50
Called from TwigEngine::render() at line 72
Called from TwigEngine::render() at line 97
Called from TwigEngine::renderResponse() at line 176
Called from Controller::render() at line 65
Called from DefaultController::indexAction()
Called from call_user_func_array() at line 3109
Called from HttpKernel::handleRaw() at line 3071
Called from HttpKernel::handle() at line 3222
Called from ContainerAwareHttpKernel::handle() at line 2444
Called from Kernel::handle() at line 34
爲了您的信息,這是我使用的樹枝版本:
php composer.phar show -i | grep twig
twig/extensions v1.0.1 Common additional features for Twig that do not directly belong in core
twig/twig v1.22.1 Twig, the flexible, fast, and secure template language for PHP
NB。在我看來,不贊成來自我安裝的一些軟件包使用一些不推薦使用的功能。所以,下面是composer.json文件,以防萬一。
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "v2.0.0-alpha3",
"lunetics/locale-bundle": "v2.4.2",
"stof/doctrine-extensions-bundle": "1.2.*@dev",
"knplabs/knp-menu": "2.0.*@dev",
"knplabs/knp-menu-bundle": "2.0.*@dev",
"coresphere/console-bundle": "0.3.0",
"knplabs/knp-markdown-bundle": "1.4.*@dev",
"lunetics/timezone-bundle": "dev-master",
"knplabs/knp-time-bundle": "1.4.0",
"a2lix/translation-form-bundle": "1.*@dev",
"knplabs/doctrine-behaviors": "1.2.*@dev",
"genemu/form-bundle": "2.2.*@dev",
"friendsofsymfony/jsrouting-bundle": "@stable",
"willdurand/geocoder": "@stable",
"misd/guzzle-bundle": "1.1.*@dev",
"friendsofsymfony/rest-bundle": "1.4.*@dev",
"jms/serializer-bundle": "0.13.*@dev",
"imagine/imagine": "0.5.*@dev",
"liip/imagine-bundle": "1.0.*@dev",
"nelmio/api-doc-bundle": "@stable",
"hwi/oauth-bundle": "0.4.*@dev",
"friendsofsymfony/facebook-bundle": "dev-master",
"willdurand/geocoder-bundle": "3.0.*@dev",
"google/apiclient": "1.0.*@dev",
"vich/uploader-bundle": "0.10.0",
"nomaya/social-bundle": "1.0.*@dev",
"jms/i18n-routing-bundle": "dev-master"
}
NB。我有類似的警告訊息Twig_Function_Method
,Twig_Function_Node
,...
NB。這link告訴我們,有貶低,但沒有指定如何解決它們。
你既可以改變它們或composer.json不更新到具有它們貶值的最新版本的樹枝。 –
**首先**關於作曲家,我已經將我的軟件包更新爲未經修改的版本。這意味着它可以捆綁一些*(甚至它們是最新版本)*使用一些不贊成使用的樹枝方法。 ** SECOND **棄用警告不告訴我在哪裏尋找錯誤(這是修復的文件??)。 –
如果您的應用程序包含任何自定義開發的「Twig」擴展,那麼這是您應該看的地方。如果遵循編碼標準,那麼通常應該是src/BundleName/Twig /'。看看有關[創建函數和過濾器]的twig文檔(http://twig.sensiolabs.org/doc/advanced.html)。 – Artamiel