diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index 71180156ba..ce1980eb16 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -34,9 +34,7 @@ class FormThemeTokenParserTest extends TestCase $stream = $env->tokenize($source); $parser = new Parser($env); - if (method_exists($expected, 'setSourceContext')) { - $expected->setSourceContext($source); - } + $expected->setSourceContext($source); $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)); } diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 3f14878d1e..82d7298365 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -89,13 +89,10 @@ class TwigExtractorTest extends TestCase try { $extractor->extract($resources, new MessageCatalogue('en')); } catch (Error $e) { - if (method_exists($e, 'getSourceContext')) { - $this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile()); - $this->assertSame(1, $e->getLine()); - $this->assertSame('Unclosed "block".', $e->getMessage()); - } else { - $this->expectExceptionMessageRegExp('/Unclosed "block" in ".*extractor(\\/|\\\\)syntax_error\\.twig" at line 1/'); - } + $this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile()); + $this->assertSame(1, $e->getLine()); + $this->assertSame('Unclosed "block".', $e->getMessage()); + throw $e; } } diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index 56427c762f..b7c7872266 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -61,11 +61,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface if ($file instanceof \SplFileInfo) { $path = $file->getRealPath() ?: $file->getPathname(); $name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path; - if (method_exists($e, 'setSourceContext')) { - $e->setSourceContext(new Source('', $name, $path)); - } else { - $e->setTemplateName($name); - } + $e->setSourceContext(new Source('', $name, $path)); } throw $e; diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 39115199e5..f2dc6b5569 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -13,7 +13,6 @@ namespace Symfony\Bundle\TwigBundle; use Symfony\Bridge\Twig\TwigEngine as BaseEngine; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\TemplateNameParserInterface; @@ -36,28 +35,6 @@ class TwigEngine extends BaseEngine implements EngineInterface $this->locator = $locator; } - /** - * {@inheritdoc} - */ - public function render($name, array $parameters = []) - { - try { - return parent::render($name, $parameters); - } catch (Error $e) { - if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) { - try { - // try to get the real name of the template where the error occurred - $name = $e->getTemplateName(); - $path = (string) $this->locator->locate($this->parser->parse($name)); - $e->setTemplateName($path); - } catch (\Exception $e2) { - } - } - - throw $e; - } - } - /** * {@inheritdoc} *