minor #21030 [TwigBridge] fix Twig 2.x compatibility (xabbuh)

This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBridge] fix Twig 2.x compatibility

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | twigphp/Twig#2302
| License       | MIT
| Doc PR        |

Commits
-------

08e5747 [TwigBridge] fix Twig 2.x compatibility
This commit is contained in:
Fabien Potencier 2016-12-23 13:31:39 +01:00
commit 7fa18ba1b9

View File

@ -53,7 +53,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
protected function getVariableGetterWithStrictCheck($name)
{
if (\Twig_Environment::MAJOR_VERSION >= 2) {
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name);
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name);
}
if (PHP_VERSION_ID >= 70000) {