mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-02 18:07:35 +00:00
Compile the generator guard as an unreachable yield instead of a yield from
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
* Fix the escaping safe analysis retaining every compiled template node for the lifetime of the environment
|
||||
* Speed up loading a template that the environment has already loaded
|
||||
* Speed up rendering by compiling a cheaper generator guard into templates
|
||||
* Fix `IntlExtension` letting the pattern derived from a date formatter prototype override an explicit locale
|
||||
* Fix `IntlExtension` not honoring the locale of a date formatter prototype configured with no date and time styles
|
||||
* Speed up macro calls
|
||||
|
||||
@@ -42,7 +42,7 @@ class BlockNode extends Node
|
||||
|
||||
$compiler
|
||||
->subcompile($this->getNode('body'))
|
||||
->write("yield from [];\n")
|
||||
->write("return; yield;\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
;
|
||||
|
||||
@@ -39,7 +39,7 @@ class CaptureNode extends Node
|
||||
->raw("(function () use (&\$context, \$macros, \$blocks) {\n")
|
||||
->indent()
|
||||
->subcompile($this->getNode('body'))
|
||||
->write("yield from [];\n")
|
||||
->write("return; yield;\n")
|
||||
->outdent()
|
||||
->write('})()')
|
||||
;
|
||||
|
||||
@@ -379,7 +379,7 @@ final class ModuleNode extends Node implements CoercesChildrenToStringInterface
|
||||
$compiler->subcompile($this->getNode('display_end'));
|
||||
|
||||
if (!$this->hasNode('parent')) {
|
||||
$compiler->write("yield from [];\n");
|
||||
$compiler->write("return; yield;\n");
|
||||
}
|
||||
|
||||
$compiler
|
||||
|
||||
@@ -49,7 +49,7 @@ public function block_foo(array \$context, array \$blocks = []): iterable
|
||||
{
|
||||
\$macros = \$this->macros;
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
}
|
||||
EOF, new Environment(new ArrayLoader()),
|
||||
];
|
||||
|
||||
@@ -77,7 +77,7 @@ new \\Twig\\TwigMacro("foo", function (\$foo = null, \$bar = "Foo", \$_underscor
|
||||
|
||||
return ('' === \$tmp = implode('', iterator_to_array((function () use (&\$context, \$macros, \$blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
})(), false))) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
||||
}, ["foo" => true, "bar" => true, "_underscore" => true], false)
|
||||
EOF, new Environment(new ArrayLoader(), ['use_yield' => true]),
|
||||
@@ -98,7 +98,7 @@ new \\Twig\\TwigMacro("foo", function (\$foo = null, \$bar = "Foo", \$_underscor
|
||||
|
||||
return ('' === \$tmp = \\Twig\\Extension\\CoreExtension::captureOutput((function () use (&\$context, \$macros, \$blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
})())) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
||||
}, ["foo" => true, "bar" => true, "_underscore" => true], false)
|
||||
EOF, new Environment(new ArrayLoader(), ['use_yield' => false]),
|
||||
|
||||
@@ -74,7 +74,7 @@ protected function loadDeclaredMacros(): array
|
||||
|
||||
return ('' === \$tmp = implode('', iterator_to_array((function () use (&\$context, \$macros, \$blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
})(), false))) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
||||
}, ["foo" => true], false),
|
||||
];
|
||||
|
||||
@@ -159,7 +159,7 @@ class __TwigTemplate_%x extends Template
|
||||
\$macros = \$this->macros;
|
||||
// line 1
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ EOF
|
||||
// line 1
|
||||
\$context["foo"] = ('' === \$tmp = implode('', iterator_to_array((function () use (&\$context, \$macros, \$blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
})(), false))) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
||||
EOF, new Environment(new ArrayLoader(), ['use_yield' => true]),
|
||||
];
|
||||
@@ -74,7 +74,7 @@ EOF, new Environment(new ArrayLoader(), ['use_yield' => true]),
|
||||
// line 1
|
||||
$context["foo"] = ('' === $tmp = \Twig\Extension\CoreExtension::captureOutput((function () use (&$context, $macros, $blocks) {
|
||||
yield "foo";
|
||||
yield from [];
|
||||
return; yield;
|
||||
})())) ? '' : new Markup($tmp, $this->env->getCharset());
|
||||
EOF, new Environment(new ArrayLoader(), ['use_yield' => false]),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user