diff --git a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php index b17da340989e1..618ed4e585c7d 100644 --- a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php +++ b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php @@ -15,6 +15,7 @@ use Symfony\Component\Form\FormView; use Twig\Environment; use Twig\Template; +use Twig\YieldingTemplate; /** * @author Bernhard Schussek @@ -46,13 +47,17 @@ public function renderBlock(FormView $view, $resource, string $blockName, array $context = $this->environment->mergeGlobals($variables); - ob_start(); - // By contract,This method can only be called after getting the resource // (which is passed to the method). Getting a resource for the first time // (with an empty cache) is guaranteed to invoke loadResourcesFromTheme(), // where the property $template is initialized. + if ($this->template instanceof YieldingTemplate) { + return $this->template->renderBlock($blockName, $context, $this->resources[$cacheKey]); + } + + ob_start(); + // We do not call renderBlock here to avoid too many nested level calls // (XDebug limits the level to 100 by default) $this->template->displayBlock($blockName, $context, $this->resources[$cacheKey]); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index b04b8a6a739ae..91485722e3115 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -138,7 +138,7 @@ public static function getDebugTemplateNameTestData() (None) templates%e%A %A @Twig templates/bundles/TwigBundle%e%A - vendors/twig-bundle/Resources/views%e%A + vendors/twig-bundle/Resources/views%e%A ----------- -------------------------------------%A @@ -305,7 +305,7 @@ public function testComplete(array $input, array $expectedSuggestions) $projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'; $loader = new FilesystemLoader([], $projectDir); - $environment = new Environment($loader); + $environment = new Environment($loader, ['use_yield' => true]); $application = new Application(); $application->add(new DebugCommand($environment, $projectDir, [], null, null)); @@ -337,7 +337,7 @@ private function createCommandTester(array $paths = [], array $bundleMetadata = $loader = new ChainLoader([$loader]); } - $environment = new Environment($loader); + $environment = new Environment($loader, ['use_yield' => true]); foreach ($globals as $name => $value) { $environment->addGlobal($name, $value); } diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 18d09b20b2d95..408bebc89a113 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -162,7 +162,7 @@ private function createCommandTester(): CommandTester private function createCommand(): Command { - $environment = new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/')); + $environment = new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/'), ['use_yield' => true]); $environment->addFilter(new TwigFilter('deprecated_filter', function ($v) { return $v; }, ['deprecated' => true])); diff --git a/src/Symfony/Bridge/Twig/Tests/ErrorRenderer/TwigErrorRendererTest.php b/src/Symfony/Bridge/Twig/Tests/ErrorRenderer/TwigErrorRendererTest.php index 9febc61e61887..c351229d661d1 100644 --- a/src/Symfony/Bridge/Twig/Tests/ErrorRenderer/TwigErrorRendererTest.php +++ b/src/Symfony/Bridge/Twig/Tests/ErrorRenderer/TwigErrorRendererTest.php @@ -40,7 +40,7 @@ public function testFallbackToNativeRendererIfCustomTemplateNotFound() { $exception = new NotFoundHttpException(); - $twig = new Environment(new ArrayLoader([])); + $twig = new Environment(new ArrayLoader([]), ['use_yield' => true]); $nativeRenderer = $this->createMock(HtmlErrorRenderer::class); $nativeRenderer @@ -57,7 +57,7 @@ public function testRenderCustomErrorTemplate() { $twig = new Environment(new ArrayLoader([ '@Twig/Exception/error404.html.twig' => '

Page Not Found

', - ])); + ]), ['use_yield' => true]); $exception = (new TwigErrorRenderer($twig))->render(new NotFoundHttpException()); $this->assertSame('

Page Not Found

', $exception->getAsString()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php index c7c859f067c7a..35464d7042735 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php @@ -116,7 +116,6 @@ public function testFormatArgsIntegration() $this->assertEquals($expected, $this->render($template, $data)); } - public function testFormatFileIntegration() { $template = <<<'TWIG' @@ -156,7 +155,7 @@ private function render(string $template, array $context = []) { $twig = new Environment( new ArrayLoader(['index' => $template]), - ['debug' => true] + ['debug' => true, 'use_yield' => true] ); $twig->addExtension($this->getExtension()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 8fe455e5d5706..04169e1e33262 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -32,6 +32,7 @@ public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) 'debug' => $debug, 'cache' => false, 'optimizations' => 0, + 'use_yield' => true, ]); $twig->addExtension($extension); @@ -72,6 +73,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true) 'debug' => $debug, 'cache' => false, 'optimizations' => 0, + 'use_yield' => true, ]); array_unshift($args, $context); @@ -129,6 +131,7 @@ public function testCustomDumper() 'debug' => true, 'cache' => false, 'optimizations' => 0, + 'use_yield' => true, ]); $dump = $extension->dump($twig, [], 'foo'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php index bfb9c578bbc95..e4096d609c01e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php @@ -21,7 +21,7 @@ class ExpressionExtensionTest extends TestCase public function testExpressionCreation() { $template = "{{ expression('1 == 1') }}"; - $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); + $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0, 'use_yield' => true]); $twig->addExtension(new ExpressionExtension()); $output = $twig->render('template'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index e746a267105e2..2efd9f026e2ec 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -43,7 +43,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 2b7e186c0d5cd..e70e4bfaf309d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -39,7 +39,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); @@ -80,7 +80,7 @@ public function testMoneyWidgetInIso() $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - ]), ['strict_variables' => true]); + ]), ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index f95e678440b4d..59653f3826f29 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -45,7 +45,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index 2d0ca9fabab21..0180f53ebc11b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -43,7 +43,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); @@ -84,7 +84,7 @@ public function testMoneyWidgetInIso() $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - ]), ['strict_variables' => true]); + ]), ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php index d6d2c3c2ecb06..4ad7ccd09fb21 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php @@ -45,7 +45,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php index 94174615a0ce0..64db408055a55 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php @@ -46,7 +46,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); @@ -87,7 +87,7 @@ public function testMoneyWidgetInIso() $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - ]), ['strict_variables' => true]); + ]), ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 5de8fb90e1a93..e81e539aa4ba2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -41,7 +41,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); // the value can be any template that exists @@ -171,7 +171,7 @@ public function testMoneyWidgetInIso() $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - ]), ['strict_variables' => true]); + ]), ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 25d595df7c9d3..7eabc19c277a0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -40,7 +40,7 @@ protected function setUp(): void __DIR__.'/Fixtures/templates/form', ]); - $environment = new Environment($loader, ['strict_variables' => true]); + $environment = new Environment($loader, ['strict_variables' => true, 'use_yield' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); $environment->addExtension(new FormExtension()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index 9a7f9cd5257b7..2cfbde9c134c0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -75,7 +75,7 @@ public function testGenerateFragmentUri() {{ fragment_uri(controller("%s::templateAction", {template: "foo.html.twig"})) }} TWIG , TemplateController::class), ]); - $twig = new Environment($loader, ['debug' => true, 'cache' => false]); + $twig = new Environment($loader, ['debug' => true, 'cache' => false, 'use_yield' => true]); $twig->addExtension(new HttpKernelExtension()); $loader = $this->createMock(RuntimeLoaderInterface::class); @@ -103,7 +103,7 @@ protected function getFragmentHandler($return) protected function renderTemplate(FragmentHandler $renderer, $template = '{{ render("foo") }}') { $loader = new ArrayLoader(['index' => $template]); - $twig = new Environment($loader, ['debug' => true, 'cache' => false]); + $twig = new Environment($loader, ['debug' => true, 'cache' => false, 'use_yield' => true]); $twig->addExtension(new HttpKernelExtension()); $loader = $this->createMock(RuntimeLoaderInterface::class); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php index 742a74f325b91..bb555f06b5b8b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php @@ -26,7 +26,7 @@ class RoutingExtensionTest extends TestCase */ public function testEscaping($template, $mustBeEscaped) { - $twig = new Environment($this->createMock(LoaderInterface::class), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); + $twig = new Environment($this->createMock(LoaderInterface::class), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0, 'use_yield' => true]); $twig->addExtension(new RoutingExtension($this->createMock(UrlGeneratorInterface::class))); $nodes = $twig->parse($twig->tokenize(new Source($template, ''))); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php index 0c36c8c6b4b93..46fe6dbbc35eb 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php @@ -61,7 +61,7 @@ private function getTwig(string $template): Environment ]) ; - $twig = new Environment(new ArrayLoader(['template' => $template])); + $twig = new Environment(new ArrayLoader(['template' => $template, 'use_yield' => true])); $twig->addExtension(new SerializerExtension()); $twig->addRuntimeLoader($mockRuntimeLoader); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index d7ff03d72ff98..ec46ae711c3e5 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php @@ -32,7 +32,7 @@ public function testFailIfStoppingWrongEvent() */ public function testTiming($template, $events) { - $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); + $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0, 'use_yield' => true]); $twig->addExtension(new StopwatchExtension($this->getStopwatch($events))); try { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index a0230aa239606..c7abc6b30b56d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -37,7 +37,7 @@ public function testTrans($template, $expected, array $variables = []) if ($expected != $this->getTemplate($template)->render($variables)) { echo $template."\n"; $loader = new TwigArrayLoader(['index' => $template]); - $twig = new Environment($loader, ['debug' => true, 'cache' => false]); + $twig = new Environment($loader, ['debug' => true, 'cache' => false, 'use_yield' => true]); $twig->addExtension(new TranslationExtension(new Translator('en'))); echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext('index'))))."\n\n"; @@ -217,7 +217,7 @@ private function getTemplate($template, ?TranslatorInterface $translator = null) } else { $loader = new TwigArrayLoader(['index' => $template]); } - $twig = new Environment($loader, ['debug' => true, 'cache' => false]); + $twig = new Environment($loader, ['debug' => true, 'cache' => false, 'use_yield' => true]); $twig->addExtension(new TranslationExtension($translator)); return $twig->load('index'); diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php index 8ff343b684b5e..87342aa53b19f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php @@ -83,7 +83,7 @@ public function testRenderedOnce() { $twig = new Environment(new ArrayLoader([ 'text' => 'Text', - ])); + ]), ['use_yield' => true]); $renderer = new BodyRenderer($twig); $email = (new TemplatedEmail()) ->to('fabien@symfony.com') @@ -104,7 +104,7 @@ public function testRenderedOnceUnserializableContext() { $twig = new Environment(new ArrayLoader([ 'text' => 'Text', - ])); + ]), ['use_yield' => true]); $renderer = new BodyRenderer($twig); $email = (new TemplatedEmail()) ->to('fabien@symfony.com') @@ -128,7 +128,7 @@ private function prepareEmail(?string $text, ?string $html, array $context = []) 'html' => $html, 'document.txt' => 'Some text document...', 'image.jpg' => 'Some image data', - ])); + ]), ['use_yield' => true]); $renderer = new BodyRenderer($twig); $email = (new TemplatedEmail()) ->to('fabien@symfony.com') diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index f655a04ae3bd6..b3ff5121dd216 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -25,7 +25,7 @@ public function testNoVar() { $node = new DumpNode('bar', null, 7); - $env = new Environment($this->createMock(LoaderInterface::class)); + $env = new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true]); $compiler = new Compiler($env); $expected = <<<'EOTXT' @@ -49,7 +49,7 @@ public function testIndented() { $node = new DumpNode('bar', null, 7); - $env = new Environment($this->createMock(LoaderInterface::class)); + $env = new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true]); $compiler = new Compiler($env); $expected = <<<'EOTXT' @@ -76,7 +76,7 @@ public function testOneVar() ]); $node = new DumpNode('bar', $vars, 7); - $env = new Environment($this->createMock(LoaderInterface::class)); + $env = new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true]); $compiler = new Compiler($env); $expected = <<<'EOTXT' @@ -100,7 +100,7 @@ public function testMultiVars() ]); $node = new DumpNode('bar', $vars, 7); - $env = new Environment($this->createMock(LoaderInterface::class)); + $env = new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true]); $compiler = new Compiler($env); $expected = <<<'EOTXT' diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index cf98191233057..2542634c9b3e0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -55,7 +55,7 @@ public function testCompile() $node = new FormThemeNode($form, $resources, 0); - $environment = new Environment($this->createMock(LoaderInterface::class)); + $environment = new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true]); $formRenderer = new FormRenderer($this->createMock(FormRendererEngineInterface::class)); $this->registerTwigRuntimeLoader($environment, $formRenderer); $compiler = new Compiler($environment); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index b259990e0b7ad..e9e6bab47119f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -33,7 +33,7 @@ public function testCompileWidget() $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); $this->assertEquals( sprintf( @@ -56,7 +56,7 @@ public function testCompileWidgetWithVariables() $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); $this->assertEquals( sprintf( @@ -76,7 +76,7 @@ public function testCompileLabelWithLabel() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); $this->assertEquals( sprintf( @@ -96,7 +96,7 @@ public function testCompileLabelWithNullLabel() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -118,7 +118,7 @@ public function testCompileLabelWithEmptyStringLabel() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -139,7 +139,7 @@ public function testCompileLabelWithDefaultLabel() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); $this->assertEquals( sprintf( @@ -163,7 +163,7 @@ public function testCompileLabelWithAttributes() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -192,7 +192,7 @@ public function testCompileLabelWithLabelAndAttributes() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); $this->assertEquals( sprintf( @@ -220,7 +220,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -258,7 +258,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class))); + $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true])); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index c6d3064676937..e9a683b326e78 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -30,7 +30,7 @@ public function testCompileStrict() $vars = new NameExpression('foo', 0); $node = new TransNode($body, null, null, $vars); - $env = new Environment($this->createMock(LoaderInterface::class), ['strict_variables' => true]); + $env = new Environment($this->createMock(LoaderInterface::class), ['strict_variables' => true, 'use_yield' => true]); $compiler = new Compiler($env); $this->assertEquals( diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index 25b8166eae62a..d3336cf229656 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -27,7 +27,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase /** @dataProvider getDefaultDomainAssignmentTestData */ public function testDefaultDomainAssignment(Node $node) { - $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0, 'use_yield' => true]); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag @@ -53,7 +53,7 @@ public function testDefaultDomainAssignment(Node $node) /** @dataProvider getDefaultDomainAssignmentTestData */ public function testNewModuleWithoutDefaultDomainTag(Node $node) { - $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0, 'use_yield' => true]); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index bf073602583f7..8140749a65978 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -26,7 +26,7 @@ class TranslationNodeVisitorTest extends TestCase /** @dataProvider getMessagesExtractionTestData */ public function testMessagesExtraction(Node $node, array $expectedMessages) { - $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0, 'use_yield' => true]); $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index 41504050f74f8..b9fd2cdb4c5a0 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -29,7 +29,7 @@ class FormThemeTokenParserTest extends TestCase */ public function testCompile($source, $expected) { - $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0, 'use_yield' => true]); $env->addTokenParser(new FormThemeTokenParser()); $source = new Source($source, ''); $stream = $env->tokenize($source); diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 4e7b501da0050..d47e50ddff52f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -35,6 +35,7 @@ public function testExtract($template, $messages) 'debug' => true, 'cache' => false, 'autoescape' => false, + 'use_yield' => true, ]); $twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class))); @@ -100,7 +101,7 @@ public static function getExtractData() */ public function testExtractSyntaxError($resources, array $messages) { - $twig = new Environment($this->createMock(LoaderInterface::class)); + $twig = new Environment($this->createMock(LoaderInterface::class), ['use_yield' => true]); $twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class))); $extractor = new TwigExtractor($twig); @@ -129,6 +130,7 @@ public function testExtractWithFiles($resource) 'debug' => true, 'cache' => false, 'autoescape' => false, + 'use_yield' => true, ]); $twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class))); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index c403a4c598fd1..bd13b7a99c7aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -63,7 +63,7 @@ public function testContext() $loader = new ArrayLoader(); $loader->setTemplate($templateName, '

{{param}}

'); - $twig = new Environment($loader); + $twig = new Environment($loader, ['use_yield' => true]); $controller = new TemplateController($twig); $this->assertEquals($expected, $controller->templateAction($templateName, null, null, null, $context)->getContent()); @@ -78,7 +78,7 @@ public function testStatusCode() $loader = new ArrayLoader(); $loader->setTemplate($templateName, '

{{param}}

'); - $twig = new Environment($loader); + $twig = new Environment($loader, ['use_yield' => true]); $controller = new TemplateController($twig); $this->assertSame(201, $controller->templateAction($templateName, null, null, null, [], $statusCode)->getStatusCode()); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 36b05857546de..b2a4e50db7916 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -137,6 +137,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode) ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() ->booleanNode('strict_variables')->defaultValue('%kernel.debug%')->end() + ->booleanNode('use_yield')->defaultFalse()->end() ->scalarNode('auto_reload')->end() ->integerNode('optimizations')->min(-1)->end() ->scalarNode('default_path') diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd b/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd index 429c91db67b74..6ac560a7e048e 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd @@ -25,6 +25,7 @@ + diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index 2dd09aca3e0fd..03b1a48033b6e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -76,7 +76,7 @@ public function testRenderWithAttributesOptions() public function testRenderWithTwigAndDefaultText() { - $twig = new Environment($loader = new ArrayLoader()); + $twig = new Environment($loader = new ArrayLoader(), ['use_yield' => true]); $strategy = new HIncludeFragmentRenderer($twig); $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent()); } diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php index 1c7dcc07ff4e9..aa74890cde615 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php @@ -331,7 +331,7 @@ public function testThrowingCaster() $out = fopen('php://memory', 'r+'); require_once __DIR__.'/../Fixtures/Twig.php'; - $twig = new \__TwigTemplate_VarDumperFixture_u75a09(new Environment(new FilesystemLoader())); + $twig = new \__TwigTemplate_VarDumperFixture_u75a09(new Environment(new FilesystemLoader(), ['use_yield' => true])); $dumper = new CliDumper(); $dumper->setColors(false); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy