[ticket/15214] Replace arrow functions with anonymous functions

Arrow functions aren't added until PHP 7.4, so we can't use them yet.
Anonymous functions have been added since PHP 5.3

PHPBB3-15214
This commit is contained in:
toxyy 2023-12-03 17:44:38 -05:00
parent c7d16febef
commit 8d6d016a5a

View file

@ -65,30 +65,36 @@ class event extends \Twig\Node\Node
// templates on page load rather than at compile. This is // templates on page load rather than at compile. This is
// slower, but makes developing extensions easier (no need to // slower, but makes developing extensions easier (no need to
// purge the cache when a new event template file is added) // purge the cache when a new event template file is added)
$compiler_calls[] = fn() => $compiler $compiler_calls[] = function() use($compiler, $ext_namespace, $location) {
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n") $compiler
->indent() ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
; ->indent()
;
};
} }
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{ {
$compiler_calls[] = fn() => $compiler $compiler_calls[] = function() use($compiler, $ext_namespace, $location) {
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") $compiler
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
// We set the namespace lookup order to be this extension first, then the main path // We set the namespace lookup order to be this extension first, then the main path
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n") ->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n") ->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
; ;
};
} }
if ($this->environment->isDebug()) if ($this->environment->isDebug())
{ {
$compiler_calls[] = fn() => $compiler $compiler_calls[] = function() use($compiler) {
->outdent() $compiler
->write("}\n\n") ->outdent()
; ->write("}\n\n")
;
};
} }
if (!empty($compiler_calls)) if (!empty($compiler_calls))