minor #33612 [Twig] Remove dead code (fabpot)
This PR was merged into the 3.4 branch.
Discussion
----------
[Twig] Remove dead code
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | n/a
| License | MIT
| Doc PR | n/a
As the min version of Twig is 1.41, we can remove some dead code.
Commits
-------
786d136b5e
[Twig] Remove dead code
This commit is contained in:
commit
d9ce895cee
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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}
|
||||
*
|
||||
|
Reference in New Issue
Block a user