From 02c0cb59f3abd7b70a752d7481d89e11fa2ed2db Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 21 Oct 2016 20:25:38 -0700 Subject: [PATCH] removed obsolete code --- lib/Twig/Environment.php | 11 +---------- lib/Twig/Extension/Core.php | 6 +----- lib/Twig/Test/IntegrationTestCase.php | 8 +------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 0ab6e98d6..273ba5f8e 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -325,17 +325,8 @@ class Twig_Environment } if (!class_exists($cls, false)) { - $loader = $this->getLoader(); - if (!$loader instanceof Twig_SourceContextLoaderInterface) { - $source = new Twig_Source($loader->getSource($name), $name); - } else { - $source = $loader->getSourceContext($name); - } - - $content = $this->compileSource($source); - + $content = $this->compileSource($this->getLoader()->getSourceContext($name)); $this->cache->write($key, $content); - eval('?>'.$content); } } diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index c805b5631..77963604d 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -1304,11 +1304,7 @@ function twig_source(Twig_Environment $env, $name, $ignoreMissing = false) { $loader = $env->getLoader(); try { - if (!$loader instanceof Twig_SourceContextLoaderInterface) { - return $loader->getSource($name); - } else { - return $loader->getSourceContext($name)->getCode(); - } + return $loader->getSourceContext($name)->getCode(); } catch (Twig_Error_Loader $e) { if (!$ignoreMissing) { throw $e; diff --git a/lib/Twig/Test/IntegrationTestCase.php b/lib/Twig/Test/IntegrationTestCase.php index 175ec2dde..786e3ba86 100644 --- a/lib/Twig/Test/IntegrationTestCase.php +++ b/lib/Twig/Test/IntegrationTestCase.php @@ -209,13 +209,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase foreach (array_keys($templates) as $name) { echo "Template: $name\n"; - $loader = $twig->getLoader(); - if (!$loader instanceof Twig_SourceContextLoaderInterface) { - $source = new Twig_Source($loader->getSource($name), $name); - } else { - $source = $loader->getSourceContext($name); - } - echo $twig->compile($twig->parse($twig->tokenize($source))); + echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext($name)))); } } $this->assertEquals($expected, $output, $message.' (in '.$file.')');