mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-15 02:04:54 +02:00
Update Twig to v2.15.4
This commit is contained in:
@@ -21,9 +21,9 @@ use Twig\Error\SyntaxError;
|
||||
*/
|
||||
class MacroNode extends Node
|
||||
{
|
||||
const VARARGS_NAME = 'varargs';
|
||||
public const VARARGS_NAME = 'varargs';
|
||||
|
||||
public function __construct($name, \Twig_NodeInterface $body, \Twig_NodeInterface $arguments, $lineno, $tag = null)
|
||||
public function __construct(string $name, Node $body, Node $arguments, int $lineno, string $tag = null)
|
||||
{
|
||||
foreach ($arguments as $argumentName => $argument) {
|
||||
if (self::VARARGS_NAME === $argumentName) {
|
||||
@@ -38,7 +38,7 @@ class MacroNode extends Node
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write(sprintf('public function get%s(', $this->getAttribute('name')))
|
||||
->write(sprintf('public function macro_%s(', $this->getAttribute('name')))
|
||||
;
|
||||
|
||||
$count = \count($this->getNode('arguments'));
|
||||
@@ -54,21 +54,16 @@ class MacroNode extends Node
|
||||
}
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID >= 50600) {
|
||||
if ($count) {
|
||||
$compiler->raw(', ');
|
||||
}
|
||||
|
||||
$compiler->raw('...$__varargs__');
|
||||
if ($count) {
|
||||
$compiler->raw(', ');
|
||||
}
|
||||
|
||||
$compiler
|
||||
->raw('...$__varargs__')
|
||||
->raw(")\n")
|
||||
->write("{\n")
|
||||
->indent()
|
||||
;
|
||||
|
||||
$compiler
|
||||
->write("\$macros = \$this->macros;\n")
|
||||
->write("\$context = \$this->env->mergeGlobals([\n")
|
||||
->indent()
|
||||
;
|
||||
@@ -88,19 +83,8 @@ class MacroNode extends Node
|
||||
->raw(' => ')
|
||||
;
|
||||
|
||||
if (\PHP_VERSION_ID >= 50600) {
|
||||
$compiler->raw("\$__varargs__,\n");
|
||||
} else {
|
||||
$compiler
|
||||
->raw('func_num_args() > ')
|
||||
->repr($count)
|
||||
->raw(' ? array_slice(func_get_args(), ')
|
||||
->repr($count)
|
||||
->raw(") : [],\n")
|
||||
;
|
||||
}
|
||||
|
||||
$compiler
|
||||
->raw("\$__varargs__,\n")
|
||||
->outdent()
|
||||
->write("]);\n\n")
|
||||
->write("\$blocks = [];\n\n")
|
||||
@@ -114,19 +98,14 @@ class MacroNode extends Node
|
||||
->write("try {\n")
|
||||
->indent()
|
||||
->subcompile($this->getNode('body'))
|
||||
->raw("\n")
|
||||
->write("return ('' === \$tmp = ob_get_contents()) ? '' : new Markup(\$tmp, \$this->env->getCharset());\n")
|
||||
->outdent()
|
||||
->write("} catch (\Exception \$e) {\n")
|
||||
->write("} finally {\n")
|
||||
->indent()
|
||||
->write("ob_end_clean();\n\n")
|
||||
->write("throw \$e;\n")
|
||||
->write("ob_end_clean();\n")
|
||||
->outdent()
|
||||
->write("} catch (\Throwable \$e) {\n")
|
||||
->indent()
|
||||
->write("ob_end_clean();\n\n")
|
||||
->write("throw \$e;\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Markup(\$tmp, \$this->env->getCharset());\n")
|
||||
->write("}\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
;
|
||||
|
Reference in New Issue
Block a user