silexphp / Silex-WebProfiler

MIT License
210 stars 61 forks source link

Deprecation errors from Twig #103

Closed Wirone closed 8 years ago

Wirone commented 8 years ago

Silex\Provider\WebProfilerServiceProvider::register() (v2.0.4) produces deprecation warnings

Passing a name as a first argument to the Twig_Environment::addFilter method is deprecated since version 1.21. Pass an instance of "Twig_SimpleFilter" instead when defining filter "yaml_encode"

Passing a name as a first argument to the Twig_Environment::addFunction method is deprecated since version 1.21. Pass an instance of "Twig_SimpleFunction" instead when defining function "yaml_encode"

when Twig is extended:

$app['twig'] = $app->extend('twig', function ($twig, $app) {
    $twig->addFilter('yaml_encode', new \Twig_SimpleFilter('yaml_encode', function (array $var) {
        return Yaml::dump($var);
    }));

    $twig->addFunction('yaml_encode', new \Twig_SimpleFunction('yaml_encode', function (array $var) {
        return Yaml::dump($var);
    }));

    return $twig;
});

Maybe Twig_Environment::VERSION can be checked and Twig could be extended in proper way if >=1.21?

SpacePossum commented 8 years ago

this is resolved on master, so all that is needed is a new tag release tag and this should go away

Wirone commented 8 years ago

@SpacePossum as far as I see in master's latest commit there's still the same Twig extending like mentioned above, which will produce deprecation warnings.

SpacePossum commented 8 years ago

Indeed, I looked in the wrong branch, on 1.x addFilter is not used, but addExtension, sorry!